-/* $OpenBSD: date.c,v 1.2 1996/06/23 14:19:42 deraadt Exp $ */
+/* $OpenBSD: date.c,v 1.3 1997/04/04 08:59:38 deraadt Exp $ */
/* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */
/*
#if 0
static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: date.c,v 1.2 1996/06/23 14:19:42 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: date.c,v 1.3 1997/04/04 08:59:38 deraadt Exp $";
#endif
#endif /* not lint */
#include <locale.h>
#include <syslog.h>
#include <unistd.h>
+#include <util.h>
#include "extern.h"
static void badformat __P((void));
static void usage __P((void));
-int logwtmp __P((char *, char *, char *));
-
int
main(argc, argv)
int argc;
-.\" $OpenBSD: rdate.8,v 1.4 1996/04/21 23:41:41 deraadt Exp $
+.\" $OpenBSD: rdate.8,v 1.5 1997/04/04 08:59:40 deraadt Exp $
.\" $NetBSD: rdate.8,v 1.4 1996/04/08 20:55:17 jtc Exp $
.\"
.\" Copyright (c) 1994 Christos Zoulas
.Xr adjtime 2
call to gradually skew the local time to the
remote time rather than just hopping.
+.Sh FILES
+.Bl -tag -width /var/log/wtmp -compact
+.It Pa /var/log/wtmp
+A record of date resets and time changes.
.Sh SEE ALSO
.Xr inetd 1 ,
-.Xr adjtime 2
+.Xr adjtime 2 ,
+.Xr gettimeofday 2
-/* $OpenBSD: rdate.c,v 1.8 1997/02/06 15:00:27 kstailey Exp $ */
+/* $OpenBSD: rdate.c,v 1.9 1997/04/04 08:59:41 deraadt Exp $ */
/* $NetBSD: rdate.c,v 1.4 1996/03/16 12:37:45 pk Exp $ */
/*
#if 0
from: static char rcsid[] = "$NetBSD: rdate.c,v 1.3 1996/02/22 06:59:18 thorpej Exp $";
#else
-static char rcsid[] = "$OpenBSD: rdate.c,v 1.8 1997/02/06 15:00:27 kstailey Exp $";
+static char rcsid[] = "$OpenBSD: rdate.c,v 1.9 1997/04/04 08:59:41 deraadt Exp $";
#endif
#endif /* lint */
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
+#include <util.h>
#include <time.h>
/* seconds from midnight Jan 1900 - 1970 */
tim = ntohl(tim) - DIFFERENCE;
if (!pr) {
- struct timeval tv;
- if (!slidetime) {
- tv.tv_sec = tim;
- tv.tv_usec = 0;
- if (settimeofday(&tv, NULL) == -1)
- err(1, "Could not set time of day");
- } else {
- struct timeval tv_current;
- if (gettimeofday(&tv_current, NULL) == -1)
- err(1, "Could not get local time of day");
- adjustment = tv.tv_sec = tim - tv_current.tv_sec;
- tv.tv_usec = 0;
- if (adjtime(&tv, NULL) == -1)
- err(1, "Could not adjust time of day");
- }
+ struct timeval tv;
+ if (!slidetime) {
+ logwtmp("|", "date", "");
+ tv.tv_sec = tim;
+ tv.tv_usec = 0;
+ if (settimeofday(&tv, NULL) == -1)
+ err(1, "Could not set time of day");
+ logwtmp("{", "date", "");
+ } else {
+ struct timeval tv_current;
+ if (gettimeofday(&tv_current, NULL) == -1)
+ err(1, "Could not get local time of day");
+ adjustment = tv.tv_sec = tim - tv_current.tv_sec;
+ tv.tv_usec = 0;
+ if (adjtime(&tv, NULL) == -1)
+ err(1, "Could not adjust time of day");
+ }
}
if (!silent) {
(void) fputs(buf, stdout);
if (slidetime)
- (void) fprintf(stdout,
- "%s: adjust local clock by %d seconds\n",
- __progname, adjustment);
+ (void) fprintf(stdout,
+ "%s: adjust local clock by %d seconds\n",
+ __progname, adjustment);
}
return 0;
}