From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#37967: guix environment -CN: Operation not permitted mounting host's /var/run/nscd Date: Mon, 04 Nov 2019 18:07:05 +0100 Message-ID: <87y2wv8tae.fsf@gnu.org> 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> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:58665) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iRfpj-0003Nn-1G for bug-guix@gnu.org; Mon, 04 Nov 2019 12:08:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iRfpi-0007ZU-0K for bug-guix@gnu.org; Mon, 04 Nov 2019 12:08:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56860) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iRfph-0007ZQ-Tg for bug-guix@gnu.org; Mon, 04 Nov 2019 12:08:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iRfph-0002cY-Mx for bug-guix@gnu.org; Mon, 04 Nov 2019 12:08:01 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <20191104032324.GG17621@sax.terramar.selidor.net> (Ivan Vilata i. Balaguer's message of "Sun, 3 Nov 2019 22:23:24 -0500") 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: Ivan Vilata i Balaguer Cc: 37967@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Saluton! Ivan Vilata i Balaguer skribis: > Ivan Vilata i Balaguer (2019-11-01 11:10:02 -0400) wrote: > >> Ludovic Court=C3=A8s (2019-11-01 15:26:27 +0100) wrote: >>=20 >> > [=E2=80=A6] What about a read-only bind mount like this: >> >=20 >> > unshare -mUr mount --bind -o ro /var/run/nscd /tmp/tt >> >=20 >> > ? >>=20 >> This one looks more interesting: >>=20 >> $ unshare -mUr mount --bind -o ro /var/run/nscd /tmp/tt && echo ok >> mount: /tmp/tt: filesystem was mounted, but any subsequent operation= failed: Unknown error 5005. >> $ echo $? >> 32 > > 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 > [=E2=80=A6] > access("/run/mount", R_OK|W_OK) =3D -1 EACCES (Permission den= ied) > mount("/run/nscd", "/tmp/tt", 0x14c25b0, MS_RDONLY|MS_BIND, NULL) =3D= 0 > mount("none", "/tmp/tt", NULL, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL) = =3D -1 EPERM (Operation not permitted) > write(2, "mount: ", 7mount: ) =3D 7 > write(2, "/tmp/tt: filesystem was mounted,"..., 89/tmp/tt: filesystem= was mounted, but any subsequent operation failed: Unknown error 5005.) =3D= 89 > write(2, "\n", 1 > [=E2=80=A6] Weird, why does it remount it? What does: mount | grep /run 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=E2=80=99s a bug in that area.) Anyway, below is a patch for you to test. Let me know how it goes. :-) Thanks, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline 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) --=-=-=--