Major update to 4.4. Frequency correction is now supported.
This commit is contained in:
parent
b83e598b9e
commit
c84266ea6e
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=238830
16 changed files with 591 additions and 64 deletions
|
@ -6,27 +6,39 @@
|
|||
#
|
||||
|
||||
PORTNAME= openntpd
|
||||
PORTVERSION= 3.9p1
|
||||
PORTREVISION= 2
|
||||
PORTVERSION= 4.4
|
||||
PORTEPOCH= 2
|
||||
CATEGORIES= net
|
||||
MASTER_SITES= ftp://ftp.openbsd.org/pub/OpenBSD/OpenNTPD/ \
|
||||
ftp://ftp.kd85.com/pub/OpenBSD/OpenNTPD/ \
|
||||
ftp://ftp.jp.openbsd.org/pub/OpenBSD/OpenNTPD/
|
||||
MASTER_SITES= ${MASTER_SITE_OPENBSD}
|
||||
MASTER_SITE_SUBDIR= OpenNTPD
|
||||
EXTRACT_SUFX= .tgz
|
||||
|
||||
MAINTAINER= naddy@FreeBSD.org
|
||||
COMMENT= OpenBSD's Network Time Protocol daemon
|
||||
|
||||
USE_RC_SUBR= openntpd
|
||||
GNU_CONFIGURE= yes
|
||||
|
||||
WRKSRC= ${WRKDIR}/ntpd
|
||||
MAKE_JOBS_SAFE= yes
|
||||
|
||||
MAN5= ntpd.conf.5
|
||||
MAN8= ntpd.8
|
||||
|
||||
.include <bsd.port.pre.mk>
|
||||
|
||||
# requires adjtime(NULL, &olddelta) by unprivileged user
|
||||
.if ${OSVERSION} < 700000
|
||||
IGNORE= is unsupported prior to FreeBSD 7.0
|
||||
.endif
|
||||
|
||||
post-extract:
|
||||
.for i in compat.h adjfreq.c arc4random.c
|
||||
@${CP} ${FILESDIR}/$i ${WRKSRC}
|
||||
.endfor
|
||||
|
||||
pre-build:
|
||||
${REINPLACE_CMD} -e 's,%%PREFIX%%,${PREFIX},g' \
|
||||
${WRKSRC}/ntpd.conf.5 ${WRKSRC}/ntpd.8
|
||||
${WRKSRC}/ntpd.h ${WRKSRC}/ntpd.conf.5 ${WRKSRC}/ntpd.8
|
||||
|
||||
do-install:
|
||||
@PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
|
||||
|
@ -34,9 +46,9 @@ do-install:
|
|||
${INSTALL_MAN} ${WRKSRC}/ntpd.conf.5 ${PREFIX}/man/man5
|
||||
${INSTALL_MAN} ${WRKSRC}/ntpd.8 ${PREFIX}/man/man8
|
||||
@${MKDIR} ${EXAMPLESDIR}
|
||||
${INSTALL_DATA} ${WRKSRC}/ntpd.conf ${EXAMPLESDIR}
|
||||
${INSTALL_DATA} ${FILESDIR}/ntpd.conf ${EXAMPLESDIR}
|
||||
@if [ ! -f ${PREFIX}/etc/ntpd.conf ]; then \
|
||||
${CP} -p ${EXAMPLESDIR}/ntpd.conf ${PREFIX}/etc; \
|
||||
${CP} ${EXAMPLESDIR}/ntpd.conf ${PREFIX}/etc; \
|
||||
fi
|
||||
|
||||
.include <bsd.port.mk>
|
||||
.include <bsd.port.post.mk>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
MD5 (openntpd-3.9p1.tar.gz) = afc34175f38d08867c1403d9008600b3
|
||||
SHA256 (openntpd-3.9p1.tar.gz) = 83dd7c1e8ec8b4567afe49af539271b5a73562fb7a3ca51df73eccba89ec8c49
|
||||
SIZE (openntpd-3.9p1.tar.gz) = 152700
|
||||
MD5 (openntpd-4.4.tgz) = 407d1818ad2d5f1c970baa91fa68d2e3
|
||||
SHA256 (openntpd-4.4.tgz) = b7b788e28ebbaafa89784978c02ea499dc65fb8db91a969152e73e3004c21741
|
||||
SIZE (openntpd-4.4.tgz) = 27262
|
||||
|
|
30
net/openntpd/files/adjfreq.c
Normal file
30
net/openntpd/files/adjfreq.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
68
net/openntpd/files/arc4random.c
Normal file
68
net/openntpd/files/arc4random.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (c) 1999,2000,2004 Damien Miller <djm@mindrot.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ntpd.h"
|
||||
|
||||
/*
|
||||
* Calculate a uniformly distributed random number less than upper_bound
|
||||
* avoiding "modulo bias".
|
||||
*
|
||||
* Uniformity is achieved by generating new random numbers until the one
|
||||
* returned is outside the range [0, 2**32 % upper_bound). This
|
||||
* guarantees the selected random number will be inside
|
||||
* [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
|
||||
* after reduction modulo upper_bound.
|
||||
*/
|
||||
u_int32_t
|
||||
arc4random_uniform(u_int32_t upper_bound)
|
||||
{
|
||||
u_int32_t r, min;
|
||||
|
||||
if (upper_bound < 2)
|
||||
return 0;
|
||||
|
||||
#if (ULONG_MAX > 0xffffffffUL)
|
||||
min = 0x100000000UL % upper_bound;
|
||||
#else
|
||||
/* Calculate (2**32 % upper_bound) avoiding 64-bit math */
|
||||
if (upper_bound > 0x80000000)
|
||||
min = 1 + ~upper_bound; /* 2**32 - upper_bound */
|
||||
else {
|
||||
/* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */
|
||||
min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This could theoretically loop forever but each retry has
|
||||
* p > 0.5 (worst case, usually far better) of selecting a
|
||||
* number inside the range we need, so it should rarely need
|
||||
* to re-roll.
|
||||
*/
|
||||
for (;;) {
|
||||
r = arc4random();
|
||||
if (r >= min)
|
||||
break;
|
||||
}
|
||||
|
||||
return r % upper_bound;
|
||||
}
|
25
net/openntpd/files/compat.h
Normal file
25
net/openntpd/files/compat.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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 *);
|
||||
|
||||
/* arc4random.c */
|
||||
u_int32_t arc4random_uniform(u_int32_t);
|
12
net/openntpd/files/ntpd.conf
Normal file
12
net/openntpd/files/ntpd.conf
Normal file
|
@ -0,0 +1,12 @@
|
|||
# $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
|
20
net/openntpd/files/patch-Makefile
Normal file
20
net/openntpd/files/patch-Makefile
Normal file
|
@ -0,0 +1,20 @@
|
|||
$FreeBSD$
|
||||
--- Makefile.orig 2009-08-01 17:38:53.000000000 +0200
|
||||
+++ Makefile 2009-08-01 18:21:05.000000000 +0200
|
||||
@@ -4,7 +4,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
|
||||
+ server.c client.c util.c adjfreq.c arc4random.c
|
||||
CFLAGS+= -Wall -I${.CURDIR}
|
||||
CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
|
||||
CFLAGS+= -Wmissing-declarations
|
||||
@@ -13,4 +13,7 @@ CFLAGS+= -Wsign-compare
|
||||
YFLAGS=
|
||||
MAN= ntpd.8 ntpd.conf.5
|
||||
|
||||
+DPADD= ${LIBMD}
|
||||
+LDADD= -lmd
|
||||
+
|
||||
.include <bsd.prog.mk>
|
|
@ -1,9 +1,7 @@
|
|||
|
||||
$FreeBSD$
|
||||
|
||||
--- log.c.orig
|
||||
+++ log.c
|
||||
@@ -28,6 +28,10 @@
|
||||
--- 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"
|
||||
|
||||
|
@ -12,9 +10,9 @@ $FreeBSD$
|
|||
+#endif
|
||||
+
|
||||
int debug;
|
||||
extern int debugsyslog;
|
||||
|
||||
void logit(int, const char *, ...);
|
||||
@@ -40,7 +44,7 @@
|
||||
@@ -39,7 +43,7 @@ log_init(int n_debug)
|
||||
debug = n_debug;
|
||||
|
||||
if (!debug)
|
||||
|
|
219
net/openntpd/files/patch-ntp.c
Normal file
219
net/openntpd/files/patch-ntp.c
Normal file
|
@ -0,0 +1,219 @@
|
|||
$FreeBSD$
|
||||
--- ntp.c.orig 2009-08-01 20:12:43.000000000 +0200
|
||||
+++ ntp.c 2009-08-01 20:26:44.000000000 +0200
|
||||
@@ -34,8 +34,12 @@
|
||||
#include "ntpd.h"
|
||||
|
||||
#define PFD_PIPE_MAIN 0
|
||||
+#ifdef HAVE_SENSORS
|
||||
#define PFD_HOTPLUG 1
|
||||
#define PFD_MAX 2
|
||||
+#else
|
||||
+#define PFD_MAX 1
|
||||
+#endif
|
||||
|
||||
volatile sig_atomic_t ntp_quit = 0;
|
||||
volatile sig_atomic_t ntp_report = 0;
|
||||
@@ -69,7 +73,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;
|
||||
+#ifdef HAVE_SENSORS
|
||||
+ int hotplugfd;
|
||||
+#endif
|
||||
+ int nullfd;
|
||||
u_int pfd_elms = 0, idx2peer_elms = 0;
|
||||
u_int listener_cnt, new_cnt, sent_cnt, trial_cnt;
|
||||
pid_t pid;
|
||||
@@ -78,10 +85,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()) {
|
||||
@@ -105,7 +117,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 (stat(pw->pw_dir, &stb) == -1)
|
||||
fatal("stat");
|
||||
@@ -168,7 +182,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");
|
||||
|
||||
@@ -210,8 +226,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
|
||||
|
||||
i = PFD_MAX;
|
||||
TAILQ_FOREACH(la, &conf->listen_addrs, entry) {
|
||||
@@ -265,6 +283,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();
|
||||
@@ -273,7 +292,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);
|
||||
@@ -281,6 +302,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) ||
|
||||
@@ -312,10 +334,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 = 1; nfds > 0 && j < idx_peers; j++)
|
||||
if (pfd[j].revents & (POLLIN|POLLERR)) {
|
||||
@@ -332,12 +356,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;
|
||||
}
|
||||
@@ -511,7 +537,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;
|
||||
@@ -524,11 +552,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);
|
||||
@@ -543,12 +573,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);
|
||||
|
||||
@@ -585,11 +617,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);
|
||||
}
|
||||
@@ -679,16 +713,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 = time(NULL);
|
||||
if (!always) {
|
||||
@@ -718,6 +756,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);
|
||||
@@ -726,5 +765,6 @@ report_peers(int always)
|
||||
log_warnx("bad sensor %s", s->device);
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
|
@ -1,55 +1,70 @@
|
|||
|
||||
$FreeBSD$
|
||||
|
||||
--- ntpd.8.orig
|
||||
+++ ntpd.8
|
||||
@@ -53,6 +53,20 @@
|
||||
.Xr adjtime 2
|
||||
will be logged.
|
||||
.Pp
|
||||
+.Nm
|
||||
+is usually started at boot time, and can be enabled by
|
||||
+setting the following in
|
||||
+.Pa /etc/rc.conf :
|
||||
+.Pp
|
||||
+.Dl openntpd_enable=\&"YES\&"
|
||||
+.Pp
|
||||
+See
|
||||
+.Xr rc 8
|
||||
+and
|
||||
+.Xr rc.conf 5
|
||||
+for more information on the boot process
|
||||
+and enabling daemons.
|
||||
+.Pp
|
||||
When
|
||||
--- ntpd.8.orig 2009-08-01 21:32:41.000000000 +0200
|
||||
+++ ntpd.8 2009-08-01 21:40:29.000000000 +0200
|
||||
@@ -29,8 +29,7 @@
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
starts up, it reads settings from a configuration file,
|
||||
@@ -72,7 +86,7 @@
|
||||
-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
|
||||
.Ar file
|
||||
as the configuration file,
|
||||
instead of the default
|
||||
-.Pa /etc/ntpd.conf .
|
||||
+.Pa %%PREFIX%%/etc/ntpd.conf .
|
||||
.It Fl S
|
||||
Do not set the time immediately at startup.
|
||||
This is the default.
|
||||
@@ -86,8 +100,8 @@
|
||||
.Nm .
|
||||
.El
|
||||
.It Fl n
|
||||
Configtest mode.
|
||||
Only check the configuration file for validity.
|
||||
@@ -91,19 +90,19 @@ will be logged.
|
||||
After the local clock is synchronized,
|
||||
.Nm
|
||||
adjusts the clock frequency using the
|
||||
-.Xr adjfreq 2
|
||||
+.Xr ntp_adjtime 2
|
||||
system call to compensate for systematic drift.
|
||||
.Pp
|
||||
.Nm
|
||||
is usually started at boot time, and can be enabled by
|
||||
setting
|
||||
-.Va ntpd_flags
|
||||
+.Va openntpd_enable
|
||||
in
|
||||
-.Pa /etc/rc.conf.local .
|
||||
+.Pa /etc/rc.conf .
|
||||
See
|
||||
.Xr rc 8
|
||||
and
|
||||
-.Xr rc.conf 8
|
||||
+.Xr rc.conf 5
|
||||
for more information on the boot process
|
||||
and enabling daemons.
|
||||
.Pp
|
||||
@@ -123,19 +122,19 @@ receives a
|
||||
signal, it writes its peer and sensor status to
|
||||
.Xr syslog 3 .
|
||||
.Sh FILES
|
||||
-.Bl -tag -width "/etc/ntpd.confXXX" -compact
|
||||
-.Bl -tag -width "/var/db/ntpd.driftXXX" -compact
|
||||
-.It Pa /etc/ntpd.conf
|
||||
+.Bl -tag -width "%%PREFIX%%/etc/ntpd.confXXX" -compact
|
||||
+.It Pa %%PREFIX%%/etc/ntpd.conf
|
||||
default
|
||||
.Nm
|
||||
configuration file
|
||||
@@ -96,6 +110,8 @@
|
||||
Default configuration file.
|
||||
.It Pa /var/db/ntpd.drift
|
||||
Drift file.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr date 1 ,
|
||||
-.Xr adjfreq 2 ,
|
||||
.Xr adjtime 2 ,
|
||||
+.Xr ntp_adjtime 2 ,
|
||||
.Xr ntpd.conf 5 ,
|
||||
+.Xr rc.conf 5 ,
|
||||
+.Xr rc 8 ,
|
||||
.Xr rc 8 ,
|
||||
-.Xr rc.conf 8 ,
|
||||
.Xr rdate 8 ,
|
||||
.Xr timed 8
|
||||
.Rs
|
||||
|
|
24
net/openntpd/files/patch-ntpd.c
Normal file
24
net/openntpd/files/patch-ntpd.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
$FreeBSD$
|
||||
|
||||
Drift file in ppm for compatibility with reference ntpd.
|
||||
|
||||
--- ntpd.c.orig 2009-08-01 22:17:42.000000000 +0200
|
||||
+++ ntpd.c 2009-08-01 22:18:51.000000000 +0200
|
||||
@@ -449,7 +449,7 @@ readfreq(void)
|
||||
log_warn("adjfreq failed");
|
||||
else if (current == 0) {
|
||||
if (fscanf(fp, "%le", &d) == 1)
|
||||
- ntpd_adjfreq(d, 0);
|
||||
+ ntpd_adjfreq(d / 1e6, 0);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
@@ -470,7 +470,7 @@ writefreq(double d)
|
||||
return 0;
|
||||
}
|
||||
|
||||
- fprintf(fp, "%e\n", d);
|
||||
+ fprintf(fp, "%e\n", d * 1e6);
|
||||
r = ferror(fp);
|
||||
if (fclose(fp) != 0 || r != 0) {
|
||||
if (warnonce) {
|
|
@ -1,9 +1,68 @@
|
|||
|
||||
$FreeBSD$
|
||||
|
||||
--- ntpd.conf.5.orig Sun Jul 18 14:25:21 2004
|
||||
+++ ntpd.conf.5 Sun Jul 18 14:25:44 2004
|
||||
@@ -80,8 +80,8 @@
|
||||
--- ntpd.conf.5.orig 2009-08-01 21:41:54.000000000 +0200
|
||||
+++ ntpd.conf.5 2009-08-01 21:47:49.000000000 +0200
|
||||
@@ -28,7 +28,7 @@ configuration file.
|
||||
The optional
|
||||
.Ic weight
|
||||
keyword permits finer control over the relative importance
|
||||
-of time sources (servers or sensor devices).
|
||||
+of time sources.
|
||||
Weights are specified in the range 1 to 10;
|
||||
if no weight is given,
|
||||
the default is 1.
|
||||
@@ -70,51 +70,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 udcf0
|
||||
-.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 15ms behind
|
||||
-actual time:
|
||||
-.Bd -literal -offset indent
|
||||
-sensor udcf0 correction 15000
|
||||
-.Ed
|
||||
-.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 msts0 refid GPS
|
||||
-.Ed
|
||||
.It Xo Ic server Ar address
|
||||
.Op Ic weight Ar weight-value
|
||||
.Xc
|
||||
@@ -157,15 +112,14 @@ servers pool.ntp.org
|
||||
.Ed
|
||||
.El
|
||||
.Sh FILES
|
||||
|
@ -14,3 +73,11 @@ $FreeBSD$
|
|||
default
|
||||
.Xr ntpd 8
|
||||
configuration file
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
-.Xr ntpd 8 ,
|
||||
-.Xr sysctl 8
|
||||
+.Xr ntpd 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
|
|
16
net/openntpd/files/patch-ntpd.h
Normal file
16
net/openntpd/files/patch-ntpd.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
$FreeBSD$
|
||||
--- ntpd.h.orig 2009-01-16 15:03:38.000000000 +0100
|
||||
+++ ntpd.h 2009-08-01 22:31:40.000000000 +0200
|
||||
@@ -29,10 +29,11 @@
|
||||
#include <pwd.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
+#include "compat.h"
|
||||
#include "ntp.h"
|
||||
|
||||
#define NTPD_USER "_ntp"
|
||||
-#define CONFFILE "/etc/ntpd.conf"
|
||||
+#define CONFFILE "%%PREFIX%%/etc/ntpd.conf"
|
||||
#define DRIFTFILE "/var/db/ntpd.drift"
|
||||
|
||||
#define READ_BUF_SIZE 8192
|
21
net/openntpd/files/patch-parse.y
Normal file
21
net/openntpd/files/patch-parse.y
Normal file
|
@ -0,0 +1,21 @@
|
|||
$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
|
||||
}
|
||||
;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
OpenBSD's ntpd, portable version.
|
||||
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-
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
sbin/ntpd
|
||||
@unexec if cmp -s %D/etc/ntpd.conf %D/%%EXAMPLESDIR%%/ntpd.conf; then rm -f %D/etc/ntpd.conf; fi
|
||||
%%EXAMPLESDIR%%/ntpd.conf
|
||||
@exec if [ ! -f %D/etc/ntpd.conf ]; then cp -p %D/%F %D/etc; fi
|
||||
@exec if [ ! -f %D/etc/ntpd.conf ]; then cp %D/%F %D/etc; fi
|
||||
@dirrm %%EXAMPLESDIR%%
|
||||
|
|
Loading…
Reference in a new issue