From a9a7b08021fa7a6a3316725bdd293b615d6a68ac Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 24 Aug 2016 19:27:23 +0200 Subject: [PATCH] Disable login also in shutdown/reboot Disable login in single-user mode as well as shutdown/reboot Signed-off-by: Joachim Nilsson --- sm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sm.c b/sm.c index 34b2834a..0ad02d6e 100644 --- a/sm.c +++ b/sm.c @@ -154,6 +154,12 @@ 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; @@ -165,11 +171,6 @@ restart: break; } - if (runlevel == 1) - touch("/etc/nologin"); /* Disable login in single-user mode */ - else - erase("/etc/nologin"); - /* No TTYs run at bootstrap, they have a delayed start. */ if (prevlevel > 0) tty_runlevel(runlevel);