Commit | Line | Data |
c5987ebb |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = "../lib" if -d "../lib"; |
6 | eval { require Config; import Config; }; |
7 | |
8 | my $PW = "/etc/passwd"; |
9 | |
10899c3d |
10 | if ($Config{'i_pwd'} ne 'define' or not -f $PW or not open(PW, $PW) |
11 | # NeXTstep /etc/passwd is used only at boot time, |
12 | # after that it's up to NetInfo and NIS/YP. |
13 | or $^O eq 'next' |
14 | ) { |
c5987ebb |
15 | print "1..0\n"; |
16 | exit 0; |
17 | } |
18 | } |
19 | |
20 | print "1..1\n"; |
21 | |
22 | # Go through at most this many users. |
23 | my $max = 25; # |
24 | |
25 | my $n = 0; |
26 | my $not; |
27 | my $tst = 1; |
28 | |
29 | $not = 0; |
30 | while (<PW>) { |
31 | last if $n == $max; |
32 | chomp; |
33 | @s = split /:/; |
34 | if (@s == 7) { |
35 | my ($name_s, $passwd_s, $uid_s, $gid_s, $gcos_s, $home_s, $shell_s) = @s; |
36 | @n = getpwuid($uid_s); |
37 | # 'nobody' et al. |
38 | next unless @n; |
39 | my ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n; |
40 | # Protect against one-to-many and many-to-one mappings. |
41 | if ($name_s ne $name) { |
42 | @n = getpwnam($name_s); |
43 | ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n; |
44 | next if $name_s ne $name; |
45 | } |
46 | $not = 1, last |
47 | if $name ne $name_s or |
48 | # Shadow passwords confuse this. |
49 | # Think about non-crypt(3) encryptions, too, before you do anything rash. |
50 | # $passwd ne $passwd_s or |
51 | $uid ne $uid_s or |
52 | $gid ne $gid_s or |
53 | $gcos ne $gcos_s or |
54 | $home ne $home_s or |
55 | $shell ne $shell_s; |
56 | } |
57 | $n++; |
58 | } |
59 | |
60 | print "not " if $not; |
61 | print "ok ", $tst++, "\n"; |
62 | |
63 | close(PW); |