diff options
author | marc <> | 2003-01-28 04:58:00 +0000 |
---|---|---|
committer | marc <> | 2003-01-28 04:58:00 +0000 |
commit | 547ebab319b228b064cf5dcb3ff0ae1bf23d24a2 (patch) | |
tree | f57454716593fb3b68672505c6dccab6438498f1 /src/lib/libc/net/res_init.c | |
parent | 98a78d57b176408b5aca87705f9681c5b155b47c (diff) | |
download | openbsd-547ebab319b228b064cf5dcb3ff0ae1bf23d24a2.tar.gz openbsd-547ebab319b228b064cf5dcb3ff0ae1bf23d24a2.tar.bz2 openbsd-547ebab319b228b064cf5dcb3ff0ae1bf23d24a2.zip |
thread safer libc (note: safer, not safe)
Access to the global _res structure replaced by pointers to a
per thread instance. If unthreaded the pointer is to the
global structure.
Also replaced a 64k stack array with malloc-ed memory so
threaded aps (with a default 64k stack) have a chance at working.
ok deraadt@
Diffstat (limited to 'src/lib/libc/net/res_init.c')
-rw-r--r-- | src/lib/libc/net/res_init.c | 187 |
1 files changed, 101 insertions, 86 deletions
diff --git a/src/lib/libc/net/res_init.c b/src/lib/libc/net/res_init.c index c55c7763a4..a1d69f57b5 100644 --- a/src/lib/libc/net/res_init.c +++ b/src/lib/libc/net/res_init.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: res_init.c,v 1.27 2002/07/25 21:13:45 deraadt Exp $ */ | 1 | /* $OpenBSD: res_init.c,v 1.28 2003/01/28 04:58:00 marc Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * ++Copyright++ 1985, 1989, 1993 | 4 | * ++Copyright++ 1985, 1989, 1993 |
@@ -64,7 +64,7 @@ | |||
64 | static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; | 64 | static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; |
65 | static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $"; | 65 | static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $"; |
66 | #else | 66 | #else |
67 | static char rcsid[] = "$OpenBSD: res_init.c,v 1.27 2002/07/25 21:13:45 deraadt Exp $"; | 67 | static char rcsid[] = "$OpenBSD: res_init.c,v 1.28 2003/01/28 04:58:00 marc Exp $"; |
68 | #endif | 68 | #endif |
69 | #endif /* LIBC_SCCS and not lint */ | 69 | #endif /* LIBC_SCCS and not lint */ |
70 | 70 | ||
@@ -86,6 +86,8 @@ static char rcsid[] = "$OpenBSD: res_init.c,v 1.27 2002/07/25 21:13:45 deraadt E | |||
86 | #include <netdb.h> | 86 | #include <netdb.h> |
87 | #endif /* INET6 */ | 87 | #endif /* INET6 */ |
88 | 88 | ||
89 | #include "thread_private.h" | ||
90 | |||
89 | /*-------------------------------------- info about "sortlist" -------------- | 91 | /*-------------------------------------- info about "sortlist" -------------- |
90 | * Marc Majka 1994/04/16 | 92 | * Marc Majka 1994/04/16 |
91 | * Allan Nathanson 1994/10/29 (BIND 4.9.3.x) | 93 | * Allan Nathanson 1994/10/29 (BIND 4.9.3.x) |
@@ -120,6 +122,9 @@ static u_int32_t net_mask(struct in_addr); | |||
120 | /* | 122 | /* |
121 | * Resolver state default settings. | 123 | * Resolver state default settings. |
122 | */ | 124 | */ |
125 | volatile struct _thread_private_key_struct __THREAD_KEY_NAME(_res) = { | ||
126 | PTHREAD_ONCE_INIT, 0 | ||
127 | }; | ||
123 | 128 | ||
124 | struct __res_state _res | 129 | struct __res_state _res |
125 | # if defined(__BIND_RES_TEXT) | 130 | # if defined(__BIND_RES_TEXT) |
@@ -127,6 +132,10 @@ struct __res_state _res | |||
127 | # endif | 132 | # endif |
128 | ; | 133 | ; |
129 | #ifdef INET6 | 134 | #ifdef INET6 |
135 | volatile struct _thread_private_key_struct __THREAD_KEY_NAME(_res_ext) = { | ||
136 | PTHREAD_ONCE_INIT, 0 | ||
137 | }; | ||
138 | |||
130 | struct __res_state_ext _res_ext; | 139 | struct __res_state_ext _res_ext; |
131 | #endif /* INET6 */ | 140 | #endif /* INET6 */ |
132 | 141 | ||
@@ -154,6 +163,11 @@ struct __res_state_ext _res_ext; | |||
154 | int | 163 | int |
155 | res_init() | 164 | res_init() |
156 | { | 165 | { |
166 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); | ||
167 | #ifdef INET6 | ||
168 | struct __res_state_ext *_res_extp = _THREAD_PRIVATE(_res_ext, _res_ext, | ||
169 | &_res_ext); | ||
170 | #endif | ||
157 | register FILE *fp; | 171 | register FILE *fp; |
158 | register char *cp, **pp; | 172 | register char *cp, **pp; |
159 | register int n; | 173 | register int n; |
@@ -189,33 +203,33 @@ res_init() | |||
189 | * set in RES_DEFAULT). Our solution is to declare such applications | 203 | * set in RES_DEFAULT). Our solution is to declare such applications |
190 | * "broken". They could fool us by setting RES_INIT but none do (yet). | 204 | * "broken". They could fool us by setting RES_INIT but none do (yet). |
191 | */ | 205 | */ |
192 | if (!_res.retrans) | 206 | if (!_resp->retrans) |
193 | _res.retrans = RES_TIMEOUT; | 207 | _resp->retrans = RES_TIMEOUT; |
194 | if (!_res.retry) | 208 | if (!_resp->retry) |
195 | _res.retry = 4; | 209 | _resp->retry = 4; |
196 | if (!(_res.options & RES_INIT)) | 210 | if (!(_resp->options & RES_INIT)) |
197 | _res.options = RES_DEFAULT; | 211 | _resp->options = RES_DEFAULT; |
198 | 212 | ||
199 | #ifdef USELOOPBACK | 213 | #ifdef USELOOPBACK |
200 | _res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1); | 214 | _resp->nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1); |
201 | #else | 215 | #else |
202 | _res.nsaddr.sin_addr.s_addr = INADDR_ANY; | 216 | _resp->nsaddr.sin_addr.s_addr = INADDR_ANY; |
203 | #endif | 217 | #endif |
204 | _res.nsaddr.sin_family = AF_INET; | 218 | _resp->nsaddr.sin_family = AF_INET; |
205 | _res.nsaddr.sin_port = htons(NAMESERVER_PORT); | 219 | _resp->nsaddr.sin_port = htons(NAMESERVER_PORT); |
206 | _res.nsaddr.sin_len = sizeof(struct sockaddr_in); | 220 | _resp->nsaddr.sin_len = sizeof(struct sockaddr_in); |
207 | #ifdef INET6 | 221 | #ifdef INET6 |
208 | if (sizeof(_res_ext.nsaddr) >= _res.nsaddr.sin_len) | 222 | if (sizeof(_res_extp->nsaddr) >= _resp->nsaddr.sin_len) |
209 | memcpy(&_res_ext.nsaddr, &_res.nsaddr, _res.nsaddr.sin_len); | 223 | memcpy(&_res_extp->nsaddr, &_resp->nsaddr, _resp->nsaddr.sin_len); |
210 | #endif | 224 | #endif |
211 | _res.nscount = 1; | 225 | _resp->nscount = 1; |
212 | _res.ndots = 1; | 226 | _resp->ndots = 1; |
213 | _res.pfcode = 0; | 227 | _resp->pfcode = 0; |
214 | strlcpy(_res.lookups, "f", sizeof _res.lookups); | 228 | strlcpy(_resp->lookups, "f", sizeof _resp->lookups); |
215 | 229 | ||
216 | /* Allow user to override the local domain definition */ | 230 | /* Allow user to override the local domain definition */ |
217 | if (issetugid() == 0 && (cp = getenv("LOCALDOMAIN")) != NULL) { | 231 | if (issetugid() == 0 && (cp = getenv("LOCALDOMAIN")) != NULL) { |
218 | strlcpy(_res.defdname, cp, sizeof(_res.defdname)); | 232 | strlcpy(_resp->defdname, cp, sizeof(_resp->defdname)); |
219 | haveenv++; | 233 | haveenv++; |
220 | 234 | ||
221 | /* | 235 | /* |
@@ -225,10 +239,10 @@ res_init() | |||
225 | * one that they want to use as an individual (even more | 239 | * one that they want to use as an individual (even more |
226 | * important now that the rfc1535 stuff restricts searches) | 240 | * important now that the rfc1535 stuff restricts searches) |
227 | */ | 241 | */ |
228 | cp = _res.defdname; | 242 | cp = _resp->defdname; |
229 | pp = _res.dnsrch; | 243 | pp = _resp->dnsrch; |
230 | *pp++ = cp; | 244 | *pp++ = cp; |
231 | for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) { | 245 | for (n = 0; *cp && pp < _resp->dnsrch + MAXDNSRCH; cp++) { |
232 | if (*cp == '\n') /* silly backwards compat */ | 246 | if (*cp == '\n') /* silly backwards compat */ |
233 | break; | 247 | break; |
234 | else if (*cp == ' ' || *cp == '\t') { | 248 | else if (*cp == ' ' || *cp == '\t') { |
@@ -253,7 +267,7 @@ res_init() | |||
253 | line[sizeof(name) - 1] == '\t')) | 267 | line[sizeof(name) - 1] == '\t')) |
254 | 268 | ||
255 | if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { | 269 | if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { |
256 | strlcpy(_res.lookups, "bf", sizeof _res.lookups); | 270 | strlcpy(_resp->lookups, "bf", sizeof _resp->lookups); |
257 | 271 | ||
258 | /* read the config file */ | 272 | /* read the config file */ |
259 | buf[0] = '\0'; | 273 | buf[0] = '\0'; |
@@ -277,8 +291,8 @@ res_init() | |||
277 | cp++; | 291 | cp++; |
278 | if ((*cp == '\0') || (*cp == '\n')) | 292 | if ((*cp == '\0') || (*cp == '\n')) |
279 | continue; | 293 | continue; |
280 | strlcpy(_res.defdname, cp, sizeof(_res.defdname)); | 294 | strlcpy(_resp->defdname, cp, sizeof(_resp->defdname)); |
281 | if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL) | 295 | if ((cp = strpbrk(_resp->defdname, " \t\n")) != NULL) |
282 | *cp = '\0'; | 296 | *cp = '\0'; |
283 | havesearch = 0; | 297 | havesearch = 0; |
284 | continue; | 298 | continue; |
@@ -287,7 +301,7 @@ res_init() | |||
287 | if (MATCH(buf, "lookup")) { | 301 | if (MATCH(buf, "lookup")) { |
288 | char *sp = NULL; | 302 | char *sp = NULL; |
289 | 303 | ||
290 | bzero(_res.lookups, sizeof _res.lookups); | 304 | bzero(_resp->lookups, sizeof _resp->lookups); |
291 | cp = buf + sizeof("lookup") - 1; | 305 | cp = buf + sizeof("lookup") - 1; |
292 | for (n = 0;; cp++) { | 306 | for (n = 0;; cp++) { |
293 | if (n == MAXDNSLUS) | 307 | if (n == MAXDNSLUS) |
@@ -295,14 +309,14 @@ res_init() | |||
295 | if ((*cp == '\0') || (*cp == '\n')) { | 309 | if ((*cp == '\0') || (*cp == '\n')) { |
296 | if (sp) { | 310 | if (sp) { |
297 | if (*sp=='y' || *sp=='b' || *sp=='f') | 311 | if (*sp=='y' || *sp=='b' || *sp=='f') |
298 | _res.lookups[n++] = *sp; | 312 | _resp->lookups[n++] = *sp; |
299 | sp = NULL; | 313 | sp = NULL; |
300 | } | 314 | } |
301 | break; | 315 | break; |
302 | } else if ((*cp == ' ') || (*cp == '\t') || (*cp == ',')) { | 316 | } else if ((*cp == ' ') || (*cp == '\t') || (*cp == ',')) { |
303 | if (sp) { | 317 | if (sp) { |
304 | if (*sp=='y' || *sp=='b' || *sp=='f') | 318 | if (*sp=='y' || *sp=='b' || *sp=='f') |
305 | _res.lookups[n++] = *sp; | 319 | _resp->lookups[n++] = *sp; |
306 | sp = NULL; | 320 | sp = NULL; |
307 | } | 321 | } |
308 | } else if (sp == NULL) | 322 | } else if (sp == NULL) |
@@ -319,17 +333,17 @@ res_init() | |||
319 | cp++; | 333 | cp++; |
320 | if ((*cp == '\0') || (*cp == '\n')) | 334 | if ((*cp == '\0') || (*cp == '\n')) |
321 | continue; | 335 | continue; |
322 | strlcpy(_res.defdname, cp, sizeof(_res.defdname)); | 336 | strlcpy(_resp->defdname, cp, sizeof(_resp->defdname)); |
323 | if ((cp = strchr(_res.defdname, '\n')) != NULL) | 337 | if ((cp = strchr(_resp->defdname, '\n')) != NULL) |
324 | *cp = '\0'; | 338 | *cp = '\0'; |
325 | /* | 339 | /* |
326 | * Set search list to be blank-separated strings | 340 | * Set search list to be blank-separated strings |
327 | * on rest of line. | 341 | * on rest of line. |
328 | */ | 342 | */ |
329 | cp = _res.defdname; | 343 | cp = _resp->defdname; |
330 | pp = _res.dnsrch; | 344 | pp = _resp->dnsrch; |
331 | *pp++ = cp; | 345 | *pp++ = cp; |
332 | for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) { | 346 | for (n = 0; *cp && pp < _resp->dnsrch + MAXDNSRCH; cp++) { |
333 | if (*cp == ' ' || *cp == '\t') { | 347 | if (*cp == ' ' || *cp == '\t') { |
334 | *cp = 0; | 348 | *cp = 0; |
335 | n = 1; | 349 | n = 1; |
@@ -375,19 +389,19 @@ res_init() | |||
375 | res = NULL; | 389 | res = NULL; |
376 | if (getaddrinfo(cp, pbuf, &hints, &res) == 0 && | 390 | if (getaddrinfo(cp, pbuf, &hints, &res) == 0 && |
377 | res->ai_next == NULL) { | 391 | res->ai_next == NULL) { |
378 | if (res->ai_addrlen <= sizeof(_res_ext.nsaddr_list[nserv])) { | 392 | if (res->ai_addrlen <= sizeof(_res_extp->nsaddr_list[nserv])) { |
379 | memcpy(&_res_ext.nsaddr_list[nserv], res->ai_addr, | 393 | memcpy(&_res_extp->nsaddr_list[nserv], res->ai_addr, |
380 | res->ai_addrlen); | 394 | res->ai_addrlen); |
381 | } else { | 395 | } else { |
382 | memset(&_res_ext.nsaddr_list[nserv], 0, | 396 | memset(&_res_extp->nsaddr_list[nserv], 0, |
383 | sizeof(_res_ext.nsaddr_list[nserv])); | 397 | sizeof(_res_extp->nsaddr_list[nserv])); |
384 | } | 398 | } |
385 | if (res->ai_addrlen <= sizeof(_res.nsaddr_list[nserv])) { | 399 | if (res->ai_addrlen <= sizeof(_resp->nsaddr_list[nserv])) { |
386 | memcpy(&_res.nsaddr_list[nserv], res->ai_addr, | 400 | memcpy(&_resp->nsaddr_list[nserv], res->ai_addr, |
387 | res->ai_addrlen); | 401 | res->ai_addrlen); |
388 | } else { | 402 | } else { |
389 | memset(&_res.nsaddr_list[nserv], 0, | 403 | memset(&_resp->nsaddr_list[nserv], 0, |
390 | sizeof(_res.nsaddr_list[nserv])); | 404 | sizeof(_resp->nsaddr_list[nserv])); |
391 | } | 405 | } |
392 | nserv++; | 406 | nserv++; |
393 | } | 407 | } |
@@ -395,11 +409,11 @@ res_init() | |||
395 | freeaddrinfo(res); | 409 | freeaddrinfo(res); |
396 | #else /* INET6 */ | 410 | #else /* INET6 */ |
397 | if ((*cp != '\0') && (*cp != '\n') && inet_aton(cp, &a)) { | 411 | if ((*cp != '\0') && (*cp != '\n') && inet_aton(cp, &a)) { |
398 | _res.nsaddr_list[nserv].sin_addr = a; | 412 | _resp->nsaddr_list[nserv].sin_addr = a; |
399 | _res.nsaddr_list[nserv].sin_family = AF_INET; | 413 | _resp->nsaddr_list[nserv].sin_family = AF_INET; |
400 | _res.nsaddr_list[nserv].sin_port = | 414 | _resp->nsaddr_list[nserv].sin_port = |
401 | htons(NAMESERVER_PORT); | 415 | htons(NAMESERVER_PORT); |
402 | _res.nsaddr_list[nserv].sin_len = | 416 | _resp->nsaddr_list[nserv].sin_len = |
403 | sizeof(struct sockaddr_in); | 417 | sizeof(struct sockaddr_in); |
404 | nserv++; | 418 | nserv++; |
405 | } | 419 | } |
@@ -428,7 +442,7 @@ res_init() | |||
428 | n = *cp; | 442 | n = *cp; |
429 | *cp = 0; | 443 | *cp = 0; |
430 | if (inet_aton(net, &a)) { | 444 | if (inet_aton(net, &a)) { |
431 | _res.sort_list[nsort].addr = a; | 445 | _resp->sort_list[nsort].addr = a; |
432 | if (ISSORTMASK(n)) { | 446 | if (ISSORTMASK(n)) { |
433 | *cp++ = n; | 447 | *cp++ = n; |
434 | net = cp; | 448 | net = cp; |
@@ -438,29 +452,29 @@ res_init() | |||
438 | n = *cp; | 452 | n = *cp; |
439 | *cp = 0; | 453 | *cp = 0; |
440 | if (inet_aton(net, &a)) { | 454 | if (inet_aton(net, &a)) { |
441 | _res.sort_list[nsort].mask = a.s_addr; | 455 | _resp->sort_list[nsort].mask = a.s_addr; |
442 | } else { | 456 | } else { |
443 | _res.sort_list[nsort].mask = | 457 | _resp->sort_list[nsort].mask = |
444 | net_mask(_res.sort_list[nsort].addr); | 458 | net_mask(_resp->sort_list[nsort].addr); |
445 | } | 459 | } |
446 | } else { | 460 | } else { |
447 | _res.sort_list[nsort].mask = | 461 | _resp->sort_list[nsort].mask = |
448 | net_mask(_res.sort_list[nsort].addr); | 462 | net_mask(_resp->sort_list[nsort].addr); |
449 | } | 463 | } |
450 | #ifdef INET6 | 464 | #ifdef INET6 |
451 | _res_ext.sort_list[nsort].af = AF_INET; | 465 | _res_extp->sort_list[nsort].af = AF_INET; |
452 | _res_ext.sort_list[nsort].addr.ina = | 466 | _res_extp->sort_list[nsort].addr.ina = |
453 | _res.sort_list[nsort].addr; | 467 | _resp->sort_list[nsort].addr; |
454 | _res_ext.sort_list[nsort].mask.ina.s_addr = | 468 | _res_extp->sort_list[nsort].mask.ina.s_addr = |
455 | _res.sort_list[nsort].mask; | 469 | _resp->sort_list[nsort].mask; |
456 | #endif /* INET6 */ | 470 | #endif /* INET6 */ |
457 | nsort++; | 471 | nsort++; |
458 | } | 472 | } |
459 | #ifdef INET6 | 473 | #ifdef INET6 |
460 | else if (inet_pton(AF_INET6, net, &a6) == 1) { | 474 | else if (inet_pton(AF_INET6, net, &a6) == 1) { |
461 | _res_ext.sort_list[nsort].af = AF_INET6; | 475 | _res_extp->sort_list[nsort].af = AF_INET6; |
462 | _res_ext.sort_list[nsort].addr.in6a = a6; | 476 | _res_extp->sort_list[nsort].addr.in6a = a6; |
463 | u = (u_char *)&_res_ext.sort_list[nsort].mask.in6a; | 477 | u = (u_char *)&_res_extp->sort_list[nsort].mask.in6a; |
464 | *cp++ = n; | 478 | *cp++ = n; |
465 | net = cp; | 479 | net = cp; |
466 | while (*cp && *cp != ';' && | 480 | while (*cp && *cp != ';' && |
@@ -510,33 +524,33 @@ res_init() | |||
510 | } | 524 | } |
511 | } | 525 | } |
512 | if (nserv > 1) | 526 | if (nserv > 1) |
513 | _res.nscount = nserv; | 527 | _resp->nscount = nserv; |
514 | #ifdef RESOLVSORT | 528 | #ifdef RESOLVSORT |
515 | _res.nsort = nsort; | 529 | _resp->nsort = nsort; |
516 | #endif | 530 | #endif |
517 | (void) fclose(fp); | 531 | (void) fclose(fp); |
518 | } | 532 | } |
519 | if (_res.defdname[0] == 0 && | 533 | if (_resp->defdname[0] == 0 && |
520 | gethostname(buf, sizeof(_res.defdname) - 1) == 0 && | 534 | gethostname(buf, sizeof(_resp->defdname) - 1) == 0 && |
521 | (cp = strchr(buf, '.')) != NULL) | 535 | (cp = strchr(buf, '.')) != NULL) |
522 | { | 536 | { |
523 | strlcpy(_res.defdname, cp + 1, | 537 | strlcpy(_resp->defdname, cp + 1, |
524 | sizeof(_res.defdname)); | 538 | sizeof(_resp->defdname)); |
525 | } | 539 | } |
526 | 540 | ||
527 | /* find components of local domain that might be searched */ | 541 | /* find components of local domain that might be searched */ |
528 | if (havesearch == 0) { | 542 | if (havesearch == 0) { |
529 | pp = _res.dnsrch; | 543 | pp = _resp->dnsrch; |
530 | *pp++ = _res.defdname; | 544 | *pp++ = _resp->defdname; |
531 | *pp = NULL; | 545 | *pp = NULL; |
532 | 546 | ||
533 | #ifndef RFC1535 | 547 | #ifndef RFC1535 |
534 | dots = 0; | 548 | dots = 0; |
535 | for (cp = _res.defdname; *cp; cp++) | 549 | for (cp = _resp->defdname; *cp; cp++) |
536 | dots += (*cp == '.'); | 550 | dots += (*cp == '.'); |
537 | 551 | ||
538 | cp = _res.defdname; | 552 | cp = _resp->defdname; |
539 | while (pp < _res.dnsrch + MAXDFLSRCH) { | 553 | while (pp < _resp->dnsrch + MAXDFLSRCH) { |
540 | if (dots < LOCALDOMAINPARTS) | 554 | if (dots < LOCALDOMAINPARTS) |
541 | break; | 555 | break; |
542 | cp = strchr(cp, '.') + 1; /* we know there is one */ | 556 | cp = strchr(cp, '.') + 1; /* we know there is one */ |
@@ -545,9 +559,9 @@ res_init() | |||
545 | } | 559 | } |
546 | *pp = NULL; | 560 | *pp = NULL; |
547 | #ifdef DEBUG | 561 | #ifdef DEBUG |
548 | if (_res.options & RES_DEBUG) { | 562 | if (_resp->options & RES_DEBUG) { |
549 | printf(";; res_init()... default dnsrch list:\n"); | 563 | printf(";; res_init()... default dnsrch list:\n"); |
550 | for (pp = _res.dnsrch; *pp; pp++) | 564 | for (pp = _resp->dnsrch; *pp; pp++) |
551 | printf(";;\t%s\n", *pp); | 565 | printf(";;\t%s\n", *pp); |
552 | printf(";;\t..END..\n"); | 566 | printf(";;\t..END..\n"); |
553 | } | 567 | } |
@@ -556,10 +570,10 @@ res_init() | |||
556 | } | 570 | } |
557 | 571 | ||
558 | if (issetugid()) | 572 | if (issetugid()) |
559 | _res.options |= RES_NOALIASES; | 573 | _resp->options |= RES_NOALIASES; |
560 | else if ((cp = getenv("RES_OPTIONS")) != NULL) | 574 | else if ((cp = getenv("RES_OPTIONS")) != NULL) |
561 | res_setoptions(cp, "env"); | 575 | res_setoptions(cp, "env"); |
562 | _res.options |= RES_INIT; | 576 | _resp->options |= RES_INIT; |
563 | return (0); | 577 | return (0); |
564 | } | 578 | } |
565 | 579 | ||
@@ -568,12 +582,13 @@ static void | |||
568 | res_setoptions(options, source) | 582 | res_setoptions(options, source) |
569 | char *options, *source; | 583 | char *options, *source; |
570 | { | 584 | { |
585 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); | ||
571 | char *cp = options; | 586 | char *cp = options; |
572 | char *endp; | 587 | char *endp; |
573 | long l; | 588 | long l; |
574 | 589 | ||
575 | #ifdef DEBUG | 590 | #ifdef DEBUG |
576 | if (_res.options & RES_DEBUG) | 591 | if (_resp->options & RES_DEBUG) |
577 | printf(";; res_setoptions(\"%s\", \"%s\")...\n", | 592 | printf(";; res_setoptions(\"%s\", \"%s\")...\n", |
578 | options, source); | 593 | options, source); |
579 | #endif | 594 | #endif |
@@ -588,31 +603,31 @@ res_setoptions(options, source) | |||
588 | if (l >= 0 && endp != p && | 603 | if (l >= 0 && endp != p && |
589 | (*endp = '\0' || isspace(*endp))) { | 604 | (*endp = '\0' || isspace(*endp))) { |
590 | if (l <= RES_MAXNDOTS) | 605 | if (l <= RES_MAXNDOTS) |
591 | _res.ndots = l; | 606 | _resp->ndots = l; |
592 | else | 607 | else |
593 | _res.ndots = RES_MAXNDOTS; | 608 | _resp->ndots = RES_MAXNDOTS; |
594 | #ifdef DEBUG | 609 | #ifdef DEBUG |
595 | if (_res.options & RES_DEBUG) | 610 | if (_resp->options & RES_DEBUG) |
596 | printf(";;\tndots=%u\n", _res.ndots); | 611 | printf(";;\tndots=%u\n", _resp->ndots); |
597 | #endif | 612 | #endif |
598 | } | 613 | } |
599 | } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) { | 614 | } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) { |
600 | #ifdef DEBUG | 615 | #ifdef DEBUG |
601 | if (!(_res.options & RES_DEBUG)) { | 616 | if (!(_resp->options & RES_DEBUG)) { |
602 | printf(";; res_setoptions(\"%s\", \"%s\")..\n", | 617 | printf(";; res_setoptions(\"%s\", \"%s\")..\n", |
603 | options, source); | 618 | options, source); |
604 | _res.options |= RES_DEBUG; | 619 | _resp->options |= RES_DEBUG; |
605 | } | 620 | } |
606 | printf(";;\tdebug\n"); | 621 | printf(";;\tdebug\n"); |
607 | #endif | 622 | #endif |
608 | } else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) { | 623 | } else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) { |
609 | _res.options |= RES_USE_INET6; | 624 | _resp->options |= RES_USE_INET6; |
610 | } else if (!strncmp(cp, "insecure1", sizeof("insecure1") - 1)) { | 625 | } else if (!strncmp(cp, "insecure1", sizeof("insecure1") - 1)) { |
611 | _res.options |= RES_INSECURE1; | 626 | _resp->options |= RES_INSECURE1; |
612 | } else if (!strncmp(cp, "insecure2", sizeof("insecure2") - 1)) { | 627 | } else if (!strncmp(cp, "insecure2", sizeof("insecure2") - 1)) { |
613 | _res.options |= RES_INSECURE2; | 628 | _resp->options |= RES_INSECURE2; |
614 | } else if (!strncmp(cp, "edns0", sizeof("edns0") - 1)) { | 629 | } else if (!strncmp(cp, "edns0", sizeof("edns0") - 1)) { |
615 | _res.options |= RES_USE_EDNS0; | 630 | _resp->options |= RES_USE_EDNS0; |
616 | } else { | 631 | } else { |
617 | /* XXX - print a warning here? */ | 632 | /* XXX - print a warning here? */ |
618 | } | 633 | } |