public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] support: Don't fail on fchown when spawning sgid processes
@ 2023-05-31 13:16 Siddhesh Poyarekar
  2023-05-31 14:32 ` Frederic Berat
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Siddhesh Poyarekar @ 2023-05-31 13:16 UTC (permalink / raw)
  To: libc-alpha; +Cc: carlos, Frederic Berat

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: Frederic Berat <fberat@redhat.com>
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
---
 support/support_capture_subprocess.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
index bae7d5fb20..ad1da9fd97 100644
--- a/support/support_capture_subprocess.c
+++ b/support/support_capture_subprocess.c
@@ -153,9 +153,15 @@ copy_and_spawn_sgid (char *child_id, gid_t gid)
 	  p += wrcount;
 	}
     }
-  TEST_VERIFY (fchown (outfd, getuid (), gid) == 0);
+
+  int chowned = 0;
+  TEST_VERIFY ((chowned = fchown (outfd, getuid (), gid)) == 0
+	       || errno == EPERM);
   if (support_record_failure_is_failed ())
     goto err;
+  else if (chowned != 0)
+    ret = 77;
+
   TEST_VERIFY (fchmod (outfd, 02750) == 0);
   if (support_record_failure_is_failed ())
     goto err;
@@ -192,8 +198,10 @@ err:
       free (dirname);
     }
 
-  if (ret != 0)
-    FAIL_EXIT1("Failed to make sgid executable for test\n");
+  if (ret == 77)
+    FAIL_UNSUPPORTED ("Failed to make sgid executable for test\n");
+  else if (ret != 0)
+    FAIL_EXIT1 ("Failed to make sgid executable for test\n");
 
   return status;
 }
-- 
2.40.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-06-01 11:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31 13:16 [PATCH] support: Don't fail on fchown when spawning sgid processes Siddhesh Poyarekar
2023-05-31 14:32 ` Frederic Berat
2023-05-31 14:55   ` Siddhesh Poyarekar
2023-05-31 15:00 ` [PATCH v2] " Siddhesh Poyarekar
2023-05-31 15:13   ` Andreas Schwab
2023-05-31 16:07     ` Siddhesh Poyarekar
2023-05-31 15:56   ` Frederic Berat
2023-05-31 16:07 ` [PATCH v3] " Siddhesh Poyarekar
2023-06-01 11:01   ` Carlos O'Donell
2023-06-01 11:22     ` Carlos O'Donell
2023-06-01 11:33       ` Carlos O'Donell
2023-06-01 11:36         ` Siddhesh Poyarekar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).