BEGIN {
chdir 't' if -d 't';
unshift @INC, "../lib" if -d "../lib";
- eval { require Config; import Config; };
-
- unless (defined $Config{'i_pwd'} &&
- $Config{'i_pwd'} eq 'define' &&
- -f "/etc/passwd" ) { # Play safe.
- print "1..0\n";
+ eval {my @n = getpwuid 0};
+ if ($@ && $@ =~ /(The \w+ function is unimplemented)/) {
+ print "1..0 # Skip: $1\n";
exit 0;
}
+ eval { require Config; import Config; };
+ my $reason;
+ if ($Config{'i_pwd'} ne 'define') {
+ $reason = '$Config{i_pwd} undefined';
+ }
+ elsif (not -f "/etc/passwd" ) { # Play safe.
+ $reason = 'no /etc/passwd file';
+ }
if (not defined $where) { # Try NIS.
foreach my $ypcat (qw(/usr/bin/ypcat /bin/ypcat /etc/ypcat)) {
open(PW, "$ypcat passwd 2>/dev/null |") &&
defined(<PW>)) {
$where = "NIS passwd";
+ undef $reason;
last;
}
}
open(PW, "$nidump passwd . 2>/dev/null |") &&
defined(<PW>)) {
$where = "NetInfo passwd";
+ undef $reason;
last;
}
}
my $PW = "/etc/passwd";
if (-f $PW && open(PW, $PW) && defined(<PW>)) {
$where = $PW;
+ undef $reason;
}
}
- if (not defined $where) { # Give up.
- print "1..0\n";
+ if ($reason) { # Give up.
+ print "1..0 # Skip: $reason\n";
exit 0;
}
}
warn "# Your $where line $. is empty.\n";
next;
}
- last if $n == $max;
+ if ($n == $max) {
+ local $/;
+ my $junk = <PW>;
+ last;
+ }
# In principle we could whine if @s != 7 but do we know enough
# of passwd file formats everywhere?
if (@s == 7) {