5 unshift @INC, "../lib" if -d "../lib";
6 eval { require Config; import Config; };
8 unless (defined $Config{'i_pwd'} &&
9 $Config{'i_pwd'} eq 'define' &&
10 -f "/etc/passwd" ) { # Play safe.
15 if (not defined $where) { # Try NIS.
16 foreach my $ypcat (qw(/usr/bin/ypcat /bin/ypcat /etc/ypcat)) {
18 open(PW, "$ypcat passwd 2>/dev/null |") &&
20 $where = "NIS passwd";
26 if (not defined $where) { # Try NetInfo.
27 foreach my $nidump (qw(/usr/bin/nidump)) {
29 open(PW, "$nidump passwd . 2>/dev/null |") &&
31 $where = "NetInfo passwd";
37 if (not defined $where) { # Try local.
38 my $PW = "/etc/passwd";
39 if (-f $PW && open(PW, $PW) && defined(<PW>)) {
44 if (not defined $where) { # Give up.
50 # By now PW filehandle should be open and full of juicy password entries.
54 # Go through at most this many users.
55 # (note that the first entry has been read away by now)
66 my ($name_s, $passwd_s, $uid_s, $gid_s, $gcos_s, $home_s, $shell_s) = @s;
67 next if /^\+/; # ignore NIS includes
69 push @{ $seen{$name_s} }, $.;
71 warn "# Your $where line $. is empty.\n";
75 # In principle we could whine if @s != 7 but do we know enough
76 # of passwd file formats everywhere?
78 @n = getpwuid($uid_s);
81 my ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n;
82 # Protect against one-to-many and many-to-one mappings.
83 if ($name_s ne $name) {
84 @n = getpwnam($name_s);
85 ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n;
86 next if $name_s ne $name;
89 if $name eq $name_s and
91 # Do not compare passwords: think shadow passwords.
100 if (keys %perfect == 0) {
104 # The failure of op/pwent test is not necessarily serious.
105 # It may fail due to local password administration conventions.
106 # If you are for example using both NIS and local passwords,
107 # test failure is possible. Any distributed password scheme
108 # can cause such failures.
110 # What the pwent test is doing is that it compares the $max first
112 # with the results of getpwuid() and getpwnam() call. If it finds no
113 # matches at all, it suspects something is wrong.
122 print "\t# (not necessarily serious: run t/op/pwent.t by itself)" if $not;