diff options
author | Daniel Mack <github@zonque.org> | 2015-10-08 16:09:09 +0200 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2015-10-08 16:09:09 +0200 |
commit | ad86c1335a2a474f91186a736a5231d0c66313c6 (patch) | |
tree | f3cc983826f4067f8dcb12f4828a2e2c8cc8e64c /src/core/dbus-service.c | |
parent | 8f3db94d9d905e6c31c1fcd0dcc6be7b78034c5c (diff) | |
parent | 1af1f2f92ef52e3e905b7928d42345d9c48e7e7b (diff) |
Merge pull request #1496 from poettering/stdin-fd
allow passing in fds for stdin/stdout/stderr for transient services
Diffstat (limited to 'src/core/dbus-service.c')
-rw-r--r-- | src/core/dbus-service.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index 3436342bef..b636f8ba6a 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -19,6 +19,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include "async.h" #include "strv.h" #include "path-util.h" #include "unit.h" @@ -120,6 +121,37 @@ static int bus_service_set_transient_property( return 1; + } else if (STR_IN_SET(name, + "StandardInputFileDescriptor", + "StandardOutputFileDescriptor", + "StandardErrorFileDescriptor")) { + int fd; + + r = sd_bus_message_read(message, "h", &fd); + if (r < 0) + return r; + + if (mode != UNIT_CHECK) { + int copy; + + copy = fcntl(fd, F_DUPFD_CLOEXEC, 3); + if (copy < 0) + return -errno; + + if (streq(name, "StandardInputFileDescriptor")) { + asynchronous_close(s->stdin_fd); + s->stdin_fd = copy; + } else if (streq(name, "StandardOutputFileDescriptor")) { + asynchronous_close(s->stdout_fd); + s->stdout_fd = copy; + } else { + asynchronous_close(s->stderr_fd); + s->stderr_fd = copy; + } + } + + return 1; + } else if (streq(name, "ExecStart")) { unsigned n = 0; |