Subject: Re: bug#37967: guix environment -CN: Operation not permitted mounting host's /var/run/nscd

From: Ivan Vilata i Balaguer <[email-masked]>
Date: Sun, 3 Nov 2019 22:23:24 -0500

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
    […]

Cheers!

-- 
Ivan Vilata i Balaguer -- https://elvil.net/