]> git.ipfire.org Git - thirdparty/systemd.git/commit
sulogin: fix control lost of the current terminal when default.target is rescue.target 26271/head
authorHATAYAMA Daisuke <d.hatayama@fujitsu.com>
Sun, 12 Feb 2023 12:15:08 +0000 (12:15 +0000)
committerHATAYAMA Daisuke <d.hatayama@fujitsu.com>
Thu, 16 Feb 2023 12:22:23 +0000 (07:22 -0500)
commit937ca8330d11e406b8ef343bead6f4f6244e39c7
tree5c7d978c3ded776c12448e6adb909d27d8fbbcd8
parent2ffbf44344983d64949e032e74edb19c48b16cc0
sulogin: fix control lost of the current terminal when default.target is rescue.target

When default.target is rescue.target, exiting from the single-user shell
results in lost of the control of the current terminal. This is because the
operation performed to continue to boot is systemctl default but default.target
is now rescue.target and it is already active. Hence, no new process that
controls the current terminal is created. Users need to make hardware reset to
recover the situation.

This sounds like a bit corner case issue and some might feel configuring
default.target as rescue.target is odd because there are several other ways to
transition to rescue.mode without configuring default.target to rescue.target
such as systemctl rescue or systemd.unit=rescue.target something like
that. However, users unfamiliar with systemd operations tend to come up with
systemctl set-default rescue.target.

To fix this issue, let's transition to default.target only when default.target
is inactive. Otherwise, invoke the single-user shell again to keep control of
the current terminal for users.

This new logic depends on whether D-Bus working well. Exiting without any check
of result of systemctl default could lead to again the control lost of the
current terminal. Hence, add checking results of each D-Bus operations
including systemctl default and invoke the single-user shell if they fail.
src/sulogin-shell/sulogin-shell.c