diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index 5d7c6aaf..b5315a30 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -315,6 +315,10 @@ All relevant changes are documented in this file. - Fix age `0` in a tmpfiles entry, it was read as no age. As in tmpfiles.d(5), `tmpfiles --clean` now empties the directory of such an entry +- Fix logins refused after boot on a system with systemd's tmpfiles.d + 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 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 4bfcc3e2..9b63c239 100644 --- a/src/sm.c +++ b/src/sm.c @@ -327,11 +327,16 @@ static char sm_rl2ch(int lvl) */ static void nologin(void) { + /* From systemd's tmpfiles.d, where systemd-user-sessions removes it */ + 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)) erase(FINIT_NOLOGIN_PATH); + } void sm_init(void) diff --git a/test/tmpfiles-boot.sh b/test/tmpfiles-boot.sh index e346547f..91ad75f2 100755 --- a/test/tmpfiles-boot.sh +++ b/test/tmpfiles-boot.sh @@ -22,11 +22,18 @@ test_teardown() { say "Running test teardown." run "rm -rf $DIR $CONF /fastboot" + rm -f "$NOLOGIN" } # Removed at boot by an r! entry in Finit's own legacy.conf touch "${SYSROOT:-$(pwd)/$TEST_DIR/sysroot}/fastboot" +# What systemd's own tmpfiles.d has, logins are refused until boot is done +NOLOGIN="${SYSROOT:-$(pwd)/$TEST_DIR/sysroot}/etc/tmpfiles.d/nologin.conf" +mkdir -p "$(dirname "$NOLOGIN")" +echo 'f+! /run/nologin 0644 - - - "System is booting up."' > "$NOLOGIN" +echo 'f! /run/nologin-ran' >> "$NOLOGIN" + # shellcheck source=/dev/null . "$TEST_DIR/lib/setup.sh" @@ -34,6 +41,11 @@ sep say 'Finit runs the boot-only entries, and removes, at boot' assert_exists /fastboot no +sep +say 'Logins are let in again when boot is done' +assert_exists /run/nologin-ran yes +assert_exists /run/nologin no + run "cat > $CONF" <