]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: simplify and check validity of paths for RequiresMountsFor=
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 7 Mar 2019 06:12:10 +0000 (15:12 +0900)
committerLennart Poettering <lennart@poettering.net>
Fri, 8 Mar 2019 14:48:34 +0000 (15:48 +0100)
Prompted by #11910.

src/core/dbus-unit.c

index 17c2003c8fbb50c1763c2becd286916453c317f3..28ae6070a60d0a0cbd8ec184d99322e6ebbbe2f6 100644 (file)
@@ -1674,9 +1674,17 @@ static int bus_unit_set_transient_property(
                         return r;
 
                 STRV_FOREACH(p, l) {
+                        path_simplify(*p, true);
+
                         if (!path_is_absolute(*p))
                                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path specified in %s is not absolute: %s", name, *p);
 
+                        if (!path_is_valid(*p))
+                                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path specified in %s has invalid length: %s", name, *p);
+
+                        if (!path_is_normalized(*p))
+                                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path specified in %s is not normalized: %s", name, *p);
+
                         if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
                                 r = unit_require_mounts_for(u, *p, UNIT_DEPENDENCY_FILE);
                                 if (r < 0)