|
|
f21993 |
commit 5b8e7980c5dabd9aaefeba4f0208baa8cf7653ee
|
|
|
f21993 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
f21993 |
Date: Mon Jan 24 18:14:24 2022 +0100
|
|
|
f21993 |
|
|
|
f21993 |
Linux: Detect user namespace support in io/tst-getcwd-smallbuff
|
|
|
f21993 |
|
|
|
f21993 |
Otherwise the test fails with certain container runtimes.
|
|
|
f21993 |
|
|
|
f21993 |
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
|
|
f21993 |
|
|
|
f21993 |
diff --git a/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c b/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c
|
|
|
f21993 |
index d460d6e7662dc5e4..55362f6060a2b3be 100644
|
|
|
f21993 |
--- a/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c
|
|
|
f21993 |
+++ b/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c
|
|
|
f21993 |
@@ -34,6 +34,7 @@
|
|
|
f21993 |
#include <sys/un.h>
|
|
|
f21993 |
#include <support/check.h>
|
|
|
f21993 |
#include <support/temp_file.h>
|
|
|
f21993 |
+#include <support/test-driver.h>
|
|
|
f21993 |
#include <support/xsched.h>
|
|
|
f21993 |
#include <support/xunistd.h>
|
|
|
f21993 |
|
|
|
f21993 |
@@ -188,6 +189,23 @@ do_test (void)
|
|
|
f21993 |
xmkdir (MOUNT_NAME, S_IRWXU);
|
|
|
f21993 |
atexit (do_cleanup);
|
|
|
f21993 |
|
|
|
f21993 |
+ /* Check whether user namespaces are supported. */
|
|
|
f21993 |
+ {
|
|
|
f21993 |
+ pid_t pid = xfork ();
|
|
|
f21993 |
+ if (pid == 0)
|
|
|
f21993 |
+ {
|
|
|
f21993 |
+ if (unshare (CLONE_NEWUSER | CLONE_NEWNS) != 0)
|
|
|
f21993 |
+ _exit (EXIT_UNSUPPORTED);
|
|
|
f21993 |
+ else
|
|
|
f21993 |
+ _exit (0);
|
|
|
f21993 |
+ }
|
|
|
f21993 |
+ int status;
|
|
|
f21993 |
+ xwaitpid (pid, &status, 0);
|
|
|
f21993 |
+ TEST_VERIFY_EXIT (WIFEXITED (status));
|
|
|
f21993 |
+ if (WEXITSTATUS (status) != 0)
|
|
|
f21993 |
+ return WEXITSTATUS (status);
|
|
|
f21993 |
+ }
|
|
|
f21993 |
+
|
|
|
f21993 |
TEST_VERIFY_EXIT (socketpair (AF_UNIX, SOCK_STREAM, 0, sockfd) == 0);
|
|
|
f21993 |
pid_t child_pid = xclone (child_func, NULL, child_stack,
|
|
|
f21993 |
sizeof (child_stack),
|