Theo de Raadt <[email protected]> wrote:
> It might be time to remove the -o support entirely.
> ntp servers are everywhere, and inetd has gone away.
Which looks like this.
The -o option goes away. The -n option must remain as a no-op,
probably forever because people have gotten used to using it.
Index: Makefile
===================================================================
RCS file: /cvs/src/usr.sbin/rdate/Makefile,v
diff -u -p -u -r1.7 Makefile
--- Makefile 20 Nov 2003 23:23:09 -0000 1.7
+++ Makefile 26 Mar 2026 01:08:31 -0000
@@ -1,7 +1,7 @@
# $OpenBSD: Makefile,v 1.7 2003/11/20 23:23:09 avsm Exp $
PROG= rdate
-SRCS= rdate.c rfc868time.c ntp.c ntpleaps.c
+SRCS= rdate.c ntp.c ntpleaps.c
CFLAGS+=-Wall
DPADD+= ${LIBUTIL}
LDADD+= -lutil
Index: rdate.8
===================================================================
RCS file: /cvs/src/usr.sbin/rdate/rdate.8,v
diff -u -p -u -r1.40 rdate.8
--- rdate.8 12 Nov 2023 18:53:22 -0000 1.40
+++ rdate.8 26 Mar 2026 01:10:44 -0000
@@ -32,19 +32,13 @@
.Nd set the system's date from a remote host
.Sh SYNOPSIS
.Nm rdate
-.Op Fl 46acnopsv
+.Op Fl 46acnpsv
.Ar host
.Sh DESCRIPTION
.Nm
displays and sets the local date and time from the
host name or address given as the argument.
-The time source may be an RFC 5905 protocol SNTP/NTP server
-or an RFC 868 TCP protocol server,
-which is usually implemented as a built-in service of
-.Xr inetd 8 .
-By default,
-.Nm
-uses the RFC 5905 SNTP/NTP protocol.
+The time source is an RFC 5905 protocol SNTP/NTP server.
.Pp
The options are as follows:
.Bl -tag -width Ds
@@ -66,14 +60,10 @@ Correct leap seconds.
This should be used only when synchronizing to a server
which does not correctly account for leap seconds.
.It Fl n
-Use SNTP (RFC 5905) instead of the RFC 868 time protocol.
+Use SNTP (RFC 5905).
This is the default.
This protocol counts 32 bits of seconds from January 1, 1900
and will handle rollover to a new NTP era in February 2036.
-.It Fl o
-Use an RFC 868 TCP protocol server instead of SNTP.
-This protocol is obsolete as it is not capable of representing
-dates past January 19, 2038 03:14:07 GMT.
.It Fl p
Do not set, just print the remote time.
.It Fl s
Index: rdate.c
===================================================================
RCS file: /cvs/src/usr.sbin/rdate/rdate.c,v
diff -u -p -u -r1.37 rdate.c
--- rdate.c 4 Jan 2023 13:00:11 -0000 1.37
+++ rdate.c 26 Mar 2026 01:11:39 -0000
@@ -52,7 +52,6 @@
#define logwtmp(a,b,c)
#endif
-void rfc868time_client(const char *, int, struct timeval *, struct timeval *,
int);
void ntp_client(const char *, int, struct timeval *, struct timeval *, int);
extern char *__progname;
@@ -67,14 +66,14 @@ struct {
__dead void
usage(void)
{
- (void) fprintf(stderr, "usage: %s [-46acnopsv] host\n", __progname);
+ (void) fprintf(stderr, "usage: %s [-46acnpsv] host\n", __progname);
exit(1);
}
int
main(int argc, char **argv)
{
- int pr = 0, silent = 0, ntp = 1, verbose = 0;
+ int pr = 0, silent = 0, verbose = 0;
int slidetime = 0, corrleaps = 0;
char *hname;
int c, p[2], pid;
@@ -103,11 +102,7 @@ main(int argc, char **argv)
break;
case 'n':
- ntp = 1;
- break;
-
- case 'o':
- ntp = 0;
+ /* noop */
break;
case 'c':
@@ -149,12 +144,8 @@ main(int argc, char **argv)
setvbuf(stdout, NULL, _IOFBF, 0);
setvbuf(stderr, NULL, _IOFBF, 0);
- if (ntp)
- ntp_client(hname, family, &pdata.new,
- &pdata.adjust, corrleaps);
- else
- rfc868time_client(hname, family, &pdata.new,
- &pdata.adjust, corrleaps);
+ ntp_client(hname, family, &pdata.new,
+ &pdata.adjust, corrleaps);
if (write(STDOUT_FILENO, &pdata, sizeof pdata) != sizeof pdata)
exit(1);
@@ -207,14 +198,9 @@ main(int argc, char **argv)
adjsec = pdata.adjust.tv_sec + pdata.adjust.tv_usec / 1.0e6;
if (slidetime || verbose) {
- if (ntp)
- (void) fprintf(stdout,
- "%s: adjust local clock by %.6f seconds\n",
- __progname, adjsec);
- else
- (void) fprintf(stdout,
- "%s: adjust local clock by %lld seconds\n",
- __progname, (long long)pdata.adjust.tv_sec);
+ (void) fprintf(stdout,
+ "%s: adjust local clock by %.6f seconds\n",
+ __progname, adjsec);
}
}
Index: rfc868time.c
===================================================================
RCS file: rfc868time.c
diff -N rfc868time.c
--- rfc868time.c 4 Jan 2023 13:00:11 -0000 1.13
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,119 +0,0 @@
-/* $OpenBSD: rfc868time.c,v 1.13 2023/01/04 13:00:11 jsg Exp $ */
-/* $NetBSD: rdate.c,v 1.4 1996/03/16 12:37:45 pk Exp $ */
-
-/*
- * Copyright (c) 1994 Christos Zoulas
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * rdate.c: Set the date from the specified host
- *
- * Uses the rfc868 time protocol at socket 37 (tcp).
- * Time is returned as the number of seconds since
- * midnight January 1st 1900.
- */
-
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-
-#include <stdio.h>
-#include <ctype.h>
-#include <err.h>
-#include <string.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <time.h>
-
-/* Obviously it is not just for SNTP clients... */
-#include "ntpleaps.h"
-
-/* seconds from midnight Jan 1900 - 1970 */
-#define DIFFERENCE 2208988800UL
-
-void
-rfc868time_client(const char *hostname, int family, struct timeval *new,
- struct timeval *adjust, int leapflag);
-
-
-void
-rfc868time_client(const char *hostname, int family, struct timeval *new,
- struct timeval *adjust, int leapflag)
-{
- struct addrinfo hints, *res0, *res;
- struct timeval old;
- u_int32_t tim; /* RFC 868 states clearly this is an uint32 */
- int s;
- int error;
- u_int64_t td;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = family;
- hints.ai_socktype = SOCK_STREAM;
- error = getaddrinfo(hostname, "time", &hints, &res0);
- if (error) {
- errx(1, "%s: %s", hostname, gai_strerror(error));
- /*NOTREACHED*/
- }
-
- if (pledge("stdio inet", NULL) == -1)
- err(1, "pledge");
-
- s = -1;
- for (res = res0; res; res = res->ai_next) {
- s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
- if (s == -1)
- continue;
-
- if (connect(s, res->ai_addr, res->ai_addrlen) == -1) {
- close(s);
- s = -1;
- continue;
- }
-
- break;
- }
- if (s == -1)
- err(1, "Could not connect socket");
- freeaddrinfo(res0);
-
- if (read(s, &tim, sizeof(tim)) != sizeof(tim))
- err(1, "Could not read data");
-
- (void) close(s);
- tim = ntohl(tim) - DIFFERENCE;
-
- if (gettimeofday(&old, NULL) == -1)
- err(1, "Could not get local time of day");
-
- td = SEC_TO_TAI64(old.tv_sec);
- if (leapflag)
- ntpleaps_sub(&td);
-
- adjust->tv_sec = tim - TAI64_TO_SEC(td);
- adjust->tv_usec = 0;
-
- new->tv_sec = old.tv_sec + adjust->tv_sec;
- new->tv_usec = 0;
-}