From patchwork Wed May 31 16:07:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1788446 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=L5+JVdmU; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QWZ1L2tpWz20QB for ; Thu, 1 Jun 2023 02:08:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A02A33857B98 for ; Wed, 31 May 2023 16:08:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A02A33857B98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685549283; bh=Nsqj1pk3Rjdi3fMUMdLnQfVHba963leSQ8w346UidvM=; 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=L5+JVdmU4J448h5kTjiKZPYDhXVQXqxTr2OaHXat2mnMEy1VFqn3r+bXOeIFffIMS Gfn6uLwmgwY+6w7uiK6Bu2TaGrH+Kbk3FJAeDLb70VDjDWm5h/6fxz8QCchs5Ue004 /rk0VPrp8luEgKnCdUXpxyBQr5uvwhXnJGyqw4BU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hedgehog.birch.relay.mailchannels.net (hedgehog.birch.relay.mailchannels.net [23.83.209.81]) by sourceware.org (Postfix) with ESMTPS id D1CB33858D20 for ; Wed, 31 May 2023 16:07:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1CB33858D20 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 8C1895C265D; Wed, 31 May 2023 16:07:37 +0000 (UTC) Received: from pdx1-sub0-mail-a233.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 14B7B5C13CA; Wed, 31 May 2023 16:07:37 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1685549257; a=rsa-sha256; cv=none; b=Bv+P5q9q8gVEMZyZM/U52ENv5L8HPrbUFW9oERm05ZNOnJ4tx5jJ/ORnk7E8AUi3303KNY 6sOGpjRwhaIkrRYSY1rIlEgRQZEHyzahycisALbUrCH2uXkxxvS8EZtTTEWddm4jxXjRx6 aVHjZgWbq+8hY1DBjVsvyCX6XkNXpKdx4J56ng5arMv64rifdCUeQsCLXD/ALjaKDPLyXR eHuu0KFTPBm5ODC+fH1r2AxmF1VR6dbJf3g8yW3c5FlIVLylxKg4MoFUyx5br68KHT4L+y F8jebWD2CMCzTGtWX4SPJMbl2MUt8/6L1WJC+KHYbq19kpheVvFewPisRRpu0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1685549257; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nsqj1pk3Rjdi3fMUMdLnQfVHba963leSQ8w346UidvM=; b=W8Gk6Ue39kzsmQFPNyUrTtsYXE3O8hafrpxXg4rP8LYtltDadF/Ro0VmWZQQno7730PubP FxfuV+WNk0rXqCFAAealNv6YktiFGIb5BfPgezNYyQ6lETakt/+K7lZ0ZNE3ZSP5IjTlX7 ZDUDZGSYrx0nSUoIbKNWV0AVjtwBT/ieLgw8vTfD5V5rkL0kxypNIw/zadJOToABxDk+6u XeXPzAFgAVhtOWgig29VwCrrIBUx47UhbKLGAY+SFNaDwZknFZFZJpR7YAeqPfGKEIYOHP 3XyUQ78+8q0iT5ixwMrZ4QaN42obJwMAs73u9VqpB0NcvHBiZtCpye2o8xbl+w== ARC-Authentication-Results: i=1; rspamd-686ff4cc9d-t575g; 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-Battle-Thread: 3d1e288f7a834045_1685549257355_4214683087 X-MC-Loop-Signature: 1685549257355:2079516983 X-MC-Ingress-Time: 1685549257354 Received: from pdx1-sub0-mail-a233.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.103.24.81 (trex/6.8.1); Wed, 31 May 2023 16:07:37 +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-a233.dreamhost.com (Postfix) with ESMTPSA id 4QWZ0m3TNWz2P; Wed, 31 May 2023 09:07:36 -0700 (PDT) To: libc-alpha@sourceware.org Cc: schwab@suse.de, carlos@redhat.com, =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Subject: [PATCH v3] support: Don't fail on fchown when spawning sgid processes Date: Wed, 31 May 2023 12:07:27 -0400 Message-Id: <20230531160727.1805753-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_H4, 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+incoming=patchwork.ozlabs.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: Frédéric Bérat Tested-by: Frédéric Bérat Signed-off-by: Siddhesh Poyarekar Reviewed-by: Carlos O'Donell --- 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; }