]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Hook more properties for transient units 1339/head
authorNicolas Cornu <ncornu@aldebaran.com>
Wed, 23 Sep 2015 07:45:50 +0000 (09:45 +0200)
committerNicolas Cornu <ncornu@aldebaran.com>
Wed, 23 Sep 2015 07:45:50 +0000 (09:45 +0200)
systemd-run can now launch units with WorkingDirectory, RootDirectory set.

src/core/dbus-execute.c
src/shared/bus-util.c

index fd13c6d01905feee8ebcbd197391b04ea1f75c20..868c8cc05a238add2d36df387605843749faec4f 100644 (file)
@@ -847,27 +847,36 @@ int bus_exec_context_set_transient_property(
 
                 return 1;
 
-        } else if (streq(name, "TTYPath")) {
-                const char *tty;
+        } else if (STR_IN_SET(name,
+                              "TTYPath", "WorkingDirectory", "RootDirectory")) {
+                const char *s;
 
-                r = sd_bus_message_read(message, "s", &tty);
+                r = sd_bus_message_read(message, "s", &s);
                 if (r < 0)
                         return r;
 
-                if (!path_is_absolute(tty))
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "TTY device not absolute path");
+                if (!path_is_absolute(s))
+                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "%s takes an absolute path", name);
 
                 if (mode != UNIT_CHECK) {
                         char *t;
 
-                        t = strdup(tty);
+                        t = strdup(s);
                         if (!t)
                                 return -ENOMEM;
 
-                        free(c->tty_path);
-                        c->tty_path = t;
+                        if (streq(name, "TTYPath")) {
+                                free(c->tty_path);
+                                c->tty_path = t;
+                        } else if (streq(name, "WorkingDirectory")) {
+                                free(c->working_directory);
+                                c->working_directory = t;
+                        } else if (streq(name, "RootDirectory")) {
+                                free(c->root_directory);
+                                c->root_directory = t;
+                        }
 
-                        unit_write_drop_in_private_format(u, mode, name, "TTYPath=%s\n", tty);
+                        unit_write_drop_in_private_format(u, mode, name, "%s=%s\n", name, s);
                 }
 
                 return 1;
index fdf41cec194a63c566401b2b5296161d12a19ce5..16b17c2c82504bca5ad91f75cb4f293c02947368 100644 (file)
@@ -1492,7 +1492,8 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                               "User", "Group", "DevicePolicy", "KillMode",
                               "UtmpIdentifier", "UtmpMode", "PAMName", "TTYPath",
                               "StandardInput", "StandardOutput", "StandardError",
-                              "Description", "Slice", "Type"))
+                              "Description", "Slice", "Type", "WorkingDirectory",
+                              "RootDirectory"))
                 r = sd_bus_message_append(m, "v", "s", eq);
 
         else if (streq(field, "DeviceAllow")) {