From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ivan Vilata i Balaguer Subject: bug#37967: guix environment -CN: Operation not permitted mounting host's /var/run/nscd Date: Mon, 4 Nov 2019 16:23:12 -0500 Message-ID: <20191104212312.GK17621@sax.terramar.selidor.net> References: <20191028172741.GJ17570@sax.terramar.selidor.net> <87v9s7dwoe.fsf@gnu.org> <20191029224714.GA17621@sax.terramar.selidor.net> <87v9s3brl8.fsf@gnu.org> <20191101151002.GE17621@sax.terramar.selidor.net> <20191104032324.GG17621@sax.terramar.selidor.net> <87y2wv8tae.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:54247) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iRjqS-0002dq-Iz for bug-guix@gnu.org; Mon, 04 Nov 2019 16:25:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iRjqQ-0005QA-Cv for bug-guix@gnu.org; Mon, 04 Nov 2019 16:25:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:57045) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iRjqQ-0005Pu-7G for bug-guix@gnu.org; Mon, 04 Nov 2019 16:25:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iRjqP-0005F9-VC for bug-guix@gnu.org; Mon, 04 Nov 2019 16:25:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: Content-Disposition: inline In-Reply-To: <87y2wv8tae.fsf@gnu.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 37967@debbugs.gnu.org, Ivan Vilata i Balaguer Ludovic Courtès (2019-11-04 18:07:05 +0100) wrote: > Ivan Vilata i Balaguer skribis: > > > BTW, I ran that under strace and it looks like the read-only remount fails > > after mounting `/var/run/nscd` in the new namespace has succeeded: > > > > $ strace -f unshare -mUr mount --bind -o ro /var/run/nscd /tmp/tt > > […] > > access("/run/mount", R_OK|W_OK) = -1 EACCES (Permission denied) > > mount("/run/nscd", "/tmp/tt", 0x14c25b0, MS_RDONLY|MS_BIND, NULL) = 0 > > mount("none", "/tmp/tt", NULL, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL) = -1 EPERM (Operation not permitted) > > write(2, "mount: ", 7mount: ) = 7 > > write(2, "/tmp/tt: filesystem was mounted,"..., 89/tmp/tt: filesystem was mounted, but any subsequent operation failed: Unknown error 5005.) = 89 > > write(2, "\n", 1 > > […] > > Weird, why does it remount it? > > What does: > > mount | grep /run $ mount | grep /run tmpfs on /run type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1641444k,mode=755) […] > returns? I just tried on a Debian 10 image with Linux 4.19.0 and /run > is a tmpfs, which may be the reason why read-only bind-mounts fail (or > at least there’s a bug in that area.) > > Anyway, below is a patch for you to test. Let me know how it goes. :-) > > Thanks, > Ludo’. I applied your patch on top of bf7b08c4, pulled Guix and did successfully start `guix environment -CN`, with network support and all. Cool! `:)` > diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm > index 6cf6ccc53e..6cdb2b749d 100644 > --- a/gnu/system/file-systems.scm > +++ b/gnu/system/file-systems.scm > @@ -507,7 +507,8 @@ a bind mount." > ;; XXX: On some GNU/Linux systems, /etc/resolv.conf is a > ;; symlink to a file in a tmpfs which, for an unknown reason, > ;; cannot be bind mounted read-only within the container. > - (writable? (string=? file "/etc/resolv.conf")))) > + (writable? (or (string=? file "/etc/resolv.conf") > + (string=? file "/var/run/nscd"))))) > (cons "/var/run/nscd" %network-configuration-files))) > > (define (file-system-type-predicate type) -- Ivan Vilata i Balaguer -- https://elvil.net/