summaryrefslogtreecommitdiffstats
path: root/sbin/reboot
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-12-05 20:26:55 +0000
committered <ed@FreeBSD.org>2009-12-05 20:26:55 +0000
commit171b5b95537d583c86570cab90a397c555bbf272 (patch)
treed0ee711ca12aea5c3b84fcace77f514d74e6e803 /sbin/reboot
parent84b72ef5098611dca55f69c69591e7491244c45e (diff)
downloadFreeBSD-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/reboot')
-rw-r--r--sbin/reboot/Makefile4
-rw-r--r--sbin/reboot/reboot.c9
2 files changed, 9 insertions, 4 deletions
diff --git a/sbin/reboot/Makefile b/sbin/reboot/Makefile
index fe02f26..2a2f6f1 100644
--- a/sbin/reboot/Makefile
+++ b/sbin/reboot/Makefile
@@ -2,8 +2,8 @@
# $FreeBSD$
PROG= reboot
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+DPADD= ${LIBULOG}
+LDADD= -lulog
MAN= reboot.8 nextboot.8
MLINKS= reboot.8 halt.8 reboot.8 fastboot.8 reboot.8 fasthalt.8
diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c
index cae709f..0a9ac51 100644
--- a/sbin/reboot/reboot.c
+++ b/sbin/reboot/reboot.c
@@ -42,18 +42,20 @@ static char sccsid[] = "@(#)reboot.c 8.1 (Berkeley) 6/5/93";
__FBSDID("$FreeBSD$");
#include <sys/reboot.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <signal.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
-#include <libutil.h>
#include <pwd.h>
#include <syslog.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#define _ULOG_POSIX_NAMES
+#include <ulog.h>
#include <unistd.h>
static void usage(void);
@@ -64,6 +66,7 @@ int dohalt;
int
main(int argc, char *argv[])
{
+ struct utmpx utx;
const struct passwd *pw;
int ch, howto, i, fd, lflag, nflag, qflag, sverrno;
u_int pageins;
@@ -140,7 +143,9 @@ main(int argc, char *argv[])
syslog(LOG_CRIT, "rebooted by %s", user);
}
}
- logwtmp("~", "shutdown", "");
+ utx.ut_type = SHUTDOWN_TIME;
+ gettimeofday(&utx.ut_tv, NULL);
+ pututxline(&utx);
/*
* Do a sync early on, so disks start transfers while we're off
OpenPOWER on IntegriCloud