From: Yu Watanabe Date: Fri, 13 Oct 2017 12:22:25 +0000 (+0900) Subject: core: ReadWritePaths= and friends assume '+' prefix when BindPaths= or freinds are set X-Git-Tag: v236~258^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d18aff042273112b07e77bb56023b08c71a5f0b2;p=platform%2Fupstream%2Fsystemd.git core: ReadWritePaths= and friends assume '+' prefix when BindPaths= or freinds are set When at least one of BindPaths=, BindReadOnlyPaths=, RootImage=, RuntimeDirectory= or their friends are set, systemd prepares a namespace under /run/systemd/unit-root. Thus, ReadWritePaths= or their friends without '+' prefix is completely meaningless. So, let's assume '+' prefix when one of them are set. Fixes #7070 and #7080. --- diff --git a/src/core/namespace.c b/src/core/namespace.c index 9624d8a..33349f2 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -191,7 +191,7 @@ static void mount_entry_done(MountEntry *p) { p->source_malloc = mfree(p->source_malloc); } -static int append_access_mounts(MountEntry **p, char **strv, MountMode mode) { +static int append_access_mounts(MountEntry **p, char **strv, MountMode mode, bool forcibly_require_prefix) { char **i; assert(p); @@ -219,7 +219,7 @@ static int append_access_mounts(MountEntry **p, char **strv, MountMode mode) { .path_const = e, .mode = mode, .ignore = ignore, - .has_prefix = !needs_prefix, + .has_prefix = !needs_prefix && !forcibly_require_prefix, }; } @@ -983,6 +983,7 @@ int setup_namespace( bool make_slave = false; const char *root; unsigned n_mounts; + bool require_prefix = false; int r = 0; assert(ns_info); @@ -1027,6 +1028,7 @@ int setup_namespace( root = "/run/systemd/unit-root"; (void) mkdir_label(root, 0700); + require_prefix = true; } else root = NULL; @@ -1047,15 +1049,15 @@ int setup_namespace( if (n_mounts > 0) { m = mounts = (MountEntry *) alloca0(n_mounts * sizeof(MountEntry)); - r = append_access_mounts(&m, read_write_paths, READWRITE); + r = append_access_mounts(&m, read_write_paths, READWRITE, require_prefix); if (r < 0) goto finish; - r = append_access_mounts(&m, read_only_paths, READONLY); + r = append_access_mounts(&m, read_only_paths, READONLY, require_prefix); if (r < 0) goto finish; - r = append_access_mounts(&m, inaccessible_paths, INACCESSIBLE); + r = append_access_mounts(&m, inaccessible_paths, INACCESSIBLE, require_prefix); if (r < 0) goto finish;