From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2206) id C97933858C41; Thu, 1 Jun 2023 11:25:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C97933858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685618708; bh=Qj5T93WNs1GO+qKxC7Jp+nGG1LuJyhiQaBb4csoD0cQ=; h=From:To:Subject:Date:From; b=yA1Hd6oMwQdoYoy4vk3lzIQPFATK+VLCiE+fa+S52U+freAwJILVWzbmVpfTjGDVC pH7Mnq0MsdX25+ka3pjpO+5pgOmvrjh1jpDR3U7SkFrr1GDAPW+YfJCaIUocTayor0 B0VZVQLUtRwiumHP9RHtLFlQ3v+muVAKL4d/UcBI= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Siddhesh Poyarekar To: glibc-cvs@sourceware.org Subject: [glibc] support: Don't fail on fchown when spawning sgid processes X-Act-Checkin: glibc X-Git-Author: Siddhesh Poyarekar X-Git-Refname: refs/heads/master X-Git-Oldrev: 5f828ff824e3b7cd133ef905b8ae25ab8a8f3d66 X-Git-Newrev: 6286cca2cb8389dcffec39238a8bf15ffea96396 Message-Id: <20230601112508.C97933858C41@sourceware.org> Date: Thu, 1 Jun 2023 11:25:08 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6286cca2cb8389dcffec39238a8bf15ffea96396 commit 6286cca2cb8389dcffec39238a8bf15ffea96396 Author: Siddhesh Poyarekar Date: Thu Jun 1 07:23:15 2023 -0400 support: Don't fail on fchown when spawning sgid processes 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 Tested-by: Frédéric Bérat Signed-off-by: Siddhesh Poyarekar Reviewed-by: Carlos O'Donell Diff: --- support/support_capture_subprocess.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c index bae7d5fb20..2a8d37b284 100644 --- a/support/support_capture_subprocess.c +++ b/support/support_capture_subprocess.c @@ -153,9 +153,18 @@ copy_and_spawn_sgid (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; }