mirror of
https://github.com/troglobit/finit.git
synced 2026-10-03 22:43:08 +07:00
Set correct initial bootstrap runlevel 'S'
This patch corrects a long standing issue with Finit. System initial bootstrap runlevel must be set to 'S' (0), not the configured fallback runlevel 'RUNLEVEL', which likely is '2'. Also, minor cleanup, reduce code duplication. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -49,6 +49,7 @@ void runlevel_set(int pre, int now)
|
||||
{
|
||||
struct utmp utent;
|
||||
|
||||
memset(&utent, 0, sizeof(utent));
|
||||
utent.ut_type = RUN_LVL;
|
||||
utent.ut_pid = (encode(pre) << 8) | (encode(now) & 0xFF);
|
||||
strlcpy(utent.ut_user, "runlevel", sizeof(utent.ut_user));
|
||||
|
||||
+5
-14
@@ -1,6 +1,6 @@
|
||||
/* Setup necessary files for UTMP, tracking logins
|
||||
/* Setup necessary system files for, e.g. UTMP (tracking logins)
|
||||
*
|
||||
* Copyright (c) 2012 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2012-2016 Joachim Nilsson <troglobit@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -31,14 +31,11 @@
|
||||
#include "lite/lite.h"
|
||||
|
||||
/*
|
||||
* Setup standard FHS 2.3 structure in /var, and
|
||||
* write runlevel to UTMP, needed by, e.g., printerdrake.
|
||||
* Setup standard FHS 2.3 structure in /var, and write runlevel to UTMP
|
||||
*/
|
||||
static void setup(void *UNUSED(arg))
|
||||
{
|
||||
#ifdef RUNLEVEL
|
||||
struct utmp entry;
|
||||
#endif
|
||||
|
||||
_d("Setting up FHS structure in /var ...");
|
||||
makedir("/var/cache", 0755);
|
||||
@@ -62,14 +59,8 @@ static void setup(void *UNUSED(arg))
|
||||
touch("/var/run/utmp");
|
||||
chown("/var/run/utmp", 0, getgroup("utmp"));
|
||||
|
||||
#ifdef RUNLEVEL
|
||||
memset(&entry, 0, sizeof(struct utmp));
|
||||
entry.ut_type = RUN_LVL;
|
||||
entry.ut_pid = '0' + RUNLEVEL;
|
||||
setutent();
|
||||
pututline(&entry);
|
||||
endutent();
|
||||
#endif
|
||||
_d("Setting initial runlevel 'S', bootstrap ...");
|
||||
runlevel_set(0, 0); /* Bootstrap 'S' */
|
||||
|
||||
#ifdef TOUCH_ETC_NETWORK_RUN_IFSTATE
|
||||
touch("/etc/network/run/ifstate");
|
||||
|
||||
Reference in New Issue
Block a user