bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37967: guix environment -CN: Operation not permitted mounting host's


From: Ludovic Courtès
Subject: bug#37967: guix environment -CN: Operation not permitted mounting host's /var/run/nscd
Date: Mon, 04 Nov 2019 18:07:05 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Saluton!

Ivan Vilata i Balaguer <address@hidden> 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’.

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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]