unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Ivan Vilata i Balaguer <ivan@selidor.net>
Cc: 37967@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	[thread overview]
Message-ID: <87y2wv8tae.fsf@gnu.org> (raw)
In-Reply-To: <20191104032324.GG17621@sax.terramar.selidor.net> (Ivan Vilata i. Balaguer's message of "Sun, 3 Nov 2019 22:23:24 -0500")

[-- Attachment #1: Type: text/plain, Size: 1700 bytes --]

Saluton!

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 759 bytes --]

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	other threads:[~2019-11-04 17:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28 17:27 bug#37967: guix environment -CN: Operation not permitted mounting host's /var/run/nscd Ivan Vilata i Balaguer
2019-10-29 22:16 ` Ludovic Courtès
2019-10-29 22:47   ` Ivan Vilata i Balaguer
2019-11-01 14:26     ` Ludovic Courtès
2019-11-01 15:10       ` Ivan Vilata i Balaguer
2019-11-04  3:23         ` Ivan Vilata i Balaguer
2019-11-04 17:07           ` Ludovic Courtès [this message]
2019-11-04 21:23             ` Ivan Vilata i Balaguer
2019-11-04 22:37               ` Ludovic Courtès
2019-11-08 19:07                 ` Björn Höfling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2wv8tae.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=37967@debbugs.gnu.org \
    --cc=ivan@selidor.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).