From 8fc4cf8b4bac636633cceb5980ad3946ea96bc8c Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 23 Nov 2026 02:17:23 +0100 Subject: [PATCH] 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 --- doc/ChangeLog.md | 4 ++++ src/sm.c | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index 3eeb8933..7fc1e3fe 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -382,6 +382,10 @@ All relevant changes are documented in this file. files installed. They create `/run/nologin` at boot, and on systemd it is removed by systemd-user-sessions. Finit now removes it when leaving 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 flux. A second reload arriving meanwhile re-parsed the unchanged .conf and cleared the pending mark, so the service resumed without ever being diff --git a/src/sm.c b/src/sm.c index 9b63c239..debe47f3 100644 --- a/src/sm.c +++ b/src/sm.c @@ -327,16 +327,14 @@ static char sm_rl2ch(int lvl) */ 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) erase("/run/nologin"); if (runlevel == 1 || IS_RESERVED_RUNLEVEL(runlevel)) touch(FINIT_NOLOGIN_PATH); - - if (prevlevel == 1 || IS_RESERVED_RUNLEVEL(prevlevel)) + else if (prevlevel == 1 || IS_RESERVED_RUNLEVEL(prevlevel)) erase(FINIT_NOLOGIN_PATH); - } void sm_init(void)