summaryrefslogtreecommitdiffstats
path: root/src/core/service.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-03-20 21:28:02 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-20 21:28:02 +0100
commit6f765baf23d0d4ed7efa6e2db2a629fd519f3a7a (patch)
tree791b17596710128935e3dff268b4c862396f1260 /src/core/service.c
parentexecute: split check if we might touch a tty out of exec_context_may_touch_co... (diff)
downloadsystemd-6f765baf23d0d4ed7efa6e2db2a629fd519f3a7a.tar.xz
systemd-6f765baf23d0d4ed7efa6e2db2a629fd519f3a7a.zip
core: rework how we reset the TTY after use by a service
This makes two changes: 1. Instead of resetting the configured service TTY each time after a process exited, let's do so only when the service goes back to "dead" state. This should be preferable in case the started processes leave background child processes around that still reference the TTY. 2. chmod() and chown() the TTY at the same time. This should make it safe to run "systemd-run -p DynamicUser=1 -p StandardInput=tty -p TTYPath=/dev/tty8 /bin/bash" without leaving a TTY owned by a dynamic user around.
Diffstat (limited to 'src/core/service.c')
-rw-r--r--src/core/service.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/core/service.c b/src/core/service.c
index 25a1297569..89029b6d11 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1754,6 +1754,9 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
if (s->pid_file)
(void) unlink(s->pid_file);
+ /* Reset TTY ownership if necessary */
+ exec_context_revert_tty(&s->exec_context);
+
return;
fail: