2 # Make sure GNU chmod works the same way as those of Solaris, HPUX, AIX
3 # wrt directories with the setgid bit set.
5 if test "$VERBOSE" = yes; then
10 .
$srcdir/..
/envvar-check
11 .
$srcdir/..
/lang-default
15 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
16 trap '(exit $?); exit' 1 2 13 15
20 # Record absolute path of srcdir and cd back to current dir.
21 cd $srcdir || framework_failure
=1
23 cd $pwd || framework_failure
=1
25 mkdir
$tmp || framework_failure
=1
26 cd $tmp || framework_failure
=1
28 .
$abs_srcdir/..
/setgid-check
31 mkdir d || framework_failure
=1
33 chmod g
+s d
2> /dev
/null ||
35 # This is required because on some systems (at least NetBSD 1.4.2A),
36 # it may happen that when you create a directory, its group isn't one
37 # to which you belong. When that happens, the above chmod fails. So
38 # here, upon failure, we try to set the group, then rerun the chmod command.
39 group
=${FETISH_GROUP-`(id -ng || /usr/xpg4/bin/id -ng) 2>/dev/null`}
40 if test "$group"; then
41 chgrp
"$group" d || framework_failure
=1
42 chmod g
+s d || framework_failure
=1
48 if test $framework_failure = 1; then
49 echo 'failure in testing framework' 1>&2
57 # To be compatible with chmod from other vendors,
58 # GNU chmod must not reset a directory's setgid bit.
59 # The latest POSIX draft (d5) allows either behavior. It says:
61 # For regular files, for each bit set in the octal number
62 # corresponding to the set-user-ID-on-execution or the
63 # set-group-ID-on-execution, bits shown in the following table shall
64 # be set; if these bits are not set in the octal number, they are
65 # cleared. For other file types, it is implementation-defined whether
66 # or not requests to set or clear the set-user-ID-on-execution or
67 # set-group-ID-on-execution bits are honored.
69 # FIXME: consider changing GNU chmod to work like other versions of chmod.
70 # For now, this test simply confirms the existing behavior.
71 p
=`ls -ld d|sed 's/ .*//'`; case $p in drwxr-xr-x
);; *) fail
=1;; esac