From patchwork Wed May 31 15:00:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 70391 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 588B83858428 for ; Wed, 31 May 2023 15:00:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 588B83858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685545237; bh=Qkm9nqUxi8k0TNLEaWw1sdg7u4xBjEBlwyv/dazx/gk=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=hCWgFgs9Oy42wCVKg2OEQSGvSKElS6w+uTuF+fF1muQ8ZJXp8BOEFLdVMBP7i2xKm 9uquTZ95QblxxshsXp7BJWzz8HqpYUuEXXnoOtDpCAc6inhTvnJpMVUBEZ1yMATzbF O/dddHrcAJMaaX/N8JswMBWE/tGkCXQ+vJ8nWJg4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bumble.birch.relay.mailchannels.net (bumble.birch.relay.mailchannels.net [23.83.209.25]) by sourceware.org (Postfix) with ESMTPS id 7E4F73858D20 for ; Wed, 31 May 2023 15:00:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E4F73858D20 X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 45F578C2218; Wed, 31 May 2023 15:00:13 +0000 (UTC) Received: from pdx1-sub0-mail-a277.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id B478C8C22C1; Wed, 31 May 2023 15:00:11 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1685545211; a=rsa-sha256; cv=none; b=bhyXPHF6uSxxl12AAv9WaIzdYDIKgroIiYtydWaCvklGvEB6ZcavhtvGhHT1EwuRl2VyAR cWNJirboSEqoO73Sd3fgYGgJTM1BrfbxW/baK4yaVhYL86VZ2S48ViNgbMlqiDqv8b59dv CGzrfAoZ4ju2mcTWpyNAF+zf4DpG8GP6F6bU+oE+CWxyjRGADChZlMpVLdCEOvvgV5KkiW bNbqUFWpK2Ul+I8n7vFIH1MBmKg9Rg687jMqQAA3mFgGjjmAGXewJ1pK/h2fU7jKOFa9F+ BXN30uzMgCjqMs3SI0r50lrxDfBbPYfyYS0Y5+VFkRU5fNVCXs4LeQ/ySpYRpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1685545211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qkm9nqUxi8k0TNLEaWw1sdg7u4xBjEBlwyv/dazx/gk=; b=PpS2l5Jt3fJMZ9CcUUnR5dSH27jzAKuK0Fj5hElHEprF39uz9b/xGp436U3/7WyT5hLjhl OOzY/K9nhuV1Mwy+q5cK4TWBhWPzM5Aop44Mc+cjzoiT0c7Lv2NHjUAFV8F9QcrSTV6+lj RVqNw+NdPiE0/YklvAiBukmF4Q/2Z1W7AEaws/4SvYYevl7SKAeZXsikZFJD+c6Qj4PWRu PuByaSzbhBGzWxH52G9MRt5X104aINLk5xZIo9jhUp/IGhTjRn5Ic+zTW4xK+uCc2+c0wF EMtqdq99K68DCeLMwv3ecNz/3Q9/aKBQ1n6GwHltSFJQYN30KFNDXWDSStp4Mw== ARC-Authentication-Results: i=1; rspamd-d7bbc7d84-pj946; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MC-Copy: stored-urls X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Tank-Relation: 6044adc8752196a1_1685545213119_666148609 X-MC-Loop-Signature: 1685545213119:3362411062 X-MC-Ingress-Time: 1685545213118 Received: from pdx1-sub0-mail-a277.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.123.193.162 (trex/6.8.1); Wed, 31 May 2023 15:00:13 +0000 Received: from fedora.redhat.com (bras-vprn-toroon4834w-lp130-02-142-113-138-85.dsl.bell.ca [142.113.138.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a277.dreamhost.com (Postfix) with ESMTPSA id 4QWXVy6yvdzF3; Wed, 31 May 2023 08:00:10 -0700 (PDT) To: libc-alpha@sourceware.org Cc: carlos@redhat.com, Frederic Berat Subject: [PATCH v2] support: Don't fail on fchown when spawning sgid processes Date: Wed, 31 May 2023 11:00:03 -0400 Message-Id: <20230531150003.3803030-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230531131643.3776181-1-siddhesh@sourceware.org> References: <20230531131643.3776181-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1173.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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 Signed-off-by: Siddhesh Poyarekar Tested-by: Frédéric Bérat --- 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..3881e3610a 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); + + 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; + 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; }