]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: actually make "+" prefix in ReadOnlyPaths=, InaccessiblePaths=, ReadWritablePat...
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Dec 2016 00:16:43 +0000 (01:16 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 7 Feb 2017 10:22:05 +0000 (11:22 +0100)
5327c910d2fc1ae91bd0b891be92b30379c7467b claimed to add support for "+"
for prefixing paths with the configured RootDirectory=. But actually it
only implemented it in the backend, it did not add support for it to the
configuration file parsers. Fix that now.

src/core/dbus-execute.c
src/core/load-fragment.c
src/shared/bus-unit-util.c

index 60b0288bb068ffacc6d798c461207fb82fe9e063..c57af5aaafa875605473ab25442b9a4c9c538413 100644 (file)
@@ -1498,12 +1498,15 @@ int bus_exec_context_set_transient_property(
                         return r;
 
                 STRV_FOREACH(p, l) {
-                        int offset;
-                        if (!utf8_is_valid(*p))
+                        const char *i = *p;
+                        size_t offset;
+
+                        if (!utf8_is_valid(i))
                                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid %s", name);
 
-                        offset = **p == '-';
-                        if (!path_is_absolute(*p + offset))
+                        offset = i[0] == '-';
+                        offset += i[offset] == '+';
+                        if (!path_is_absolute(i + offset))
                                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid %s", name);
                 }
 
@@ -1522,7 +1525,6 @@ int bus_exec_context_set_transient_property(
                                 unit_write_drop_in_private_format(u, mode, name, "%s=", name);
                         } else {
                                 r = strv_extend_strv(dirs, l, true);
-
                                 if (r < 0)
                                         return -ENOMEM;
 
index 243c288885dd88d25d8381d1dee23d57d25bd006..5b7471c0d0d202b45a28c138ec9f862c8128c6c8 100644 (file)
@@ -3839,7 +3839,8 @@ int config_parse_namespace_path_strv(
         cur = rvalue;
         for (;;) {
                 _cleanup_free_ char *word = NULL, *resolved = NULL, *joined = NULL;
-                bool ignore_enoent;
+                const char *w;
+                bool ignore_enoent = false, shall_prefix = false;
 
                 r = extract_first_word(&cur, &word, NULL, EXTRACT_QUOTES);
                 if (r == 0)
@@ -3856,9 +3857,17 @@ int config_parse_namespace_path_strv(
                         continue;
                 }
 
-                ignore_enoent = word[0] == '-';
+                w = word;
+                if (startswith(w, "-")) {
+                        ignore_enoent = true;
+                        w++;
+                }
+                if (startswith(w, "+")) {
+                        shall_prefix = true;
+                        w++;
+                }
 
-                r = unit_full_printf(u, word + ignore_enoent, &resolved);
+                r = unit_full_printf(u, w, &resolved);
                 if (r < 0) {
                         log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve specifiers in %s: %m", word);
                         continue;
@@ -3871,7 +3880,9 @@ int config_parse_namespace_path_strv(
 
                 path_kill_slashes(resolved);
 
-                joined = strjoin(ignore_enoent ? "-" : "", resolved);
+                joined = strjoin(ignore_enoent ? "-" : "",
+                                 shall_prefix ? "+" : "",
+                                 resolved);
 
                 r = strv_push(sv, joined);
                 if (r < 0)
index b6da20a04a8c41baff37d830cd2c2f08aa4ab6ed..a4677bef271fcc060b7b62fd79f72b5f338c0207 100644 (file)
@@ -484,7 +484,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
 
                 for (p = eq;;) {
                         _cleanup_free_ char *word = NULL;
-                        int offset;
+                        size_t offset;
 
                         r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
                         if (r < 0) {
@@ -500,6 +500,8 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                         }
 
                         offset = word[0] == '-';
+                        offset += word[offset] == '+';
+
                         if (!path_is_absolute(word + offset)) {
                                 log_error("Failed to parse %s value %s", field, eq);
                                 return -EINVAL;