1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-03 06:04:53 +00:00

After a long hiatus, update to 5.7p1.

Major user-visible changes:
* Added ntpctl(8), which allows for querying ntpd(8) at runtime.
* Added support for different routing tables.
This commit is contained in:
Christian Weisgerber 2015-01-08 16:11:29 +00:00
parent 1d5c7e9284
commit 6762458c89
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=376542
15 changed files with 37 additions and 509 deletions

View File

@ -1,36 +1,31 @@
# $FreeBSD$
PORTNAME= openntpd
PORTVERSION= 4.6
PORTREVISION= 3
PORTVERSION= 5.7p1
PORTEPOCH= 2
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_OPENBSD}
MASTER_SITE_SUBDIR= OpenNTPD
EXTRACT_SUFX= .tgz
MAINTAINER= naddy@FreeBSD.org
COMMENT= OpenBSD's Network Time Protocol daemon
COMMENT= Network Time Protocol (NTP) daemon
LICENSE= ISCL
USERS= _ntp
GROUPS= _ntp
USE_RC_SUBR= openntpd
WRKSRC= ${WRKDIR}/ntpd
post-extract:
@${CP} ${FILESDIR}/compat.h ${FILESDIR}/adjfreq.c ${WRKSRC}
GNU_CONFIGURE= yes
CONFIGURE_ARGS= --localstatedir=/var \
--disable-silent-rules
pre-build:
${REINPLACE_CMD} -e 's,%%PREFIX%%,${PREFIX},g' \
${WRKSRC}/ntpd.h ${WRKSRC}/ntpd.conf.5 ${WRKSRC}/ntpd.8
${WRKSRC}/ntpd.conf.5 ${WRKSRC}/ntpd.8
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/ntpd ${STAGEDIR}${PREFIX}/sbin
${INSTALL_MAN} ${WRKSRC}/ntpd.conf.5 ${STAGEDIR}${PREFIX}/man/man5
${INSTALL_MAN} ${WRKSRC}/ntpd.8 ${STAGEDIR}${PREFIX}/man/man8
${INSTALL_DATA} ${FILESDIR}/ntpd.conf \
${STAGEDIR}${PREFIX}/etc/ntpd.conf.sample
post-install:
cd ${STAGEDIR}${PREFIX}/etc; ${MV} ntpd.conf ntpd.conf.sample
.include <bsd.port.mk>

View File

@ -1,2 +1,2 @@
SHA256 (openntpd-4.6.tgz) = 724164736f8489a64aedfbc5f8fceaa5eef69c9b8cb26c75a711cfa1b6bab6d7
SIZE (openntpd-4.6.tgz) = 30472
SHA256 (openntpd-5.7p1.tar.gz) = 071cfdcfc179c481568a2b8262945243a3123abfc7fa8831da1bbff3729b8307
SIZE (openntpd-5.7p1.tar.gz) = 400113

View File

@ -1,30 +0,0 @@
/*
* This file is in the public domain.
*
* $FreeBSD$
*/
#include <sys/types.h>
#include <sys/timex.h>
#include "ntpd.h"
int
adjfreq(const int64_t *freq, int64_t *oldfreq)
{
struct timex t;
if (oldfreq) {
t.modes = 0;
if (ntp_adjtime(&t) == -1)
return -1;
*oldfreq = (int64_t)t.freq * (1<<16) * 1000;
}
if (freq) {
t.modes = MOD_FREQUENCY;
t.freq = *freq / ((1<<16) * 1000);
if (ntp_adjtime(&t) == -1)
return -1;
}
return 0;
}

View File

@ -1,22 +0,0 @@
/*
* This file is in the public domain.
*
* $FreeBSD$
*/
#ifndef SA_LEN
# define SA_LEN(x) ((x)->sa_len)
#endif
#ifndef EAI_NODATA
# define EAI_NODATA EAI_NONAME
#endif
#ifndef __dead
# define __dead
#endif
#undef HAVE_SENSORS
/* adjfreq.c */
int adjfreq(const int64_t *, int64_t *);

View File

@ -1,12 +0,0 @@
# $FreeBSD$
# sample ntpd configuration file, see ntpd.conf(5)
# Addresses to listen on (ntpd does not listen by default)
#listen on *
# sync to a single server
#server ntp.example.org
# use a random selection of NTP Pool Time Servers
# see http://support.ntp.org/bin/view/Servers/NTPPoolServers
servers pool.ntp.org

View File

