diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/namespace.c | 12 | ||||
-rw-r--r-- | src/shared/conf-parser.c | 10 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/core/namespace.c b/src/core/namespace.c index 7e33d84156..16b132ba56 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -51,6 +51,7 @@ typedef struct BindMount { const char *path; MountMode mode; bool done; + bool ignore; } BindMount; static int append_mounts(BindMount **p, char **strv, MountMode mode) { @@ -58,6 +59,13 @@ static int append_mounts(BindMount **p, char **strv, MountMode mode) { STRV_FOREACH(i, strv) { + (*p)->ignore = false; + + if ((mode == INACCESSIBLE || mode == READONLY) && (*i)[0] == '-') { + (*p)->ignore = true; + (*i)++; + } + if (!path_is_absolute(*i)) return -EINVAL; @@ -155,6 +163,8 @@ static int apply_mount( r = mount(what, m->path, NULL, MS_BIND|MS_REC, NULL); if (r >= 0) log_debug("Successfully mounted %s to %s", what, m->path); + else if (m->ignore && errno == ENOENT) + r = 0; return r; } @@ -168,7 +178,7 @@ static int make_read_only(BindMount *m) { return 0; r = mount(NULL, m->path, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY|MS_REC, NULL); - if (r < 0) + if (r < 0 && !(m->ignore && errno == ENOENT)) return -errno; return 0; diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 2303d9a50b..6085d33391 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -599,6 +599,7 @@ int config_parse_path(const char *unit, char **s = data; char *n; + int offset; assert(filename); assert(lvalue); @@ -611,7 +612,9 @@ int config_parse_path(const char *unit, return 0; } - if (!path_is_absolute(rvalue)) { + offset = rvalue[0] == '-' && (streq(lvalue, "InaccessibleDirectories") || + streq(lvalue, "ReadOnlyDirectories")); + if (!path_is_absolute(rvalue + offset)) { log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Not an absolute path, ignoring: %s", rvalue); return 0; @@ -713,6 +716,7 @@ int config_parse_path_strv(const char *unit, FOREACH_WORD_QUOTED(w, l, rvalue, state) { _cleanup_free_ char *n; + int offset; n = strndup(w, l); if (!n) @@ -724,7 +728,9 @@ int config_parse_path_strv(const char *unit, continue; } - if (!path_is_absolute(n)) { + offset = n[0] == '-' && (streq(lvalue, "InaccessibleDirectories") || + streq(lvalue, "ReadOnlyDirectories")); + if (!path_is_absolute(n + offset)) { log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Not an absolute path, ignoring: %s", rvalue); continue; |