Browse Source

Remove support for sending status reports to syslog on SIGINFO;

we have ntpctl now and ntpd doesn't need redundant/obsolete features.
Pointed out by naddy@, with input from zhuk@ (SIGINFO doesn't need SIG_IGN)
OK deraadt@
OPENBSD_5_9
reyk 9 years ago
parent
commit
13e2f2c777
2 changed files with 3 additions and 79 deletions
  1. +1
    -69
      src/usr.sbin/ntpd/ntp.c
  2. +2
    -10
      src/usr.sbin/ntpd/ntpd.8

+ 1
- 69
src/usr.sbin/ntpd/ntp.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntp.c,v 1.138 2015/10/23 14:52:20 phessler Exp $ */
/* $OpenBSD: ntp.c,v 1.139 2015/10/30 16:41:53 reyk Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -40,7 +40,6 @@
#define PFD_MAX 3 #define PFD_MAX 3
volatile sig_atomic_t ntp_quit = 0; volatile sig_atomic_t ntp_quit = 0;
volatile sig_atomic_t ntp_report = 0;
struct imsgbuf *ibuf_main; struct imsgbuf *ibuf_main;
struct imsgbuf *ibuf_dns; struct imsgbuf *ibuf_dns;
struct ntpd_conf *conf; struct ntpd_conf *conf;
@ -48,14 +47,12 @@ struct ctl_conns ctl_conns;
u_int peer_cnt; u_int peer_cnt;
u_int sensors_cnt; u_int sensors_cnt;
extern u_int constraint_cnt; extern u_int constraint_cnt;
time_t lastreport;
void ntp_sighdlr(int); void ntp_sighdlr(int);
int ntp_dispatch_imsg(void); int ntp_dispatch_imsg(void);
int ntp_dispatch_imsg_dns(void); int ntp_dispatch_imsg_dns(void);
void peer_add(struct ntp_peer *); void peer_add(struct ntp_peer *);
void peer_remove(struct ntp_peer *); void peer_remove(struct ntp_peer *);
void report_peers(int);
void void
ntp_sighdlr(int sig) ntp_sighdlr(int sig)
@ -65,9 +62,6 @@ ntp_sighdlr(int sig)
case SIGTERM: case SIGTERM:
ntp_quit = 1; ntp_quit = 1;
break; break;
case SIGINFO:
ntp_report = 1;
break;
} }
} }
@ -160,7 +154,6 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf,
signal(SIGTERM, ntp_sighdlr); signal(SIGTERM, ntp_sighdlr);
signal(SIGINT, ntp_sighdlr); signal(SIGINT, ntp_sighdlr);
signal(SIGINFO, ntp_sighdlr);
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
signal(SIGHUP, SIG_IGN); signal(SIGHUP, SIG_IGN);
signal(SIGCHLD, SIG_DFL); signal(SIGCHLD, SIG_DFL);
@ -209,9 +202,6 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf,
TAILQ_FOREACH(p, &conf->ntp_peers, entry) TAILQ_FOREACH(p, &conf->ntp_peers, entry)
peer_cnt++; peer_cnt++;
/* wait 5 min before reporting first status to let things settle down */
lastreport = getmonotime() + (5 * 60) - REPORT_INTERVAL;
while (ntp_quit == 0) { while (ntp_quit == 0) {
if (peer_cnt > idx2peer_elms) { if (peer_cnt > idx2peer_elms) {
if ((newp = reallocarray(idx2peer, peer_cnt, if ((newp = reallocarray(idx2peer, peer_cnt,
@ -419,8 +409,6 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf,
if (s->next <= getmonotime()) if (s->next <= getmonotime())
sensor_query(s); sensor_query(s);
} }
report_peers(ntp_report);
ntp_report = 0;
} }
msgbuf_write(&ibuf_main->w); msgbuf_write(&ibuf_main->w);
@ -788,59 +776,3 @@ error_interval(void)
r = arc4random_uniform(interval / 10); r = arc4random_uniform(interval / 10);
return (interval + r); return (interval + r);
} }
void
report_peers(int always)
{
time_t now;
u_int badpeers = 0;
u_int badsensors = 0;
struct ntp_peer *p;
struct ntp_sensor *s;
TAILQ_FOREACH(p, &conf->ntp_peers, entry) {
if (p->trustlevel < TRUSTLEVEL_BADPEER)
badpeers++;
}
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
if (!s->update.good)
badsensors++;
}
now = getmonotime();
if (!always) {
if ((peer_cnt == 0 || badpeers == 0 || badpeers < peer_cnt / 2)
&& (sensors_cnt == 0 || badsensors == 0 ||
badsensors < sensors_cnt / 2))
return;
if (lastreport + REPORT_INTERVAL > now)
return;
}
lastreport = now;
if (peer_cnt > 0) {
log_warnx("%u out of %u peers valid", peer_cnt - badpeers,
peer_cnt);
TAILQ_FOREACH(p, &conf->ntp_peers, entry) {
if (p->trustlevel < TRUSTLEVEL_BADPEER) {
const char *a = "not resolved";
const char *pool = "";
if (p->addr)
a = log_sockaddr(
(struct sockaddr *)&p->addr->ss);
if (p->addr_head.pool)
pool = "from pool ";
log_warnx("bad peer %s%s (%s)",
pool, p->addr_head.name, a);
}
}
}
if (sensors_cnt > 0) {
log_warnx("%u out of %u sensors valid",
sensors_cnt - badsensors, sensors_cnt);
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
if (!s->update.good)
log_warnx("bad sensor %s", s->device);
}
}
}

+ 2
- 10
src/usr.sbin/ntpd/ntpd.8 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: ntpd.8,v 1.39 2015/03/26 20:34:54 jmc Exp $
.\" $OpenBSD: ntpd.8,v 1.40 2015/10/30 16:41:53 reyk Exp $
.\" .\"
.\" Copyright (c) 2003, 2004, 2006 Henning Brauer <henning@openbsd.org> .\" Copyright (c) 2003, 2004, 2006 Henning Brauer <henning@openbsd.org>
.\" .\"
@ -14,7 +14,7 @@
.\" AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT .\" AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: March 26 2015 $
.Dd $Mdocdate: October 30 2015 $
.Dt NTPD 8 .Dt NTPD 8
.Os .Os
.Sh NAME .Sh NAME
@ -119,14 +119,6 @@ typically
and its initial clock drift from and its initial clock drift from
.Pa /var/db/ntpd.drift . .Pa /var/db/ntpd.drift .
Clock drift is periodically written to the drift file thereafter. Clock drift is periodically written to the drift file thereafter.
.Pp
When
.Nm
.Pq engine
receives a
.Dv SIGINFO
signal, it writes its peer and sensor status to
.Xr syslog 3 .
.Sh FILES .Sh FILES
.Bl -tag -width "/var/db/ntpd.driftXXX" -compact .Bl -tag -width "/var/db/ntpd.driftXXX" -compact
.It Pa /etc/ntpd.conf .It Pa /etc/ntpd.conf


Loading…
Cancel
Save