@ -1,20 +0,0 @@
$FreeBSD$
--- Makefile.orig 2009-06-25 16:14:54.000000000 +0200
+++ Makefile 2013-08-01 17:33:37.000000000 +0200
@@ -2,7 +2,7 @@
PROG= ntpd
SRCS= ntpd.c buffer.c log.c imsg.c ntp.c ntp_msg.c parse.y config.c \
- server.c client.c sensors.c util.c ntp_dns.c
+ server.c client.c util.c ntp_dns.c adjfreq.c
CFLAGS+= -Wall -I${.CURDIR}
CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
CFLAGS+= -Wmissing-declarations
@@ -11,4 +11,7 @@ CFLAGS+= -Wsign-compare
YFLAGS=
MAN= ntpd.8 ntpd.conf.5
+DPADD= ${LIBMD}
+LDADD= -lmd
+
.include <bsd.prog.mk>

View File

@ -1,23 +0,0 @@
$FreeBSD$
--- log.c.orig 2007-08-22 23:04:30.000000000 +0200
+++ log.c 2009-08-01 22:08:01.000000000 +0200
@@ -26,6 +26,10 @@
#include "ntpd.h"
+#ifndef LOG_NTP
+#define LOG_NTP LOG_DAEMON
+#endif
+
int debug;
extern int debugsyslog;
@@ -39,7 +43,7 @@ log_init(int n_debug)
debug = n_debug;
if (!debug)
- openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
+ openlog(__progname, LOG_PID | LOG_NDELAY, LOG_NTP);
tzset();
}

View File

