From 43ace6ea76b0cb4e2ba3f6486acba7dc66e2f19d Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 8 Jun 2015 08:43:05 -0400 Subject: build: syscalls: Add setns. * guix/build/syscalls.scm (setns): New procedure. * tests/syscalls.scm ("setns"): New test. squash: setns --- tests/syscalls.scm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/syscalls.scm') diff --git a/tests/syscalls.scm b/tests/syscalls.scm index 4bc6f0332c..9b8ac9e603 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm @@ -90,6 +90,32 @@ ((_ . status) (= 42 (status:exit-val status)))))))) +(test-assert "setns" + (match (clone (logior CLONE_NEWUSER SIGCHLD)) + (0 (primitive-exit 0)) + (clone-pid + (match (pipe) + ((in . out) + (match (primitive-fork) + (0 + (close in) + ;; Join the user namespace. + (call-with-input-file (user-namespace clone-pid) + (lambda (port) + (setns (port->fdes port) 0))) + (write 'done out) + (close out) + (primitive-exit 0)) + (fork-pid + (close out) + ;; Wait for the child process to join the namespace. + (read in) + (let ((result (and (equal? (readlink (user-namespace clone-pid)) + (readlink (user-namespace fork-pid)))))) + ;; Clean up. + (waitpid clone-pid) + (waitpid fork-pid) + result)))))))) (test-assert "all-network-interfaces" (match (all-network-interfaces) -- cgit v1.2.3