From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 4A970385801B for ; Thu, 14 Jul 2022 11:24:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4A970385801B Received: by mail-ot1-x330.google.com with SMTP id v19-20020a9d69d3000000b0061c78772699so933204oto.11 for ; Thu, 14 Jul 2022 04:24:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:organization:in-reply-to :content-transfer-encoding; bh=RQ6UC+ai+7Eky3PHZKtjjeMD4jSBEM+J/lMhDDPiNM4=; b=iqWoIMlskVeL3dUdENV40BLfj+LUC6dAAgLUvoVlRAHnuiqRmUJb54ursk2AUpVIy/ V+K9rfsNIuXVZU2PuX6pBtFDIRWsDXcBTepSkxQxMzrizd7OP8FSMXaOyGCd51EXq3e2 6V3rs4Oi2IfJ9QVGA/9KsDjaTKfZfddTMqi+G+MHjhFEMm2wp1A+xGsnLQit84xe+Rhq bRXgcey9s0JOJ5L/hbDsdPujeJ1sCUr/zMFdT1JZNhH/qyhEzI7QMH8evcudUktW15Tz /wyCyHk/mO9+iWavAW5M5iiZlqZYQkTpuViY8+8/KHg5Dwh+Bma7wKsXuLdGSDGF+HMm j8+w== X-Gm-Message-State: AJIora/PiyV7UIrnIspylAoSj/jvErYeiHtab9IUgWOxcnY4BKhVU5PK 8k3MtClFIPdsTfdhO7Ff+NKtYPYUyY7iVQ== X-Google-Smtp-Source: AGRyM1uTAe6YqTsOALynVrpQfbDguXyGeVByL2TTrs1K3R6tQ/3IRoepBV7ET/RuzyXnZuW7VaEwDQ== X-Received: by 2002:a9d:5906:0:b0:61b:1b87:3a0d with SMTP id t6-20020a9d5906000000b0061b1b873a0dmr3127463oth.70.1657797886364; Thu, 14 Jul 2022 04:24:46 -0700 (PDT) Received: from ?IPV6:2804:431:c7ca:19c3:4427:c171:4fa9:c3d9? ([2804:431:c7ca:19c3:4427:c171:4fa9:c3d9]) by smtp.gmail.com with ESMTPSA id l4-20020a4abe04000000b004356951ab45sm491072oop.6.2022.07.14.04.24.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Jul 2022 04:24:46 -0700 (PDT) Message-ID: Date: Thu, 14 Jul 2022 08:24:44 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.0.2 Subject: Re: [PATCH] linux: return UNSUPPORTED in tst-mount if support_become_root fails Content-Language: en-US To: Michael Hudson-Doyle , libc-alpha@sourceware.org References: <20220714032325.3899142-1-michael.hudson@canonical.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20220714032325.3899142-1-michael.hudson@canonical.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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-List-Received-Date: Thu, 14 Jul 2022 11:24:49 -0000 On 14/07/22 00:23, Michael Hudson-Doyle via Libc-alpha wrote: > Otherwise the test fails if run in a chroot by a non-root user: > > warning: could not become root outside namespace (Operation not permitted) > ../sysdeps/unix/sysv/linux/tst-mount.c:36: numeric comparison failure > left: 1 (0x1); from: errno > right: 19 (0x13); from: ENODEV > error: ../sysdeps/unix/sysv/linux/tst-mount.c:39: not true: fd != -1 > error: ../sysdeps/unix/sysv/linux/tst-mount.c:46: not true: r != -1 > error: ../sysdeps/unix/sysv/linux/tst-mount.c:48: not true: r != -1 > ../sysdeps/unix/sysv/linux/tst-mount.c:52: numeric comparison failure > left: 1 (0x1); from: errno > right: 9 (0x9); from: EBADF > error: ../sysdeps/unix/sysv/linux/tst-mount.c:55: not true: mfd != -1 > ../sysdeps/unix/sysv/linux/tst-mount.c:58: numeric comparison failure > left: 1 (0x1); from: errno > right: 2 (0x2); from: ENOENT > error: ../sysdeps/unix/sysv/linux/tst-mount.c:61: not true: r != -1 > ../sysdeps/unix/sysv/linux/tst-mount.c:65: numeric comparison failure > left: 1 (0x1); from: errno > right: 2 (0x2); from: ENOENT > error: ../sysdeps/unix/sysv/linux/tst-mount.c:68: not true: pfd != -1 > error: ../sysdeps/unix/sysv/linux/tst-mount.c:75: not true: fd_tree != -1 > ../sysdeps/unix/sysv/linux/tst-mount.c:88: numeric comparison failure > left: 1 (0x1); from: errno > right: 38 (0x26); from: ENOSYS > error: 12 test failures > --- > sysdeps/unix/sysv/linux/tst-mount.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/sysdeps/unix/sysv/linux/tst-mount.c b/sysdeps/unix/sysv/linux/tst-mount.c > index 502d7e3433..bd75c9e704 100644 > --- a/sysdeps/unix/sysv/linux/tst-mount.c > +++ b/sysdeps/unix/sysv/linux/tst-mount.c > @@ -103,7 +103,8 @@ subprocess (void) > static int > do_test (void) > { > - support_become_root (); > + if (!support_become_root ()) > + FAIL_UNSUPPORTED("could not become root"); > I think the usual way is to check if process can chroot: support_become_root (); if (!support_can_chroot ()) return EXIT_UNSUPPORTED; As done by other tests. > pid_t pid = xfork (); > if (pid == 0)