From 62c3d341a1a19c1453090bee0b13606c246efca5 Mon Sep 17 00:00:00 2001 From: henning <> Date: Wed, 9 Mar 2005 20:31:11 +0000 Subject: [PATCH] nasty: host_dns used to run before forking and chrooting etc, so it was guaranteed that its res_init() call was done once before fork etc... that is no longer the case. call res_init() in main() early. --- src/usr.sbin/ntpd/config.c | 3 +-- src/usr.sbin/ntpd/ntpd.c | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/usr.sbin/ntpd/config.c b/src/usr.sbin/ntpd/config.c index 03849d08..36f27d42 100644 --- a/src/usr.sbin/ntpd/config.c +++ b/src/usr.sbin/ntpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.16 2005/03/08 14:59:36 henning Exp $ */ +/* $OpenBSD: config.c,v 1.17 2005/03/09 20:31:11 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -121,7 +121,6 @@ host_dns(const char *s, struct ntp_addr **hn) bzero(&hints, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; /* DUMMY */ - res_init(); /* XXX */ error = getaddrinfo(s, NULL, &hints, &res0); if (error == EAI_AGAIN || error == EAI_NODATA || error == EAI_NONAME) return (0); diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c index 2d9fbf7a..02f63b06 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.30 2005/03/08 14:28:55 henning Exp $ */ +/* $OpenBSD: ntpd.c,v 1.31 2005/03/09 20:31:11 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -90,6 +91,7 @@ main(int argc, char *argv[]) bzero(&conf, sizeof(conf)); log_init(1); /* log to stderr until daemonized */ + res_init(); /* XXX */ while ((ch = getopt(argc, argv, "df:sS")) != -1) { switch (ch) {