2 # Make sure GNU chmod works the same way as those of Solaris, HPUX, AIX
3 # on directories with the setgid bit set. Also, check that the GNU octal
6 # Copyright (C) 2001-2024 Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <https://www.gnu.org/licenses/>.
21 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
25 mkdir
-m 755 d || framework_failure_
27 # "chmod g+s d" does nothing on some NFS file systems.
28 chmod g
+s d
2> /dev
/null
&& env
-- test -g d ||
30 # This is required because on some systems (at least NetBSD 1.4.2A),
31 # it may happen that when you create a directory, its group isn't one
32 # to which you belong. When that happens, the above chmod fails. So
33 # here, upon failure, we try to set the group, then rerun the chmod command.
35 for id_g
in $
(id
-g) $
(id
-G) ''; do
36 test -n "$id_g" ||
break
37 chgrp
"$id_g" d
&& chmod g
+s d
&& env
-- test -g d
&& break
41 skip_
'cannot create setgid directories'
44 + - g-s
00755 000755 =755 -2000 -7022 755 0755 \
45 +2000 -5022 =7777,-5022
47 chmod $mode d || fail
=1
50 g-s |
00*755 |
=755 |
-2000 |
-7022)
51 expected_mode
=drwxr-xr-x
;;
52 *) expected_mode
=drwxr-sr-x
;;
60 chmod =2755 d || fail
=1