GNU bug report logs - #37967
guix environment -CN: Operation not permitted mounting host's /var/run/nscd

Previous Next

Package: guix;

Reported by: Ivan Vilata i Balaguer <ivan <at> selidor.net>

Date: Mon, 28 Oct 2019 17:29:02 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ludovic Courtès <ludo <at> gnu.org>
To: Ivan Vilata i Balaguer <ivan <at> selidor.net>
Cc: 37967 <at> debbugs.gnu.org
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 part 1 (text/plain, inline)]
Saluton!

Ivan Vilata i Balaguer <ivan <at> selidor.net> skribis:

> Ivan Vilata i Balaguer (2019-11-01 11:10:02 -0400) wrote:
>
>> Ludovic Courtès (2019-11-01 15:26:27 +0100) wrote:
>> 
>> > […] What about a read-only bind mount like this:
>> > 
>> >   unshare -mUr mount --bind -o ro /var/run/nscd /tmp/tt
>> > 
>> > ?
>> 
>> This one looks more interesting:
>> 
>>     $ 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
>     […]
>     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

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’.

[Message part 2 (text/x-patch, 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)

This bug report was last modified 5 years and 282 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.