@ -1,220 +0,0 @@
$FreeBSD$
--- ntp.c.orig 2009-11-23 20:47:16.000000000 +0100
+++ ntp.c 2009-11-23 20:55:59.000000000 +0100
@@ -34,9 +34,14 @@
#include "ntpd.h"
#define PFD_PIPE_MAIN 0
+#ifdef HAVE_SENSORS
#define PFD_HOTPLUG 1
#define PFD_PIPE_DNS 2
#define PFD_MAX 3
+#else
+#define PFD_PIPE_DNS 1
+#define PFD_MAX 2
+#endif
volatile sig_atomic_t ntp_quit = 0;
volatile sig_atomic_t ntp_report = 0;
@@ -72,7 +77,10 @@ pid_t
ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf, struct passwd *pw)
{
int a, b, nfds, i, j, idx_peers, timeout;
- int hotplugfd, nullfd, pipe_dns[2];
+#ifdef HAVE_SENSORS
+ int hotplugfd;
+#endif
+ int nullfd, pipe_dns[2];
u_int pfd_elms = 0, idx2peer_elms = 0;
u_int listener_cnt, new_cnt, sent_cnt, trial_cnt;
pid_t pid, dns_pid;
@@ -81,10 +89,15 @@ ntp_main(int pipe_prnt[2], struct ntpd_c
struct listen_addr *la;
struct ntp_peer *p;
struct ntp_peer **idx2peer = NULL;
+#ifdef HAVE_SENSORS
struct ntp_sensor *s, *next_s;
+#endif
struct timespec tp;
struct stat stb;
- time_t nextaction, last_sensor_scan = 0;
+ time_t nextaction;
+#ifdef HAVE_SENSORS
+ time_t last_sensor_scan = 0;
+#endif
void *newp;
switch (pid = fork()) {
@@ -108,7 +121,9 @@ ntp_main(int pipe_prnt[2], struct ntpd_c
if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
fatal(NULL);
+#ifdef HAVE_SENSORS
hotplugfd = sensor_hotplugfd();
+#endif
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_dns) == -1)
fatal("socketpair");
@@ -179,7 +194,9 @@ ntp_main(int pipe_prnt[2], struct ntpd_c
conf->status.precision = a;
conf->scale = 1;
+#ifdef HAVE_SENSORS
sensor_init();
+#endif
log_info("ntp engine ready");
@@ -221,8 +238,10 @@ ntp_main(int pipe_prnt[2], struct ntpd_c
nextaction = getmonotime() + 3600;
pfd[PFD_PIPE_MAIN].fd = ibuf_main->fd;
pfd[PFD_PIPE_MAIN].events = POLLIN;
+#ifdef HAVE_SENSORS
pfd[PFD_HOTPLUG].fd = hotplugfd;
pfd[PFD_HOTPLUG].events = POLLIN;
+#endif
pfd[PFD_PIPE_DNS].fd = ibuf_dns->fd;
pfd[PFD_PIPE_DNS].events = POLLIN;
@@ -278,6 +297,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_c
}
}
+#ifdef HAVE_SENSORS
if (last_sensor_scan == 0 ||
last_sensor_scan + SENSOR_SCAN_INTERVAL < getmonotime()) {
sensors_cnt = sensor_scan();
@@ -286,7 +306,9 @@ ntp_main(int pipe_prnt[2], struct ntpd_c
if (!TAILQ_EMPTY(&conf->ntp_conf_sensors) && sensors_cnt == 0 &&
nextaction > last_sensor_scan + SENSOR_SCAN_INTERVAL)
nextaction = last_sensor_scan + SENSOR_SCAN_INTERVAL;
+#endif
sensors_cnt = 0;
+#ifdef HAVE_SENSORS
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
if (conf->settime && s->offsets[0].offset)
priv_settime(s->offsets[0].offset);
@@ -294,6 +316,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_c
if (s->next > 0 && s->next < nextaction)
nextaction = s->next;
}
+#endif
if (conf->settime &&
((trial_cnt > 0 && sent_cnt == 0) ||
@@ -339,10 +362,12 @@ ntp_main(int pipe_prnt[2], struct ntpd_c
ntp_quit = 1;
}
+#ifdef HAVE_SENSORS
if (nfds > 0 && pfd[PFD_HOTPLUG].revents & (POLLIN|POLLERR)) {
nfds--;
sensor_hotplugevent(hotplugfd);
}
+#endif
for (j = PFD_MAX; nfds > 0 && j < idx_peers; j++)
if (pfd[j].revents & (POLLIN|POLLERR)) {
@@ -359,12 +384,14 @@ ntp_main(int pipe_prnt[2], struct ntpd_c
ntp_quit = 1;
}
+#ifdef HAVE_SENSORS
for (s = TAILQ_FIRST(&conf->ntp_sensors); s != NULL;
s = next_s) {
next_s = TAILQ_NEXT(s, entry);
if (s->next <= getmonotime())
sensor_query(s);
}
+#endif
report_peers(ntp_report);
ntp_report = 0;
}
@@ -574,7 +601,9 @@ int
priv_adjtime(void)
{
struct ntp_peer *p;
+#ifdef HAVE_SENSORS
struct ntp_sensor *s;
+#endif
int offset_cnt = 0, i = 0, j;
struct ntp_offset **offsets;
double offset_median;
@@ -587,11 +616,13 @@ priv_adjtime(void)
offset_cnt += p->weight;
}
+#ifdef HAVE_SENSORS
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
if (!s->update.good)
continue;
offset_cnt += s->weight;
}
+#endif
if (offset_cnt == 0)
return (1);
@@ -606,12 +637,14 @@ priv_adjtime(void)
offsets[i++] = &p->update;
}
+#ifdef HAVE_SENSORS
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
if (!s->update.good)
continue;
for (j = 0; j < s->weight; j++)
offsets[i++] = &s->update;
}
+#endif
qsort(offsets, offset_cnt, sizeof(struct ntp_offset *), offset_compare);
@@ -648,11 +681,13 @@ priv_adjtime(void)
p->reply[i].offset -= offset_median;
p->update.good = 0;
}
+#ifdef HAVE_SENSORS
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
for (i = 0; i < SENSOR_OFFSETS; i++)
s->offsets[i].offset -= offset_median;
s->update.offset -= offset_median;
}
+#endif
return (0);
}
@@ -734,16 +769,20 @@ report_peers(int always)
u_int badpeers = 0;
u_int badsensors = 0;
struct ntp_peer *p;
+#ifdef HAVE_SENSORS
struct ntp_sensor *s;
+#endif
TAILQ_FOREACH(p, &conf->ntp_peers, entry) {
if (p->trustlevel < TRUSTLEVEL_BADPEER)
badpeers++;
}
+#ifdef HAVE_SENSORS
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
if (!s->update.good)
badsensors++;
}
+#endif
now = getmonotime();
if (!always) {
@@ -773,6 +812,7 @@ report_peers(int always)
}
}
}
+#ifdef HAVE_SENSORS
if (sensors_cnt > 0) {
log_warnx("%u out of %u sensors valid",
sensors_cnt - badsensors, sensors_cnt);
@@ -781,4 +821,5 @@ report_peers(int always)
log_warnx("bad sensor %s", s->device);
}
}
+#endif
}

View File

