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 | |
10 | if ($Config{'i_pwd'} ne 'define' or not -f $PW or not open(PW, $PW)) { |
11 | print "1..0\n"; |
12 | exit 0; |
13 | } |
14 | } |
15 | |
16 | print "1..1\n"; |
17 | |
18 | # Go through at most this many users. |
19 | my $max = 25; # |
20 | |
21 | my $n = 0; |
22 | my $not; |
23 | my $tst = 1; |
24 | |
25 | $not = 0; |
26 | while (<PW>) { |
27 | last if $n == $max; |
28 | chomp; |
29 | @s = split /:/; |
30 | if (@s == 7) { |
31 | my ($name_s, $passwd_s, $uid_s, $gid_s, $gcos_s, $home_s, $shell_s) = @s; |
32 | @n = getpwuid($uid_s); |
33 | # 'nobody' et al. |
34 | next unless @n; |
35 | my ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n; |
36 | # Protect against one-to-many and many-to-one mappings. |
37 | if ($name_s ne $name) { |
38 | @n = getpwnam($name_s); |
39 | ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n; |
40 | next if $name_s ne $name; |
41 | } |
42 | $not = 1, last |
43 | if $name ne $name_s or |
44 | # Shadow passwords confuse this. |
45 | # Think about non-crypt(3) encryptions, too, before you do anything rash. |
46 | # $passwd ne $passwd_s or |
47 | $uid ne $uid_s or |
48 | $gid ne $gid_s or |
49 | $gcos ne $gcos_s or |
50 | $home ne $home_s or |
51 | $shell ne $shell_s; |
52 | } |
53 | $n++; |
54 | } |
55 | |
56 | print "not " if $not; |
57 | print "ok ", $tst++, "\n"; |
58 | |
59 | close(PW); |