]> git.ipfire.org Git - thirdparty/systemd.git/commit
nspawn: don't become TTY controller just to undo it later again
authorLennart Poettering <lennart@poettering.net>
Wed, 16 Sep 2020 20:34:43 +0000 (22:34 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 17 Sep 2020 14:39:23 +0000 (16:39 +0200)
commit335d2eadca9e9d8fdac1afb2ceae86d75d815979
treeaa4c7feaa43f03d16d1cf5c6ca1d034b6b7b2650
parent2fef50cd9eee59cea6145639f6bd464939fac624
nspawn: don't become TTY controller just to undo it later again

Instead of first becoming a controlling process of the payload pty
as side effect of opening it (without O_NOCTTY), and then possibly
dropping it again, let's do it cleanly an reverse the logic: let's open
the pty without becoming its controller first. Only after everything
went the way we wanted it to go become the controller explicitly.

This has the benefit that the PID 1 stub process we run (as effect of
--as-pid2) doesn't have to lose the tty explicitly, but can just
continue running with things. And we explicitly make the tty controlling
right before invoking actual payload.

In order to make sure everything works as expected validate that the
stub PID 1 in the container really has no conrolling tty by issuing the
TIOCNOTTY tty and expecting ENOTTY, and log about it.

This shouldn't change behaviour much, it just makes thins a bit cleaner,
in particular as we'll not trigger SIGHUP on ourselves (since we are
controller and session leader) due to TIOCNOTTY which we then have to
explicitly ignore.
src/nspawn/nspawn-stub-pid1.c
src/nspawn/nspawn.c