Write runlevel to utmp

This is needed by Printerdrake (by Pascal Terjan)

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
Claudio Matsuoka
2008-05-28 12:51:30 -03:00
parent 698c5a1852
commit f94504ad96
3 changed files with 16 additions and 3 deletions
+1
View File
@@ -1,5 +1,6 @@
0.5 ()
- finit-alt listens to /dev/initctl to work with reboot(8)
- write runlevel to utmp, needed by Printerdrake (by Pascal Terjan)
O.4 (20080516)
- default username for finit-alt configurable in Makefile
-3
View File
@@ -30,9 +30,6 @@ CFLAGS += -march=pentium-m
# Use built-in run-parts instead of /bin/run-parts
CFLAGS += -DBUILTIN_RUNPARTS
# Listen to /dev/initctl to handle reboot requests
CFLAGS += -DLISTEN_INITCTL
#### End of configurable parameters
+15
View File
@@ -37,6 +37,7 @@ THE SOFTWARE.
#include <sys/reboot.h>
#include <sys/wait.h>
#include <linux/fs.h>
#include <utmp.h>
#include "helpers.h"
@@ -54,6 +55,8 @@ THE SOFTWARE.
#define REMOUNT_ROOTFS_RW
#define MAKE_DEVICES
#define PAM_CONSOLE
#define LISTEN_INITCTL
#define RUNLEVEL 5
#else /* original Eeepc distribution */
#define RANDOMSEED "/var/lib/urandom/random-seed"
#define SYSROOT "/mnt"
@@ -145,6 +148,9 @@ int main()
struct init_request req;
struct timespec timeout;
#endif
#ifdef RUNLEVEL
struct utmp entry;
#endif
puts("finit-alt " VERSION " (built " __DATE__ " by " WHOAMI ")");
@@ -304,6 +310,15 @@ int main()
}
touch("/var/run/utmp");
#ifdef RUNLEVEL
memset(&entry, 0, sizeof(struct utmp));
entry.ut_type = RUN_LVL;
entry.ut_pid = '0' + RUNLEVEL;
setutent();
pututline(&entry);
endutent();
#endif
touch("/etc/resolvconf/run/enable-updates");
chdir("/etc/resolvconf/run/interface");