| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: res_init.c,v 1.27 2013/12/09 09:35:16 wiz Exp $ */ | | 1 | /* $NetBSD: res_init.c,v 1.28 2014/01/08 22:58:50 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1985, 1989, 1993 | | 4 | * Copyright (c) 1985, 1989, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -66,27 +66,27 @@ | | | @@ -66,27 +66,27 @@ |
66 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | | 66 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR |
67 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 67 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
68 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 68 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
69 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | | 69 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
70 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 70 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
71 | */ | | 71 | */ |
72 | | | 72 | |
73 | #include <sys/cdefs.h> | | 73 | #include <sys/cdefs.h> |
74 | #if defined(LIBC_SCCS) && !defined(lint) | | 74 | #if defined(LIBC_SCCS) && !defined(lint) |
75 | #ifdef notdef | | 75 | #ifdef notdef |
76 | static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; | | 76 | static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; |
77 | static const char rcsid[] = "Id: res_init.c,v 1.26 2008/12/11 09:59:00 marka Exp"; | | 77 | static const char rcsid[] = "Id: res_init.c,v 1.26 2008/12/11 09:59:00 marka Exp"; |
78 | #else | | 78 | #else |
79 | __RCSID("$NetBSD: res_init.c,v 1.27 2013/12/09 09:35:16 wiz Exp $"); | | 79 | __RCSID("$NetBSD: res_init.c,v 1.28 2014/01/08 22:58:50 christos Exp $"); |
80 | #endif | | 80 | #endif |
81 | #endif /* LIBC_SCCS and not lint */ | | 81 | #endif /* LIBC_SCCS and not lint */ |
82 | | | 82 | |
83 | #include "port_before.h" | | 83 | #include "port_before.h" |
84 | | | 84 | |
85 | #include "namespace.h" | | 85 | #include "namespace.h" |
86 | #include <sys/types.h> | | 86 | #include <sys/types.h> |
87 | #include <sys/param.h> | | 87 | #include <sys/param.h> |
88 | #include <sys/socket.h> | | 88 | #include <sys/socket.h> |
89 | #include <sys/stat.h> | | 89 | #include <sys/stat.h> |
90 | #include <sys/time.h> | | 90 | #include <sys/time.h> |
91 | #include <sys/event.h> | | 91 | #include <sys/event.h> |
92 | | | 92 | |
| @@ -152,26 +152,28 @@ static void res_setoptions(res_state, co | | | @@ -152,26 +152,28 @@ static void res_setoptions(res_state, co |
152 | #ifdef RESOLVSORT | | 152 | #ifdef RESOLVSORT |
153 | static const char sort_mask[] = "/&"; | | 153 | static const char sort_mask[] = "/&"; |
154 | #define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL) | | 154 | #define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL) |
155 | static uint32_t net_mask(struct in_addr); | | 155 | static uint32_t net_mask(struct in_addr); |
156 | #endif | | 156 | #endif |
157 | | | 157 | |
158 | #if !defined(isascii) /*%< XXX - could be a function */ | | 158 | #if !defined(isascii) /*%< XXX - could be a function */ |
159 | # define isascii(c) (!(c & 0200)) | | 159 | # define isascii(c) (!(c & 0200)) |
160 | #endif | | 160 | #endif |
161 | | | 161 | |
162 | static struct timespec __res_conf_time; | | 162 | static struct timespec __res_conf_time; |
163 | static const struct timespec ts = { 0, 0 }; | | 163 | static const struct timespec ts = { 0, 0 }; |
164 | | | 164 | |
| | | 165 | const char *__res_conf_name = _PATH_RESCONF; |
| | | 166 | |
165 | /* | | 167 | /* |
166 | * Resolver state default settings. | | 168 | * Resolver state default settings. |
167 | */ | | 169 | */ |
168 | | | 170 | |
169 | /*% | | 171 | /*% |
170 | * Set up default settings. If the configuration file exist, the values | | 172 | * Set up default settings. If the configuration file exist, the values |
171 | * there will have precedence. Otherwise, the server address is set to | | 173 | * there will have precedence. Otherwise, the server address is set to |
172 | * INADDR_ANY and the default domain name comes from the gethostname(). | | 174 | * INADDR_ANY and the default domain name comes from the gethostname(). |
173 | * | | 175 | * |
174 | * An interrim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1 | | 176 | * An interrim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1 |
175 | * rather than INADDR_ANY ("0.0.0.0") as the default name server address | | 177 | * rather than INADDR_ANY ("0.0.0.0") as the default name server address |
176 | * since it was noted that INADDR_ANY actually meant ``the first interface | | 178 | * since it was noted that INADDR_ANY actually meant ``the first interface |
177 | * you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface, | | 179 | * you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface, |
| @@ -336,27 +338,27 @@ __res_vinit(res_state statp, int preinit | | | @@ -336,27 +338,27 @@ __res_vinit(res_state statp, int preinit |
336 | /* null terminate last domain if there are excess */ | | 338 | /* null terminate last domain if there are excess */ |
337 | while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n') | | 339 | while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n') |
338 | cp++; | | 340 | cp++; |
339 | *cp = '\0'; | | 341 | *cp = '\0'; |
340 | *pp++ = 0; | | 342 | *pp++ = 0; |
341 | } | | 343 | } |
342 | | | 344 | |
343 | #define MATCH(line, name) \ | | 345 | #define MATCH(line, name) \ |
344 | (!strncmp(line, name, sizeof(name) - 1) && \ | | 346 | (!strncmp(line, name, sizeof(name) - 1) && \ |
345 | (line[sizeof(name) - 1] == ' ' || \ | | 347 | (line[sizeof(name) - 1] == ' ' || \ |
346 | line[sizeof(name) - 1] == '\t')) | | 348 | line[sizeof(name) - 1] == '\t')) |
347 | | | 349 | |
348 | nserv = 0; | | 350 | nserv = 0; |
349 | if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) { | | 351 | if ((fp = fopen(__res_conf_name, "re")) != NULL) { |
350 | struct stat st; | | 352 | struct stat st; |
351 | struct kevent kc; | | 353 | struct kevent kc; |
352 | | | 354 | |
353 | /* read the config file */ | | 355 | /* read the config file */ |
354 | while (fgets(buf, (int)sizeof(buf), fp) != NULL) { | | 356 | while (fgets(buf, (int)sizeof(buf), fp) != NULL) { |
355 | /* skip comments */ | | 357 | /* skip comments */ |
356 | if (*buf == ';' || *buf == '#') | | 358 | if (*buf == ';' || *buf == '#') |
357 | continue; | | 359 | continue; |
358 | /* read default domain name */ | | 360 | /* read default domain name */ |
359 | if (MATCH(buf, "domain")) { | | 361 | if (MATCH(buf, "domain")) { |
360 | if (haveenv) /*%< skip if have from environ */ | | 362 | if (haveenv) /*%< skip if have from environ */ |
361 | continue; | | 363 | continue; |
362 | cp = buf + sizeof("domain") - 1; | | 364 | cp = buf + sizeof("domain") - 1; |