summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ntpd/server.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/usr.sbin/ntpd/server.c b/usr.sbin/ntpd/server.c
index 6156d522914..56fe4d5522b 100644
--- a/usr.sbin/ntpd/server.c
+++ b/usr.sbin/ntpd/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.32 2008/06/10 03:46:09 naddy Exp $ */
+/* $OpenBSD: server.c,v 1.33 2008/11/10 16:59:33 deraadt Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -75,9 +75,7 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
freeifaddrs(ifa);
}
- TAILQ_FOREACH(la, &lconf->listen_addrs, entry) {
- new_cnt++;
-
+ for (la = TAILQ_FIRST(&lconf->listen_addrs); la; ) {
switch (la->sa.ss_family) {
case AF_INET:
if (((struct sockaddr_in *)&la->sa)->sin_port == 0)
@@ -104,8 +102,21 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
log_warn("setsockopt IPTOS_LOWDELAY");
if (bind(la->fd, (struct sockaddr *)&la->sa,
- SA_LEN((struct sockaddr *)&la->sa)) == -1)
- fatal("bind");
+ SA_LEN((struct sockaddr *)&la->sa)) == -1) {
+ struct listen_addr *nla;
+
+ log_warn("bind on %s failed, skipping",
+ log_sockaddr((struct sockaddr *)&la->sa));
+ close(la->fd);
+ la->fd = -1;
+ nla = TAILQ_NEXT(la, entry);
+ TAILQ_REMOVE(&lconf->listen_addrs, la, entry);
+ free(la);
+ la = nla;
+ continue;
+ }
+ new_cnt++;
+ la = TAILQ_NEXT(la, entry);
}
*cnt = new_cnt;