summaryrefslogtreecommitdiffstats
path: root/usr.sbin/rdate
diff options
context:
space:
mode:
authorjakob <jakob@openbsd.org>2002-07-27 20:11:34 +0000
committerjakob <jakob@openbsd.org>2002-07-27 20:11:34 +0000
commit7c4658522ba6ecf2349efaf2c7a4472ddb79340f (patch)
tree5c96de66045e906466614a00a376899b50540eb8 /usr.sbin/rdate
parentFix art link, PR #2840 (diff)
downloadwireguard-openbsd-7c4658522ba6ecf2349efaf2c7a4472ddb79340f.tar.xz
wireguard-openbsd-7c4658522ba6ecf2349efaf2c7a4472ddb79340f.zip
move leap seconds correction to -N option for now
Diffstat (limited to 'usr.sbin/rdate')
-rw-r--r--usr.sbin/rdate/ntp.c9
-rw-r--r--usr.sbin/rdate/rdate.86
-rw-r--r--usr.sbin/rdate/rdate.c14
3 files changed, 20 insertions, 9 deletions
diff --git a/usr.sbin/rdate/ntp.c b/usr.sbin/rdate/ntp.c
index 3ddc3f6cbe3..1ff3a9c0e76 100644
--- a/usr.sbin/rdate/ntp.c
+++ b/usr.sbin/rdate/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.8 2002/07/27 08:47:19 jakob Exp $ */
+/* $OpenBSD: ntp.c,v 1.9 2002/07/27 20:11:34 jakob Exp $ */
/*
* Copyright (c) 1996, 1997 by N.M. Maclaren. All rights reserved.
@@ -111,6 +111,8 @@ void unpack_ntp(struct ntp_data *, u_char *, int);
double current_time(double);
void create_timeval(double, struct timeval *, struct timeval *);
+int corrleaps = 0;
+
void
ntp_client(const char *hostname, struct timeval *new, struct timeval *adjust)
{
@@ -127,8 +129,6 @@ ntp_client(const char *hostname, struct timeval *new, struct timeval *adjust)
/*NOTREACHED*/
}
- ntpleaps_init();
-
s = -1;
for (res = res0; res; res = res->ai_next) {
s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
@@ -449,7 +449,8 @@ current_time(double offset)
*/
t = NTPLEAPS_OFFSET + (u_int64_t) current.tv_sec;
- ntpleaps_sub(&t);
+ if (corrleaps)
+ ntpleaps_sub(&t);
return offset + ( t - NTPLEAPS_OFFSET ) + 1.0e-6 * current.tv_usec;
}
diff --git a/usr.sbin/rdate/rdate.8 b/usr.sbin/rdate/rdate.8
index f9052c2991e..f03a8851362 100644
--- a/usr.sbin/rdate/rdate.8
+++ b/usr.sbin/rdate/rdate.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rdate.8,v 1.17 2002/07/27 09:29:50 jakob Exp $
+.\" $OpenBSD: rdate.8,v 1.18 2002/07/27 20:11:34 jakob Exp $
.\" $NetBSD: rdate.8,v 1.4 1996/04/08 20:55:17 jtc Exp $
.\"
.\" Copyright (c) 1994 Christos Zoulas
@@ -37,7 +37,7 @@
.Nd set the system's date from a remote host
.Sh SYNOPSIS
.Nm rdate
-.Op Fl npsav
+.Op Fl nNpsav
.Ar host
.Sh DESCRIPTION
.Nm
@@ -55,6 +55,8 @@ The options are as follows:
.Bl -tag -width Ds
.It Fl n
Use SNTP (RFC1361) instead of the RFC868 time protocol.
+.It Fl N
+Use SNTP (RFC1361) instead of the RFC868 time protocol and correct leap seconds.
.It Fl p
Do not set, just print the remote time.
.It Fl s
diff --git a/usr.sbin/rdate/rdate.c b/usr.sbin/rdate/rdate.c
index 241e4fd29fe..e7d92bbf715 100644
--- a/usr.sbin/rdate/rdate.c
+++ b/usr.sbin/rdate/rdate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rdate.c,v 1.16 2002/07/27 09:29:50 jakob Exp $ */
+/* $OpenBSD: rdate.c,v 1.17 2002/07/27 20:11:34 jakob Exp $ */
/* $NetBSD: rdate.c,v 1.4 1996/03/16 12:37:45 pk Exp $ */
/*
@@ -42,7 +42,7 @@
#if 0
from: static char rcsid[] = "$NetBSD: rdate.c,v 1.3 1996/02/22 06:59:18 thorpej Exp $";
#else
-static const char rcsid[] = "$OpenBSD: rdate.c,v 1.16 2002/07/27 09:29:50 jakob Exp $";
+static const char rcsid[] = "$OpenBSD: rdate.c,v 1.17 2002/07/27 20:11:34 jakob Exp $";
#endif
#endif /* lint */
@@ -61,12 +61,14 @@ void rfc868time_client (const char *, struct timeval *, struct timeval *);
void ntp_client (const char *, struct timeval *, struct timeval *);
extern char *__progname;
+extern int corrleaps;
void
usage()
{
(void) fprintf(stderr, "Usage: %s [-npsa] host\n", __progname);
(void) fprintf(stderr, " -n: use SNTP instead of RFC868 time protocol\n");
+ (void) fprintf(stderr, " -N: use SNTP and correct leap seconds\n");
(void) fprintf(stderr, " -p: just print, don't set\n");
(void) fprintf(stderr, " -s: just set, don't print\n");
(void) fprintf(stderr, " -a: use adjtime instead of instant change\n");
@@ -84,7 +86,7 @@ main(int argc, char **argv)
struct timeval new, adjust;
- while ((c = getopt(argc, argv, "psanv")) != -1)
+ while ((c = getopt(argc, argv, "psanNv")) != -1)
switch (c) {
case 'p':
pr++;
@@ -100,6 +102,12 @@ main(int argc, char **argv)
case 'n':
ntp++;
+ corrleaps = 0;
+ break;
+
+ case 'N':
+ ntp++;
+ corrleaps = 1;
break;
case 'v':