From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:bc8:30d7:100::1]) by sourceware.org (Postfix) with ESMTPS id B06E33858C53; Thu, 18 Aug 2022 10:02:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B06E33858C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: sourceware.org; spf=none smtp.mailfrom=aurel32.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:From:Reply-To: Subject:Content-ID:Content-Description:X-Debbugs-Cc; bh=y83CEBK2PEth0+hokw8Syz/ZUG0ylINgbRdUWFHVrkc=; b=JgTNIbq3sI7g/DDh1zAo8uOaV6 Yx3RZd9WGOYVm2NWRpQvk73tEXAeWALovlgHQrFM5NWaGI9DXR5zOx4Qq7KdhVkZgFla90zTt2xuT 08fqNnsR3rxwKoJQiDG5tHvM2pDp2GEAWnfoaVTZylqATLxptAfBrU5sa81xWxPxG8nCGJWYeqk+y Gyo1lGcLmPbImwKEpZi5DAisy35TTni9HW8aureTny2Euoi0UilGzSA0ndCEekwrNEGh5fRIXAnVw Hl+NIckM63A+v+eGeE2S4cZlLtYsBqgJMDhNjUIjgXYiKBK6ZjCpK1g9wy2lpcyYbTqmj61Rn8RGY HL0OlANA==; Received: from [2a01:e0a:406:7381:3e0e:d27:becd:e47b] (helo=ohm.aurel32.net) by hall.aurel32.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oOcMG-00ApvC-TX; Thu, 18 Aug 2022 12:02:36 +0200 Received: from aurel32 by ohm.aurel32.net with local (Exim 4.96) (envelope-from ) id 1oOcM9-008Ozb-0b; Thu, 18 Aug 2022 12:02:29 +0200 From: Aurelien Jarno To: libc-stable@sourceware.org Cc: Florian Weimer , Siddhesh Poyarekar Subject: [COMMITTED 2.31 7/7] Linux: Detect user namespace support in io/tst-getcwd-smallbuff Date: Thu, 18 Aug 2022 12:02:25 +0200 Message-Id: <20220818100225.2002653-7-aurelien@aurel32.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220818100225.2002653-1-aurelien@aurel32.net> References: <20220818100225.2002653-1-aurelien@aurel32.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_NONE, 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-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2022 10:02:41 -0000 From: Florian Weimer Otherwise the test fails with certain container runtimes. Reviewed-by: Siddhesh Poyarekar (cherry picked from commit 5b8e7980c5dabd9aaefeba4f0208baa8cf7653ee) --- sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c b/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c index d460d6e766..55362f6060 100644 --- a/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c +++ b/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -188,6 +189,23 @@ do_test (void) xmkdir (MOUNT_NAME, S_IRWXU); atexit (do_cleanup); + /* Check whether user namespaces are supported. */ + { + pid_t pid = xfork (); + if (pid == 0) + { + if (unshare (CLONE_NEWUSER | CLONE_NEWNS) != 0) + _exit (EXIT_UNSUPPORTED); + else + _exit (0); + } + int status; + xwaitpid (pid, &status, 0); + TEST_VERIFY_EXIT (WIFEXITED (status)); + if (WEXITSTATUS (status) != 0) + return WEXITSTATUS (status); + } + TEST_VERIFY_EXIT (socketpair (AF_UNIX, SOCK_STREAM, 0, sockfd) == 0); pid_t child_pid = xclone (child_func, NULL, child_stack, sizeof (child_stack), -- 2.35.1