From 95f4ee0577dd836de523f46999777fbbbe9d2772 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 18 Feb 2023 13:29:41 -0800 Subject: [PATCH] tests: port chmod/setgid.sh to macOS 12 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * tests/chmod/setgid.sh: Try all the groups you’re a member of, in case id -g returns 4294967295 (nogroup) which is special and does not let you chgrp a file to it. --- tests/chmod/setgid.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/chmod/setgid.sh b/tests/chmod/setgid.sh index 9f277f0bec..d7a4b3e7e3 100755 --- a/tests/chmod/setgid.sh +++ b/tests/chmod/setgid.sh @@ -24,6 +24,7 @@ print_ver_ chmod umask 0 mkdir -m 755 d || framework_failure_ +# "chmod g+s d" does nothing on some NFS file systems. chmod g+s d 2> /dev/null && env -- test -g d || { # This is required because on some systems (at least NetBSD 1.4.2A), @@ -31,14 +32,12 @@ chmod g+s d 2> /dev/null && env -- test -g d || # to which you belong. When that happens, the above chmod fails. So # here, upon failure, we try to set the group, then rerun the chmod command. - id_g=$(id -g) && - test -n "$id_g" && - chgrp "$id_g" d && - chmod g+s d || framework_failure_ - } - -# "chmod g+s d" does nothing on some NFS file systems. -env -- test -g d || + for id_g in $(id -g) $(id -G) ''; do + test -n "$id_g" || break + chgrp "$id_g" d && chmod g+s d && env -- test -g d && break + done + test -n "$id_g" + } || skip_ 'cannot create setgid directories' for mode in \ -- 2.47.2