#!./perl
BEGIN {
chdir 't';
require Config;
if ($@) {
print "1..0 # Skip: no Config\n";
} else {
}
}
exit 0;
}
print "1..0 # Skip: getgrgid() not implemented\n";
exit 0;
}
# We have to find a command that prints all (effective
# and real) group names (not ids). The known commands are:
# groups
# id -Gn
# id -a
# Beware 1: some systems do just 'id -G' even when 'id -Gn' is used.
# Beware 2: id -Gn or id -a format might be id(name) or name(id).
# Beware 3: the groups= might be anywhere in the id output.
# Beware 4: groups can have spaces ('id -a' being the only defense against this)
# Beware 5: id -a might not contain the groups= part.
#
# That is, we might meet the following:
#
# foo bar zot # accept
# foo 22 42 bar zot # accept
# 1 22 42 2 3 # reject
# groups=(42),foo(1),bar(2),zot me(3) # parse
# groups=22,42,1(foo),2(bar),3(zot me) # parse
#
# and the groups= might be after, before, or between uid=... and gid=...
GROUPS: {
# prefer 'id' over 'groups' (is this ever wrong anywhere?)
# and 'id -a' over 'id -Gn' (the former is good about spaces in group names)
# $groups is of the form:
# uid=39957(gsar) gid=22(users) groups=33536,39181,22(users),0(root),1067(dev)
}
# $groups could be of the form:
# users 33536 39181 root dev
}
# may not reflect all groups in some places, so do a sanity check
if (-d '/afs') {
print <<EOM;
# These test results *may* be bogus, as you appear to have AFS,
# and I can't find a working 'id' in your PATH (which I have set
# to '$ENV{PATH}').
#
# If these tests fail, report the particular incantation you use
# on this platform to find *all* the groups that an arbitrary
# user may belong to, using the 'perlbug' program.
EOM
}
}
# Okay, not today.
}
# Remember that group names can contain whitespace, '-', et cetera.
# That is: do not \w, do not \S.
my $gr = $1;
my @g1;
# prefer names over numbers
# 42(zot me)
if (/^(\d+)(?:\(([^)]+)\))?/) {
}
# zot me(42)
elsif (/^([^(]*)\((\d+)\)/) {
}
else {
print "# ignoring group entry [$_]\n";
}
}
print "# g0 = @g0\n";
print "# g1 = @g1\n";
}
print "1..2\n";
$pwgid = $( + 0;
}
else {
}
}
print "# gr = @gr\n";
# Or anybody else who can have spaces in group names.
} else {
}
} else {
}
my $ok1 = 0;
print "ok 1\n";
$ok1++;
}
# Retry in default unix mode
print "ok 1 # This Cygwin behaves like Unix (Win2k?)\n";
$ok1++;
}
}
print "not ok 1\n";
}
# multiple 0's indicate GROUPSTYPE is currently long but should be short
print "ok 2\n";
}
else {
print "not ok 2 (groupstype should be type short, not long)\n";
}