5 @INC = "../lib" if -d "../lib";
6 eval { require Config; import Config; };
8 my $PW = "/etc/passwd";
12 if (-x "/usr/bin/nidump") { # nidump is not just NeXT/OpenStep
13 if (open(PW, "nidump passwd . |")) {
14 $where = "NetInfo passwd";
19 } elsif ((defined $Config{'i_pwd'} and $Config{'i_pwd'} ne 'define')
20 or not -f $PW or not open(PW, $PW)) {
28 # Go through at most this many users.
38 next if /^\+/; # ignore NIS includes
40 my ($name_s, $passwd_s, $uid_s, $gid_s, $gcos_s, $home_s, $shell_s) = @s;
42 push @{ $seen{$name_s} }, $.;
44 warn "# Your $where line $. is empty.\n";
48 # In principle we could whine if @s != 7 but do we know enough
49 # of passwd file formats everywhere?
51 @n = getpwuid($uid_s);
54 my ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n;
55 # Protect against one-to-many and many-to-one mappings.
56 if ($name_s ne $name) {
57 @n = getpwnam($name_s);
58 ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n;
59 next if $name_s ne $name;
62 if $name ne $name_s or
63 # Shadow passwords confuse this.
64 # Think about non-crypt(3) encryptions, too, before you do anything rash.
65 # $passwd ne $passwd_s or
75 # Drop the multiply defined users.
77 foreach (sort keys %seen) {
78 my $times = @{ $seen{$_} };
80 # Multiply defined users are rarely intentional.
82 print "# User '$_' defined multiple times in $where, lines: @{$seen{$_}}.\n";
87 print "not " if keys %suspect;
88 print "ok ", $tst++, "\n";