From 2c1e9877f99f6e49bec3dee96761f584939b62ab Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 18 Sep 2016 11:24:10 +0200 Subject: [PATCH] Touch /etc/nologin when runlevel change comes in The /etc/nologin file must be set as soon as the runlevel change to 0/1/6 comes in, not when done with runlevel change and services have been started, if any. Signed-off-by: Joachim Nilsson --- sm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sm.c b/sm.c index 0ad02d6e..c2c7f097 100644 --- a/sm.c +++ b/sm.c @@ -127,6 +127,12 @@ restart: _d("Setting new runlevel --> %d <-- previous %d", runlevel, prevlevel); runlevel_set(prevlevel, runlevel); + /* Disable login in single-user mode as well as shutdown/reboot */ + if (runlevel == 1 || runlevel == 0 || runlevel == 6) + touch("/etc/nologin"); + else + erase("/etc/nologin"); + /* Make sure to (re)load all *.conf in /etc/finit.d/ */ conf_reload_dynamic(); @@ -154,12 +160,6 @@ restart: /* Cleanup stale services */ svc_clean_dynamic(service_unregister); - /* Disable login in single-user mode as well as shutdown/reboot */ - if (runlevel == 1 || runlevel == 0 || runlevel == 6) - touch("/etc/nologin"); - else - erase("/etc/nologin"); - if (0 == runlevel) { do_shutdown(SHUT_OFF); sm->state = SM_RUNNING_STATE;