From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thompson, David" Subject: Re: [PATCH 06/15] build: syscalls: Add setns syscall wrapper. Date: Tue, 7 Jul 2015 20:57:52 -0400 Message-ID: References: <1436188604-2813-1-git-send-email-dthompson2@worcester.edu> <1436188604-2813-6-git-send-email-dthompson2@worcester.edu> <87h9pgjdvu.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCdgW-0004cl-AA for guix-devel@gnu.org; Tue, 07 Jul 2015 20:58:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCdgP-0005Er-HL for guix-devel@gnu.org; Tue, 07 Jul 2015 20:58:00 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:34536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCdgP-0005EO-Aj for guix-devel@gnu.org; Tue, 07 Jul 2015 20:57:53 -0400 Received: by lbnk3 with SMTP id k3so46856601lbn.1 for ; Tue, 07 Jul 2015 17:57:52 -0700 (PDT) In-Reply-To: <87h9pgjdvu.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Cc: guix-devel , David Thompson On Tue, Jul 7, 2015 at 9:28 AM, Ludovic Court=C3=A8s wrote: > David Thompson skribis: > >> From: David Thompson >> >> * guix/build/syscalls.scm (setns): New procedure. >> * tests/syscalls.scm: Test it. > > [...] > >> + (lambda (fdes nstype) >> + "Reassociate the current process with the namespace specified by = FDES. > > =E2=80=9C... by FDES, a file descriptor obtained by opening a /proc/PID/n= s/* > files.=E2=80=9D > >> +(test-assert "setns" >> + (match (clone (logior CLONE_NEWUSER)) >> + (0 (primitive-exit 0)) >> + (clone-pid >> + (match (pipe) >> + ((in . out) >> + (match (primitive-fork) >> + (0 >> + (close in) >> + (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) >> + (equal? (readlink (user-namespace clone-pid)) >> + (readlink (user-namespace fork-pid)))))))))) > > Add a waipid call for both CLONE-PID and FORK-PID to make sure nothing=E2= =80=99s > left behind. > > OK with these changes! Done and pushed. Thanks! - Dave