]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/shared/mount-util.c
namespace: rework how ReadWritePaths= is applied
authorLennart Poettering <lennart@poettering.net>
Sun, 25 Sep 2016 08:40:51 +0000 (10:40 +0200)
committerDjalal Harouni <tixxdz@opendz.org>
Sun, 25 Sep 2016 08:40:51 +0000 (10:40 +0200)
commit6b7c9f8bce4679c89f3b89cacfd4932c0aeadad4
tree02d5497a28119f87d6dfa7484e4c43008ea22e0d
parent7648a565d14dfb5516d93bacf0d87de2de5b5d91
namespace: rework how ReadWritePaths= is applied

Previously, if ReadWritePaths= was nested inside a ReadOnlyPaths=
specification, then we'd first recursively apply the ReadOnlyPaths= paths, and
make everything below read-only, only in order to then flip the read-only bit
again for the subdirs listed in ReadWritePaths= below it.

This is not only ugly (as for the dirs in question we first turn on the RO bit,
only to turn it off again immediately after), but also problematic in
containers, where a container manager might have marked a set of dirs read-only
and this code will undo this is ReadWritePaths= is set for any.

With this patch behaviour in this regard is altered: ReadOnlyPaths= will not be
applied to the children listed in ReadWritePaths= in the first place, so that
we do not need to turn off the RO bit for those after all.

This means that ReadWritePaths=/ReadOnlyPaths= may only be used to turn on the
RO bit, but never to turn it off again. Or to say this differently: if some
dirs are marked read-only via some external tool, then ReadWritePaths= will not
undo it.

This is not only the safer option, but also more in-line with what the man page
currently claims:

        "Entries (files or directories) listed in ReadWritePaths= are
        accessible from within the namespace with the same access rights as
        from outside."

To implement this change bind_remount_recursive() gained a new "blacklist"
string list parameter, which when passed may contain subdirs that shall be
excluded from the read-only mounting.

A number of functions are updated to add more debug logging to make this more
digestable.
src/basic/mount-util.c
src/basic/mount-util.h
src/core/namespace.c
src/nspawn/nspawn-mount.c
src/nspawn/nspawn.c