Fix ordering of UTMP events: reboot, then runlevel

This patch fixes the ordering of UTMP events. The first event that is
expected in /var/run/utmp is reboot, next is the runlevel change to
the configured runlevel, e.g. from S --> 2.

Let the bootmisc plugin handle this, it knows when /var/run/utmp has
been created and is writable.  It is not the eact boot time, but close
enough for most usees.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2016-08-09 00:12:47 +02:00
parent addc21bdf6
commit f8def336d4
3 changed files with 5 additions and 8 deletions
-3
View File
@@ -270,9 +270,6 @@ int main(int argc, char* argv[])
mount("tmpfs", "/run", "tmpfs", MS_NODEV, "mode=0755,size=10%");
umask(022);
/* Set BOOT_TIME UTMP entry */
utmp_set_boot();
/*
* Parse kernel parameters
*/
+3 -5
View File
@@ -22,21 +22,19 @@
*/
#include <string.h>
#include <utmp.h>
#include <lite/lite.h>
#include "../config.h"
#include "../finit.h"
#include "../helpers.h"
#include "../plugin.h"
#include "../utmp-api.h"
/*
* Setup standard FHS 2.3 structure in /var, and write runlevel to UTMP
*/
static void setup(void *UNUSED(arg))
{
struct utmp entry;
_d("Setting up FHS structure in /var ...");
makedir("/var/cache", 0755);
makedir("/var/games", 0755);
@@ -77,8 +75,8 @@ static void setup(void *UNUSED(arg))
chmod("/var/log/lastlog", 0664);
chown("/var/log/lastlog", 0, getgroup("utmp"));
_d("Setting initial runlevel 'S', bootstrap ...");
runlevel_set(0, 0); /* Bootstrap 'S' */
/* Set BOOT_TIME UTMP entry */
utmp_set_boot();
#ifdef TOUCH_ETC_NETWORK_RUN_IFSTATE
touch("/etc/network/run/ifstate");
+2
View File
@@ -55,6 +55,8 @@ int utmp_set(int type, int pid, char *user, char *line, char *id)
ut.ut_tv.tv_sec = time(NULL);
setutent();
while (getutent())
;
result = pututline(&ut) ? 0 : 1;;
endutent();