diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-07-17 11:47:14 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-07-25 22:48:11 +0200 |
commit | 5686391b006ee82d8a4559067ad9818e3e631247 (patch) | |
tree | 2d5bcfcf0838a3abd120bde1a7145acf2492b3b6 /src/core/execute.h | |
parent | ce0d60a7c4e07c5bdfed9f076bd48752287f0777 (diff) | |
download | systemd-5686391b006ee82d8a4559067ad9818e3e631247.tar.gz |
core: introduce new Type=exec service type
Users are often surprised that "systemd-run" command lines like
"systemd-run -p User=idontexist /bin/true" will return successfully,
even though the logs show that the process couldn't be invoked, as the
user "idontexist" doesn't exist. This is because Type=simple will only
wait until fork() succeeded before returning start-up success.
This patch adds a new service type Type=exec, which is very similar to
Type=simple, but waits until the child process completed the execve()
before returning success. It uses a pipe that has O_CLOEXEC set for this
logic, so that the kernel automatically sends POLLHUP on it when the
execve() succeeded but leaves the pipe open if not. This means PID 1
waits exactly until the execve() succeeded in the child, and not longer
and not shorter, which is the desired functionality.
Making use of this new functionality, the command line
"systemd-run -p User=idontexist -p Type=exec /bin/true" will now fail,
as expected.
Diffstat (limited to 'src/core/execute.h')
-rw-r--r-- | src/core/execute.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/core/execute.h b/src/core/execute.h index aa6f1ccfda..cd5165c2d1 100644 --- a/src/core/execute.h +++ b/src/core/execute.h @@ -317,6 +317,9 @@ struct ExecParameters { int stdin_fd; int stdout_fd; int stderr_fd; + + /* An fd that is closed by the execve(), and thus will result in EOF when the execve() is done */ + int exec_fd; }; #include "unit.h" |