diff options
author | ed <ed@FreeBSD.org> | 2009-12-05 20:26:55 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-12-05 20:26:55 +0000 |
commit | 171b5b95537d583c86570cab90a397c555bbf272 (patch) | |
tree | d0ee711ca12aea5c3b84fcace77f514d74e6e803 /sbin/init | |
parent | 84b72ef5098611dca55f69c69591e7491244c45e (diff) | |
download | FreeBSD-src-171b5b95537d583c86570cab90a397c555bbf272.zip FreeBSD-src-171b5b95537d583c86570cab90a397c555bbf272.tar.gz |
Let init(8) and reboot(8) use utmpx to log wtmp entries.
logwtmp() gets called with the raw strings that are written to disk. For
regular user entries, this isn't too bad, but when booting/shutting
down, the contents get rather cryptic.
Just call the standardized pututxline().
Diffstat (limited to 'sbin/init')
-rw-r--r-- | sbin/init/Makefile | 4 | ||||
-rw-r--r-- | sbin/init/init.c | 16 |
2 files changed, 13 insertions, 7 deletions
diff --git a/sbin/init/Makefile b/sbin/init/Makefile index 7497a4b..7778c71 100644 --- a/sbin/init/Makefile +++ b/sbin/init/Makefile @@ -6,8 +6,8 @@ MAN= init.8 PRECIOUSPROG= INSTALLFLAGS=-b -B.bak CFLAGS+=-DDEBUGSHELL -DSECURE -DLOGIN_CAP -DCOMPAT_SYSV_INIT -DPADD= ${LIBUTIL} ${LIBCRYPT} -LDADD= -lutil -lcrypt +DPADD= ${LIBUTIL} ${LIBULOG} ${LIBCRYPT} +LDADD= -lutil -lulog -lcrypt NO_SHARED?= YES diff --git a/sbin/init/init.c b/sbin/init/init.c index 8629b90..58e6739 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -65,6 +65,8 @@ static const char rcsid[] = #include <syslog.h> #include <time.h> #include <ttyent.h> +#define _ULOG_POSIX_NAMES +#include <ulog.h> #include <unistd.h> #include <sys/reboot.h> #include <err.h> @@ -569,10 +571,8 @@ transition(state_t s) static void clear_session_logs(session_t *sp) { - char *line = sp->se_device + sizeof(_PATH_DEV) - 1; - if (logout(line)) - logwtmp(line, "", ""); + ulog_logout(sp->se_device); } /* @@ -775,6 +775,7 @@ single_user(void) static state_func_t runcom(void) { + struct utmpx utx; state_func_t next_transition; if ((next_transition = run_script(_PATH_RUNCOM)) != 0) @@ -782,7 +783,9 @@ runcom(void) runcom_mode = AUTOBOOT; /* the default */ /* NB: should send a message to the session logger to avoid blocking. */ - logwtmp("~", "reboot", ""); + utx.ut_type = BOOT_TIME; + gettimeofday(&utx.ut_tv, NULL); + pututxline(&utx); return (state_func_t) read_ttys; } @@ -1487,13 +1490,16 @@ alrm_handler(int sig) static state_func_t death(void) { + struct utmpx utx; session_t *sp; int i; pid_t pid; static const int death_sigs[2] = { SIGTERM, SIGKILL }; /* NB: should send a message to the session logger to avoid blocking. */ - logwtmp("~", "shutdown", ""); + utx.ut_type = SHUTDOWN_TIME; + gettimeofday(&utx.ut_tv, NULL); + pututxline(&utx); /* * Also revoke the TTY here. Because runshutdown() may reopen |