core: add support for StandardInputFile= and friends
These new settings permit specifiying arbitrary paths as stdin/stdout/stderr locations. We try to open/create them as necessary. Some special magic is applied: 1) if the same path is specified for both input and output/stderr, we'll open it only once O_RDWR, and duplicate them fd instead. 2) If we an AF_UNIX socket path is specified, we'll connect() to it, rather than open() it. This allows invoking systemd services with stdin/stdout/stderr connected to arbitrary foreign service sockets. Fixes: #3991
This commit is contained in:
@@ -275,6 +275,22 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
|
||||
r = sd_bus_message_append(m, "sv", "TasksMax", "t", t);
|
||||
goto finish;
|
||||
|
||||
} else if (STR_IN_SET(field, "StandardInput", "StandardOutput", "StandardError")) {
|
||||
const char *n, *appended;
|
||||
|
||||
n = startswith(eq, "fd:");
|
||||
if (n) {
|
||||
appended = strjoina(field, "FileDescriptorName");
|
||||
r = sd_bus_message_append(m, "sv", appended, "s", n);
|
||||
|
||||
} else if ((n = startswith(eq, "file:"))) {
|
||||
appended = strjoina(field, "File");
|
||||
r = sd_bus_message_append(m, "sv", appended, "s", n);
|
||||
} else
|
||||
r = sd_bus_message_append(m, "sv", field, "s", eq);
|
||||
|
||||
goto finish;
|
||||
|
||||
} else if (streq(field, "StandardInputText")) {
|
||||
_cleanup_free_ char *unescaped = NULL;
|
||||
|
||||
@@ -387,7 +403,6 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
|
||||
} else if (STR_IN_SET(field,
|
||||
"User", "Group", "DevicePolicy", "KillMode",
|
||||
"UtmpIdentifier", "UtmpMode", "PAMName", "TTYPath",
|
||||
"StandardInput", "StandardOutput", "StandardError",
|
||||
"Description", "Slice", "Type", "WorkingDirectory",
|
||||
"RootDirectory", "SyslogIdentifier", "ProtectSystem",
|
||||
"ProtectHome", "SELinuxContext", "Restart", "RootImage",
|
||||
|
||||
Reference in New Issue
Block a user