diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 1998-08-03 01:05:28 +0300 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-08-08 22:26:09 +0000 |
commit | c5987ebb451d843cbf0a792310f25ebaec3f7378 (patch) | |
tree | 3ac52dd4e8a1842a96e9866d534a134a18982f78 /t/op/pwent.t | |
parent | 8e680dc37b34060770f3573bebbd4e34de1c230e (diff) | |
download | perl-c5987ebb451d843cbf0a792310f25ebaec3f7378.tar.gz |
5.005_02-TRIAL1 or 5.004_05-MAINT_TRIAL_5: t/op/{pw,gr}ent.t
Message-Id: <199808021905.WAA10592@alpha.hut.fi>
p4raw-id: //depot/perl@1762
Diffstat (limited to 't/op/pwent.t')
-rwxr-xr-x | t/op/pwent.t | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/t/op/pwent.t b/t/op/pwent.t new file mode 100755 index 0000000000..8fd9ce0dd8 --- /dev/null +++ b/t/op/pwent.t @@ -0,0 +1,59 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = "../lib" if -d "../lib"; + eval { require Config; import Config; }; + + my $PW = "/etc/passwd"; + + if ($Config{'i_pwd'} ne 'define' or not -f $PW or not open(PW, $PW)) { + print "1..0\n"; + exit 0; + } +} + +print "1..1\n"; + +# Go through at most this many users. +my $max = 25; # + +my $n = 0; +my $not; +my $tst = 1; + +$not = 0; +while (<PW>) { + last if $n == $max; + chomp; + @s = split /:/; + if (@s == 7) { + my ($name_s, $passwd_s, $uid_s, $gid_s, $gcos_s, $home_s, $shell_s) = @s; + @n = getpwuid($uid_s); + # 'nobody' et al. + next unless @n; + my ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n; + # Protect against one-to-many and many-to-one mappings. + if ($name_s ne $name) { + @n = getpwnam($name_s); + ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n; + next if $name_s ne $name; + } + $not = 1, last + if $name ne $name_s or +# Shadow passwords confuse this. +# Think about non-crypt(3) encryptions, too, before you do anything rash. +# $passwd ne $passwd_s or + $uid ne $uid_s or + $gid ne $gid_s or + $gcos ne $gcos_s or + $home ne $home_s or + $shell ne $shell_s; + } + $n++; +} + +print "not " if $not; +print "ok ", $tst++, "\n"; + +close(PW); |