5 unshift @INC, "../lib" if -d "../lib";
6 eval { require Config; import Config; };
8 if ($Config{'i_grp'} ne 'define') {
9 $reason = '$Config{i_grp} not defined';
11 elsif (not -f "/etc/group" ) { # Play safe.
12 $reason = 'no /etc/group file';
15 if (not defined $where) { # Try NIS.
16 foreach my $ypcat (qw(/usr/bin/ypcat /bin/ypcat /etc/ypcat)) {
18 open(GR, "$ypcat group 2>/dev/null |") &&
27 if (not defined $where) { # Try NetInfo.
28 foreach my $nidump (qw(/usr/bin/nidump)) {
30 open(GR, "$nidump group . 2>/dev/null |") &&
32 $where = "NetInfo group";
39 if (not defined $where) { # Try local.
40 my $GR = "/etc/group";
41 if (-f $GR && open(GR, $GR) && defined(<GR>)) {
47 print "1..0 # Skip: $reason\n";
52 # By now GR filehandle should be open and full of juicy group entries.
56 # Go through at most this many groups.
57 # (note that the first entry has been read away by now)
68 my ($name_s,$passwd_s,$gid_s,$members_s) = @s;
70 push @{ $seen{$name_s} }, $.;
72 warn "# Your $where line $. is empty.\n";
76 # In principle we could whine if @s != 4 but do we know enough
77 # of group file formats everywhere?
79 $members_s =~ s/\s*,\s*/,/g;
80 $members_s =~ s/\s+$//;
81 $members_s =~ s/^\s+//;
82 @n = getgrgid($gid_s);
85 my ($name,$passwd,$gid,$members) = @n;
86 # Protect against one-to-many and many-to-one mappings.
87 if ($name_s ne $name) {
88 @n = getgrnam($name_s);
89 ($name,$passwd,$gid,$members) = @n;
90 next if $name_s ne $name;
92 # NOTE: group names *CAN* contain whitespace.
93 $members =~ s/\s+/,/g;
94 # what about different orders of members?
96 if $name eq $name_s and
97 # Do not compare passwords: think shadow passwords.
98 # Not that group passwords are used much but better not assume anything.
100 $members eq $members_s;
105 if (keys %perfect == 0) {
109 # The failure of op/grent test is not necessarily serious.
110 # It may fail due to local group administration conventions.
111 # If you are for example using both NIS and local groups,
112 # test failure is possible. Any distributed group scheme
113 # can cause such failures.
115 # What the grent test is doing is that it compares the $max first
117 # with the results of getgrgid() and getgrnam() call. If it finds no
118 # matches at all, it suspects something is wrong.
127 print "\t# (not necessarily serious: run t/op/grent.t by itself)" if $not;