mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-28 11:12:46 +00:00
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.
This commit is contained in:
parent
bd76376f80
commit
9b796f4419
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=200157
@ -3,7 +3,7 @@
|
||||
|
||||
PROG= date
|
||||
SRCS= date.c netdate.c vary.c
|
||||
DPADD= ${LIBUTIL}
|
||||
LDADD= -lutil
|
||||
DPADD= ${LIBULOG}
|
||||
LDADD= -lulog
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -48,11 +48,12 @@ __FBSDID("$FreeBSD$");
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <locale.h>
|
||||
#include <libutil.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#define _ULOG_POSIX_NAMES
|
||||
#include <ulog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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)
|
||||
|
Loading…
Reference in New Issue
Block a user