]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: avoid false failures in user namespaces
authorPádraig Brady <P@draigBrady.com>
Sat, 3 May 2025 08:59:16 +0000 (09:59 +0100)
committerPádraig Brady <P@draigBrady.com>
Sat, 3 May 2025 08:59:16 +0000 (09:59 +0100)
* init.cfg (require_membership_in_two_groups_): Skip
overflow gids used in user namespaces, as one can't
chgrp() to these.
Fixes https://bugs.gnu.org/78225

init.cfg

index 7e21f96c6a7cdc08a4d8e019cac7a5729610415c..9824189005c1d75260994ed592a97650665d12aa 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -504,6 +504,10 @@ require_membership_in_two_groups_()
 {
   test $# = 0 || framework_failure_
 
+  # Skip overflow gids used in user namespaces
+  overflow_gid=$(cat /proc/sys/kernel/overflowgid 2>/dev/null)
+  : "${overflow_gid:=1}"
+
   groups=
   for group_ in 1 \
     ${COREUTILS_GROUPS-$( (id -G || /usr/xpg4/bin/id -G) 2>/dev/null)}
@@ -511,7 +515,7 @@ require_membership_in_two_groups_()
     # Skip group numbers equal to 2**N - 1 for common N,
     # as they are possibly reserved groups like 'nogroup'.
     case $group_ in
-      1 | 32767 | 65535 | 2147483647 | 4294967295) ;;
+      $overflow_gid | 1 | 32767 | 65535 | 2147483647 | 4294967295) ;;
       9223372036854775807 | 18446744073709551615) ;;
       *) test -z "$groups" || groups="$groups "
          groups="$groups$group_";;