From 9b796f4419d32ef4fe0b5348d4e03f367765d526 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sat, 5 Dec 2009 20:09:50 +0000 Subject: [PATCH] Let date(1) use utmpx instead of logwtmp(). utmpx also has OLD_TIME/NEW_TIME messages, which seem to be intended for the same purpose as how we call logwtmp() here. --- bin/date/Makefile | 4 ++-- bin/date/date.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/date/Makefile b/bin/date/Makefile index 8a1dc8579330..b466e1d3b3a3 100644 --- a/bin/date/Makefile +++ b/bin/date/Makefile @@ -3,7 +3,7 @@ PROG= date SRCS= date.c netdate.c vary.c -DPADD= ${LIBUTIL} -LDADD= -lutil +DPADD= ${LIBULOG} +LDADD= -lulog .include diff --git a/bin/date/date.c b/bin/date/date.c index 578229eb4308..c980b99d3d2a 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -48,11 +48,12 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include #include +#define _ULOG_POSIX_NAMES +#include #include #include "extern.h" @@ -181,6 +182,7 @@ main(int argc, char *argv[]) static void setthetime(const char *fmt, const char *p, int jflag, int nflag) { + struct utmpx utx; struct tm *lt; struct timeval tv; const char *dot, *t; @@ -271,12 +273,16 @@ setthetime(const char *fmt, const char *p, int jflag, int nflag) if (!jflag) { /* set the time */ if (nflag || netsettime(tval)) { - logwtmp("|", "date", ""); + utx.ut_type = OLD_TIME; + gettimeofday(&utx.ut_tv, NULL); + pututxline(&utx); tv.tv_sec = tval; tv.tv_usec = 0; if (settimeofday(&tv, (struct timezone *)NULL)) err(1, "settimeofday (timeval)"); - logwtmp("{", "date", ""); + utx.ut_type = NEW_TIME; + gettimeofday(&utx.ut_tv, NULL); + pututxline(&utx); } if ((p = getlogin()) == NULL)