sm: keep /etc/nologin when entering runlevel 1 from S

Booting straight into single user mode left logins allowed.  The same
happened going from runlevel 1 to 0 or 6, logins were let in while the
system went down.

The file was created when the new runlevel was 1, 0, 6 or S, and after
that removed when the previous one was.  With both true, the removal
undid the creation.

Remove it only when the new runlevel does not want it.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-23 02:17:23 +01:00
1 parent a629c8add3
commit 8fc4cf8b4b
2 files changed
+6 -4

No files matched your search

+4
View File
@@ -382,6 +382,10 @@ All relevant changes are documented in this file.
files installed. They create `/run/nologin` at boot, and on systemd it files installed. They create `/run/nologin` at boot, and on systemd it
is removed by systemd-user-sessions. Finit now removes it when leaving is removed by systemd-user-sessions. Finit now removes it when leaving
runlevel S, like it already does with `/etc/nologin` runlevel S, like it already does with `/etc/nologin`
- Fix logins allowed in single user mode when booting straight into
runlevel 1, and while going from runlevel 1 to halt or reboot. The
`/etc/nologin` file was created for the new runlevel and then removed
again for the one being left
- Fix a lost reload for a service paused mid-reload by a condition in - Fix a lost reload for a service paused mid-reload by a condition in
flux. A second reload arriving meanwhile re-parsed the unchanged .conf flux. A second reload arriving meanwhile re-parsed the unchanged .conf
and cleared the pending mark, so the service resumed without ever being and cleared the pending mark, so the service resumed without ever being
+2 -4
View File
@@ -327,16 +327,14 @@ static char sm_rl2ch(int lvl)
*/ */
static void nologin(void) static void nologin(void)
{ {
/* From systemd's tmpfiles.d, where systemd-user-sessions removes it */ /* Left by tmpfiles.d at boot */
if (prevlevel == INIT_LEVEL) if (prevlevel == INIT_LEVEL)
erase("/run/nologin"); erase("/run/nologin");
if (runlevel == 1 || IS_RESERVED_RUNLEVEL(runlevel)) if (runlevel == 1 || IS_RESERVED_RUNLEVEL(runlevel))
touch(FINIT_NOLOGIN_PATH); touch(FINIT_NOLOGIN_PATH);
else if (prevlevel == 1 || IS_RESERVED_RUNLEVEL(prevlevel))
if (prevlevel == 1 || IS_RESERVED_RUNLEVEL(prevlevel))
erase(FINIT_NOLOGIN_PATH); erase(FINIT_NOLOGIN_PATH);
} }
void sm_init(void) void sm_init(void)