5 unshift @INC, "../lib" if -d "../lib";
6 eval { require Config; import Config; };
8 if ($Config{'i_pwd'} ne 'define') {
9 $reason = '$Config{i_pwd} undefined';
11 elsif (not -f "/etc/passwd" ) { # Play safe.
12 $reason = 'no /etc/passwd file';
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";
27 if (not defined $where) { # Try NetInfo.
28 foreach my $nidump (qw(/usr/bin/nidump)) {
30 open(PW, "$nidump passwd . 2>/dev/null |") &&
32 $where = "NetInfo passwd";
39 if (not defined $where) { # Try local.
40 my $PW = "/etc/passwd";
41 if (-f $PW && open(PW, $PW) && defined(<PW>)) {
47 if ($reason) { # Give up.
48 print "1..0 # Skip: $reason\n";
53 # By now PW filehandle should be open and full of juicy password entries.
57 # Go through at most this many users.
58 # (note that the first entry has been read away by now)
69 my ($name_s, $passwd_s, $uid_s, $gid_s, $gcos_s, $home_s, $shell_s) = @s;
70 next if /^\+/; # ignore NIS includes
72 push @{ $seen{$name_s} }, $.;
74 warn "# Your $where line $. is empty.\n";
78 # In principle we could whine if @s != 7 but do we know enough
79 # of passwd file formats everywhere?
81 @n = getpwuid($uid_s);
84 my ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n;
85 # Protect against one-to-many and many-to-one mappings.
86 if ($name_s ne $name) {
87 @n = getpwnam($name_s);
88 ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n;
89 next if $name_s ne $name;
92 if $name eq $name_s and
94 # Do not compare passwords: think shadow passwords.
103 if (keys %perfect == 0) {
107 # The failure of op/pwent test is not necessarily serious.
108 # It may fail due to local password administration conventions.
109 # If you are for example using both NIS and local passwords,
110 # test failure is possible. Any distributed password scheme
111 # can cause such failures.
113 # What the pwent test is doing is that it compares the $max first
115 # with the results of getpwuid() and getpwnam() call. If it finds no
116 # matches at all, it suspects something is wrong.
125 print "\t# (not necessarily serious: run t/op/pwent.t by itself)" if $not;