@ -1,17 +1,6 @@
$FreeBSD$
--- ntpd.8.orig 2009-02-12 02:33:37.000000000 +0100
+++ ntpd.8 2009-11-23 21:36:02.000000000 +0100
@@ -29,8 +29,7 @@
.Sh DESCRIPTION
The
.Nm
-daemon synchronizes the local clock to one or more remote NTP servers
-or local timedelta sensors.
+daemon synchronizes the local clock to one or more remote NTP servers.
.Nm
can also act as an NTP server itself,
redistributing the local time.
@@ -52,7 +51,7 @@ Use
--- ntpd.8.orig 2015-01-08 06:57:55 UTC
+++ ntpd.8
@@ -53,7 +53,7 @@ Use
.Ar file
as the configuration file,
instead of the default
@ -20,7 +9,7 @@ $FreeBSD$
.It Fl n
Configtest mode.
Only check the configuration file for validity.
@@ -91,19 +90,19 @@ will be logged.
@@ -96,19 +96,19 @@ will be logged.
After the local clock is synchronized,
.Nm
adjusts the clock frequency using the
@ -32,7 +21,7 @@ $FreeBSD$
is usually started at boot time, and can be enabled by
setting
-.Va ntpd_flags
+.Va openntpd_enable
+.Va openntpd_flags
in
-.Pa /etc/rc.conf.local .
+.Pa /etc/rc.conf .
@ -44,12 +33,8 @@ $FreeBSD$
for more information on the boot process
and enabling daemons.
.Pp
@@ -120,22 +119,22 @@ When
.Nm
receives a
.Dv SIGINFO
-signal, it writes its peer and sensor status to
+signal, it writes its peer status to
@@ -129,8 +129,8 @@ receives a
signal, it writes its peer and sensor status to
.Xr syslog 3 .
.Sh FILES
-.Bl -tag -width "/var/db/ntpd.driftXXX" -compact
@ -59,6 +44,7 @@ $FreeBSD$
Default configuration file.
.It Pa /var/db/ntpd.drift
Drift file.
@@ -140,12 +140,12 @@ Socket file for communication with
.El
.Sh SEE ALSO
.Xr date 1 ,
@ -67,8 +53,9 @@ $FreeBSD$
+.Xr ntp_adjtime 2 ,
.Xr ntpd.conf 5 ,
+.Xr rc.conf 5 ,
.Xr ntpctl 8 ,
.Xr rc 8 ,
-.Xr rc.conf 8 ,
.Xr rdate 8 ,
.Xr timed 8
.Xr rdate 8
.Sh STANDARDS
.Rs

View File

