]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: avoid false failures with non default groups
authorPádraig Brady <P@draigBrady.com>
Fri, 12 Apr 2013 21:57:45 +0000 (22:57 +0100)
committerPádraig Brady <P@draigBrady.com>
Sun, 14 Apr 2013 00:03:56 +0000 (01:03 +0100)
On OS X it was seen that the group ID used for new files,
are set to a that of the directory rather than the current user.
It's not currently understood when this happens, but it was confirmed
that ACLs, extended attributes and setgid bits are _not_ involved.

* init.cfg (skip_if_nondefault_group_): A new function to detect
and avoid this situation.  Document with links to the discussions
for hopefully future clarification.
* tests/install/install-C-root.sh: Use the new function.
* tests/install/install-C-selinux.sh: Likewise.
* tests/install/install-C.sh: Likewise.

init.cfg
tests/install/install-C-root.sh
tests/install/install-C-selinux.sh
tests/install/install-C.sh

index 093cd85863c3787f4bb4dcb74242fe60b5a79af2..7976b61666bb09006512f190e4dedb86debf46e9 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -502,6 +502,19 @@ skip_if_setgid_()
   esac
 }
 
+# Skip if files are created with a different group to the current user
+# This can happen due to a setgid dir, or by some other mechanism on OS X:
+# http://unix.stackexchange.com/q/63865
+# http://bugs.gnu.org/14024#41
+skip_if_nondefault_group_()
+{
+  touch grp.$$
+  gen_ug=$(stat -c '%u:%g' grp.$$)
+  rm grp.$$
+  test "$gen_ug" = "$(id -ru):$(id -rg)" ||
+    skip_ 'Files are created with a different gid'
+}
+
 skip_if_mcstransd_is_running_()
 {
   test $# = 0 || framework_failure_
index d8a8d846c65c0a5f67f901ebe50f229d4d7c4ecf..6e6d7eb9dad0e27e99dadf54ef723a5581eb474e 100755 (executable)
@@ -20,6 +20,7 @@
 print_ver_ ginstall
 require_root_
 skip_if_setgid_
+skip_if_nondefault_group_
 
 u1=1
 u2=2
index 8513d50b8f3d4e38ca5d742d965ccda068165c97..ce9e0c3600020ea7326418118f753c5d51b10ea0 100755 (executable)
@@ -19,7 +19,7 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ ginstall
 require_selinux_
-
+skip_if_nondefault_group_
 
 echo test > a || framework_failure_
 chcon -u system_u a || skip_ "chcon doesn't work"
index 7d3582c405e66798188a2623f48bdbbe0389667a..6051d57f8d2590f2c695003449cea15d5b8dde52 100755 (executable)
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ ginstall
 skip_if_setgid_
+skip_if_nondefault_group_
+
+# Note if a group is not specified, install(1) will assume that a file
+# would be installed with the current user's group ID, and thus if the
+# file is the same except that it does have a different group due to
+# its parent directory being g+s for example, then the copy will be
+# done again redundantly in a futile attempt to reset the group ID to
+# that of the current user.
+#
+#  install -d -g wheel -m 2775 test  # Create setgid dir
+#  touch test/a                      # Create source
+#  install -Cv -m664 test/a test/i1  # install source with mode
+#  install -Cv -m664 test/i1 test/i2 # install dest
+#  install -Cv -m664 test/i1 test/i2 # again to see redundant install
+#
+# Similarly if an existing file exists that is the same and has the
+# current users group ID, but when an actual install of the file would
+# reset to a different group ID due to the directory being g+s for example,
+# then the install will not be done when it should.
+#
+#  install -Cv -m664 -g "$(id -nrg)" test/i1 test/i2 # set i2 to uesr's gid
+#  install -Cv -m664 test/i1 test/i2 # this should install but doesn't
+#
+# Therefore we skip the test in the presence of setgid dirs
+# An additional complication on HFS is that it...
 
 mode1=0644
 mode2=0755