1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-07-15 20:59:30 +03:00

Hook more properties for transient units

systemd-run can now launch units with WorkingDirectory, RootDirectory set.
This commit is contained in:
Nicolas Cornu
2015-09-23 09:45:50 +02:00
parent f98f4ace4d
commit 602b83559a
2 changed files with 20 additions and 10 deletions

View File

@ -847,27 +847,36 @@ int bus_exec_context_set_transient_property(
return 1; return 1;
} else if (streq(name, "TTYPath")) { } else if (STR_IN_SET(name,
const char *tty; "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) if (r < 0)
return r; return r;
if (!path_is_absolute(tty)) if (!path_is_absolute(s))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "TTY device not absolute path"); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "%s takes an absolute path", name);
if (mode != UNIT_CHECK) { if (mode != UNIT_CHECK) {
char *t; char *t;
t = strdup(tty); t = strdup(s);
if (!t) if (!t)
return -ENOMEM; return -ENOMEM;
if (streq(name, "TTYPath")) {
free(c->tty_path); free(c->tty_path);
c->tty_path = t; 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; return 1;

View File

@ -1492,7 +1492,8 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
"User", "Group", "DevicePolicy", "KillMode", "User", "Group", "DevicePolicy", "KillMode",
"UtmpIdentifier", "UtmpMode", "PAMName", "TTYPath", "UtmpIdentifier", "UtmpMode", "PAMName", "TTYPath",
"StandardInput", "StandardOutput", "StandardError", "StandardInput", "StandardOutput", "StandardError",
"Description", "Slice", "Type")) "Description", "Slice", "Type", "WorkingDirectory",
"RootDirectory"))
r = sd_bus_message_append(m, "v", "s", eq); r = sd_bus_message_append(m, "v", "s", eq);
else if (streq(field, "DeviceAllow")) { else if (streq(field, "DeviceAllow")) {