@ -1,23 +1,24 @@
$FreeBSD$
Drift file in ppm for compatibility with reference ntpd.
--- ntpd.c.orig 2009-11-23 20:34:47.000000000 +0100
+++ ntpd.c 2009-11-23 20:36:38.000000000 +0100
@@ -457,7 +457,7 @@ readfreq(void)
--- ntpd.c.orig 2015-01-08 06:57:55 UTC
+++ ntpd.c
@@ -515,7 +515,11 @@ readfreq(void)
log_warn("adjfreq failed");
else if (current == 0) {
if (fscanf(fp, "%le", &d) == 1)
- ntpd_adjfreq(d, 0);
+ /*
+ * Drift file in ppm for compatibility
+ * with reference ntpd.
+ */
+ ntpd_adjfreq(d / 1e6, 0);
else
log_warnx("can't read %s", DRIFTFILE);
}
@@ -480,7 +480,7 @@ writefreq(double d)
@@ -538,7 +542,8 @@ writefreq(double d)
return 0;
}
- fprintf(fp, "%e\n", d);
+ /* Drift file in ppm for compatibility with reference ntpd. */
+ fprintf(fp, "%e\n", d * 1e6);
r = ferror(fp);
if (fclose(fp) != 0 || r != 0) {

View File

@ -1,88 +1,6 @@
$FreeBSD$
--- ntpd.conf.5.orig 2009-11-23 21:03:30.000000000 +0100
+++ ntpd.conf.5 2009-11-23 21:12:27.000000000 +0100
@@ -59,62 +59,6 @@ or
listen on 127.0.0.1
listen on ::1
.Ed
-.It Xo Ic sensor Ar device
-.Op Ic correction Ar microseconds
-.Op Ic weight Ar weight-value
-.Op Ic refid Ar string
-.Xc
-Specify a timedelta sensor device
-.Xr ntpd 8
-should use.
-The sensor can be specified multiple times:
-.Xr ntpd 8
-will use each given sensor that actually exists.
-Non-existent sensors are ignored.
-If
-.Sq *
-is given as device name,
-.Xr ntpd 8
-will use all timedelta sensors it finds.
-.Xr ntpd 8
-does not use any timedelta sensor by default.
-For example:
-.Bd -literal -offset indent
-sensor *
-sensor nmea0
-.Ed
-.Pp
-An optional correction in microseconds can be given to compensate
-for the sensor's offset.
-The maximum correction is 127 seconds.
-For example, if a DCF77 receiver is lagging 70ms behind
-actual time:
-.Bd -literal -offset indent
-sensor udcf0 correction 70000
-.Ed
-.Pp
-The optional
-.Ic weight
-keyword permits finer control over the relative importance
-of time sources (servers or sensor devices).
-Weights are specified in the range 1 to 10;
-if no weight is given,
-the default is 1.
-A server with a weight of 5, for example,
-will have five times more influence on time offset calculation
-than a server with a weight of 1.
-.Pp
-An optional reference ID string - up to 4 ASCII characters - can be
-given to publish the sensor type to clients.
-RFC 2030 suggests some common reference identifiers, but new identifiers
-"can be contrived as appropriate."
-If an ID string is not given,
-.Xr ntpd 8
-will use a generic reference ID.
-For example:
-.Bd -literal -offset indent
-sensor nmea0 refid GPS
-.Ed
.It Xo Ic server Ar address
.Op Ic weight Ar weight-value
.Xc
@@ -139,6 +83,17 @@ server ntp.example.org weight 1
To provide redundancy, it is good practice to configure multiple servers.
In general, best accuracy is obtained by using servers that have a low
network latency.
+.Pp
+The optional
+.Ic weight
+keyword permits finer control over the relative importance
+of time sources.
+Weights are specified in the range 1 to 10;
+if no weight is given,
+the default is 1.
+A server with a weight of 5, for example,
+will have five times more influence on time offset calculation
+than a server with a weight of 1.
.It Xo Ic servers Ar address
.Op Ic weight Ar weight-value
.Xc
@@ -157,15 +112,14 @@ servers pool.ntp.org
--- ntpd.conf.5.orig 2015-01-08 06:57:55 UTC
+++ ntpd.conf.5
@@ -182,8 +182,8 @@ servers pool.ntp.org rtable 5
.Ed
.El
.Sh FILES
@ -93,11 +11,3 @@ $FreeBSD$
default
.Xr ntpd 8
configuration file
.El
.Sh SEE ALSO
-.Xr ntpd 8 ,
-.Xr sysctl 8
+.Xr ntpd 8
.Sh HISTORY
The
.Nm

View File

@ -1,17 +0,0 @@
$FreeBSD$
--- ntpd.h.orig 2009-11-23 20:37:40.000000000 +0100
+++ ntpd.h 2009-11-23 20:38:12.000000000 +0100
@@ -29,11 +29,12 @@
#include <pwd.h>
#include <stdarg.h>
+#include "compat.h"
#include "ntp.h"
#include <imsg.h>
#define NTPD_USER "_ntp"
-#define CONFFILE "/etc/ntpd.conf"
+#define CONFFILE "%%PREFIX%%/etc/ntpd.conf"
#define DRIFTFILE "/var/db/ntpd.drift"
#define INTERVAL_QUERY_NORMAL 30 /* sync to peers every n secs */

View File

@ -1,21 +0,0 @@
$FreeBSD$
--- parse.y.orig 2009-08-01 20:29:44.000000000 +0200
+++ parse.y 2009-08-01 21:17:58.000000000 +0200
@@ -200,6 +200,7 @@ main : LISTEN ON address {
free($2);
}
| SENSOR STRING sensor_opts {
+#ifdef HAVE_SENSORS
struct ntp_conf_sensor *s;
s = new_sensor($2);
@@ -208,6 +209,9 @@ main : LISTEN ON address {
s->refstr = $3.refstr;
free($2);
TAILQ_INSERT_TAIL(&conf->ntp_conf_sensors, s, entry);
+#else
+ yyerror("sensor devices not supported");
+#endif
}
;

View File

@ -1,5 +1,3 @@
OpenBSD's ntpd.
The ntpd daemon implements the Simple Network Time Protocol version 4 as
described in RFC 2030 and the Network Time Protocol version 3 as de-
scribed in RFC 1305. It can synchronize the local clock to one or more

View File

@ -1,4 +1,6 @@
@sample etc/ntpd.conf.sample
man/man5/ntpd.conf.5.gz
man/man8/ntpctl.8.gz
man/man8/ntpd.8.gz
sbin/ntpctl
sbin/ntpd