]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
support: Don't fail on fchown when spawning sgid processes
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 1 Jun 2023 11:23:15 +0000 (07:23 -0400)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 20 Jun 2025 09:48:27 +0000 (11:48 +0200)
In some cases (e.g. when podman creates user containers), the only other
group assigned to the executing user is nobody and fchown fails with it
because the group is not mapped.  Do not fail the test in this case,
instead exit as unsupported.

Reported-by: Frédéric Bérat <fberat@redhat.com>
Tested-by: Frédéric Bérat <fberat@redhat.com>
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 6286cca2cb8389dcffec39238a8bf15ffea96396)

support/support_capture_subprocess.c

index 1b4aa66ede5e98a14ef5c69f4d2c85bb5f33d7b6..d63fe8a027e5be6f4c92829e279000b9f4981f4e 100644 (file)
@@ -153,9 +153,18 @@ copy_and_spawn_sgid (const char *child_id, gid_t gid)
          p += wrcount;
        }
     }
-  TEST_VERIFY (fchown (outfd, getuid (), gid) == 0);
+
+  bool chowned = false;
+  TEST_VERIFY ((chowned = fchown (outfd, getuid (), gid) == 0)
+              || errno == EPERM);
   if (support_record_failure_is_failed ())
     goto err;
+  else if (!chowned)
+    {
+      ret = 77;
+      goto err;
+    }
+
   TEST_VERIFY (fchmod (outfd, 02750) == 0);
   if (support_record_failure_is_failed ())
     goto err;
@@ -192,8 +201,10 @@ err:
       free (dirname);
     }
 
+  if (ret == 77)
+    FAIL_UNSUPPORTED ("Failed to make sgid executable for test\n");
   if (ret != 0)
-    FAIL_EXIT1("Failed to make sgid executable for test\n");
+    FAIL_EXIT1 ("Failed to make sgid executable for test\n");
 
   return status;
 }