Merge pull request #200 from liuming50/dont-hard-code-nologins-file

Dont hard-code nologin file
This commit is contained in:
Joachim Wiberg authored and GitHub committed 2021-09-18 09:48:43 +02:00
commit aef3b4117d
2 files changed
+11 -4

No files matched your search

+2
View File
@@ -269,6 +269,8 @@ Optional features:
Built-in keventd......: $with_keventd Built-in keventd......: $with_keventd
Built-in watchdogd....: $with_watchdog $watchdog Built-in watchdogd....: $with_watchdog $watchdog
Built-in logrotate....: $enable_logrotate Built-in logrotate....: $enable_logrotate
Skip fsck check.......: $enable_fastboot
Run fsck fix mode.....: $enable_fsckfix
Redirect output.......: $enable_redirect Redirect output.......: $enable_redirect
Default hostname......: $hostname Default hostname......: $hostname
Default runlevel......: $runlevel Default runlevel......: $runlevel
+9 -4
View File
@@ -23,6 +23,7 @@
#include "config.h" /* Generated by configure script */ #include "config.h" /* Generated by configure script */
#include <paths.h>
#include <sys/types.h> #include <sys/types.h>
#include "finit.h" #include "finit.h"
@@ -38,6 +39,10 @@
sm_t sm; sm_t sm;
#ifndef FINIT_NOLOGIN_PATH
#define FINIT_NOLOGIN_PATH _PATH_NOLOGIN /* Stop user logging in. */
#endif
void sm_init(sm_t *sm) void sm_init(sm_t *sm)
{ {
sm->state = SM_BOOTSTRAP_STATE; sm->state = SM_BOOTSTRAP_STATE;
@@ -76,16 +81,16 @@ static char *sm_status(sm_state_t state)
* Disable login in single user mode and shutdown/reboot * Disable login in single user mode and shutdown/reboot
* *
* Re-enable only when going from these runlevels, this way a user can * Re-enable only when going from these runlevels, this way a user can
* manage /etc/nologin manually within the other runlevels without us * manage FINIT_NOLOGIN_PATH manually within the other runlevels without
* pulling the rug from under their feet. * us pulling the rug from under their feet.
*/ */
static void nologin(void) static void nologin(void)
{ {
if (runlevel == 1 || runlevel == 0 || runlevel == 6) if (runlevel == 1 || runlevel == 0 || runlevel == 6)
touch("/etc/nologin"); touch(FINIT_NOLOGIN_PATH);
if (prevlevel == 1 || prevlevel == 0 || prevlevel == 6) if (prevlevel == 1 || prevlevel == 0 || prevlevel == 6)
erase("/etc/nologin"); erase(FINIT_NOLOGIN_PATH);
} }
void sm_set_runlevel(sm_t *sm, int newlevel) void sm_set_runlevel(sm_t *sm, int newlevel)