summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ntpd/config.c6
-rw-r--r--usr.sbin/ntpd/ntpd.h3
-rw-r--r--usr.sbin/ntpd/parse.y21
-rw-r--r--usr.sbin/ntpd/server.c4
4 files changed, 26 insertions, 8 deletions
diff --git a/usr.sbin/ntpd/config.c b/usr.sbin/ntpd/config.c
index ea52c4fc6b6..f622de2a51f 100644
--- a/usr.sbin/ntpd/config.c
+++ b/usr.sbin/ntpd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.5 2004/07/07 03:53:14 henning Exp $ */
+/* $OpenBSD: config.c,v 1.6 2004/07/07 05:47:57 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -77,6 +77,10 @@ host(const char *s, u_int8_t *len)
mask = 128;
}
+ if (!strcmp(s, "*"))
+ if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
+ fatal(NULL);
+
/* IPv4 address? */
if (h == NULL)
h = host_v4(s, len);
diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h
index bef5936a174..2f790282104 100644
--- a/usr.sbin/ntpd/ntpd.h
+++ b/usr.sbin/ntpd/ntpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.h,v 1.15 2004/07/07 03:15:37 henning Exp $ */
+/* $OpenBSD: ntpd.h,v 1.16 2004/07/07 05:47:57 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -90,6 +90,7 @@ struct ntpd_conf {
TAILQ_HEAD(listen_addrs, listen_addr) listen_addrs;
TAILQ_HEAD(ntp_peers, ntp_peer) ntp_peers;
u_int8_t opts;
+ u_int8_t listen_all;
};
struct buf {
diff --git a/usr.sbin/ntpd/parse.y b/usr.sbin/ntpd/parse.y
index c06d3b35b77..c2ab3d3b936 100644
--- a/usr.sbin/ntpd/parse.y
+++ b/usr.sbin/ntpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.5 2004/07/07 03:15:37 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.6 2004/07/07 05:47:57 henning Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -124,12 +124,17 @@ varset : STRING '=' string {
}
;
-conf_main : LISTEN ON address {
+conf_main : LISTEN ON address {
struct listen_addr *la;
struct ntp_addr *h, *next;
for (h = $3; h != NULL; h = next) {
next = h->next;
+ if (h->ss.ss_family == AF_UNSPEC) {
+ conf->listen_all = 1;
+ free(h);
+ continue;
+ }
la = calloc(1, sizeof(struct listen_addr));
if (la == NULL)
fatal("listen on calloc");
@@ -144,9 +149,15 @@ conf_main : LISTEN ON address {
| SERVER address {
struct ntp_peer *p;
struct ntp_addr *h, *next;
-
- for (h = $2; h != NULL; h = next) {
+
+ for (h = $2; h != NULL; h = next) {
next = h->next;
+ if (h->ss.ss_family != AF_INET &&
+ h->ss.ss_family != AF_INET6) {
+ yyerror("IPv4 or IPv6 address "
+ "or hostname expected");
+ YYERROR;
+ }
p = calloc(1, sizeof(struct ntp_peer));
if (p == NULL)
fatal("conf_main server calloc");
@@ -483,6 +494,8 @@ parse_config(char *filename, struct ntpd_conf *xconf)
TAILQ_INSERT_TAIL(&xconf->ntp_peers, p, entry);
}
+ xconf->listen_all = conf->listen_all;
+
free(conf);
return (errors ? -1 : 0);
diff --git a/usr.sbin/ntpd/server.c b/usr.sbin/ntpd/server.c
index 8d9971df4f9..70074dd83e1 100644
--- a/usr.sbin/ntpd/server.c
+++ b/usr.sbin/ntpd/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.4 2004/07/04 18:07:15 henning Exp $ */
+/* $OpenBSD: server.c,v 1.5 2004/07/07 05:47:57 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -36,7 +36,7 @@ setup_listeners(struct servent *se, struct ntpd_conf *conf, u_int *cnt)
struct sockaddr *sap;
u_int new_cnt = 0;
- if (TAILQ_EMPTY(&conf->listen_addrs)) {
+ if (conf->listen_all) {
if (getifaddrs(&ifap) == -1)
fatal("getifaddrs");