3 $ENV{PATH} = '/usr/xpg4/bin:/bin:/usr/bin:/usr/ucb';
5 # We have to find a command that prints all (effective
6 # and real) group names (not ids). The known commands are:
10 # Beware 1: some systems do just 'id -G' even when 'id -Gn' is used.
11 # Beware 2: the 'id -a' output format is tricky.
14 last GROUPS if ($groups = `groups 2>/dev/null`) ne '';
15 if ($groups = `id -Gn 2>/dev/null` ne '') {
16 last GROUPS unless $groups =~ /^(\d+)(\s+\d)*$/;
18 if ($groups = `id -a 2>/dev/null` ne '') {
19 if (/groups=/g && (@g = /\((.+?)\)/g)) {
20 $groups = join(" ", @g);
32 ($pwgnam) = getgrgid($pwgid);
33 @basegroup{$pwgid,$pwgnam} = (1,1);
37 for (split(' ', $()) {
39 ($group) = getgrgid($_);
48 if ($^O eq "uwin") { # Or anybody else who can have spaces in group names.
49 $gr1 = join(' ', grep(!$did{$_}++, sort split(' ', join(' ', @gr))));
51 $gr1 = join(' ', sort @gr);
54 $gr2 = join(' ', grep(!$basegroup{$_}++, sort split(' ',$groups)));
60 print "#gr1 is <$gr1>\n";
61 print "#gr2 is <$gr2>\n";
65 # multiple 0's indicate GROUPSTYPE is currently long but should be short
67 if ($pwgid == 0 || $seen{0} < 2) {
71 print "not ok 2 (groupstype should be type short, not long)\n";