5 unshift @INC, "../lib" if -d "../lib";
6 eval { require Config; import Config; };
8 unless (defined $Config{'i_grp'} &&
9 $Config{'i_grp'} eq 'define' &&
10 -f "/etc/group" ) { # Play safe.
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 |") &&
26 if (not defined $where) { # Try NetInfo.
27 foreach my $nidump (qw(/usr/bin/nidump)) {
29 open(GR, "$nidump group . 2>/dev/null |") &&
31 $where = "NetInfo group";
37 if (not defined $where) { # Try local.
38 my $GR = "/etc/group";
39 if (-f $GR && open(GR, $GR) && defined(<GR>)) {
44 if (not defined $where) { # Give up.
50 # By now GR filehandle should be open and full of juicy group entries.
54 # Go through at most this many groups.
55 # (note that the first entry has been read away by now)
66 my ($name_s,$passwd_s,$gid_s,$members_s) = @s;
68 push @{ $seen{$name_s} }, $.;
70 warn "# Your $where line $. is empty.\n";
74 # In principle we could whine if @s != 4 but do we know enough
75 # of group file formats everywhere?
77 $members_s =~ s/\s*,\s*/,/g;
78 $members_s =~ s/\s+$//;
79 $members_s =~ s/^\s+//;
80 @n = getgrgid($gid_s);
83 my ($name,$passwd,$gid,$members) = @n;
84 # Protect against one-to-many and many-to-one mappings.
85 if ($name_s ne $name) {
86 @n = getgrnam($name_s);
87 ($name,$passwd,$gid,$members) = @n;
88 next if $name_s ne $name;
90 # NOTE: group names *CAN* contain whitespace.
91 $members =~ s/\s+/,/g;
92 # what about different orders of members?
94 if $name eq $name_s and
95 # Do not compare passwords: think shadow passwords.
96 # Not that group passwords are used much but better not assume anything.
98 $members eq $members_s;
103 if (keys %perfect == 0) {
107 # The failure of op/grent test is not necessarily serious.
108 # It may fail due to local group administration conventions.
109 # If you are for example using both NIS and local groups,
110 # test failure is possible. Any distributed group scheme
111 # can cause such failures.
113 # What the grent test is doing is that it compares the $max first
115 # with the results of getgrgid() and getgrnam() call. If it finds no
116 # matches at all, it suspects something is wrong.
125 print "\t# (not necessarily serious: run t/op/grent.t by itself)" if $not;