summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2005-12-22 06:52:12 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2005-12-22 06:52:12 +0000
commita0e3210399ceb6e15617efea2146d974cfd89535 (patch)
treeb2b34dcd1a07838ccf085afb3bb5a6923b98b6fb /lib
parent15c2043021cc17276cdd34a76c55dddd8105cc96 (diff)
handle chroot and res_init calls better. diagnosis assistance from otto.
ok deraadt otto.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/res_init.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/lib/libc/net/res_init.c b/lib/libc/net/res_init.c
index 62ccb94630f..43ee5ac6bb2 100644
--- a/lib/libc/net/res_init.c
+++ b/lib/libc/net/res_init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_init.c,v 1.33 2005/08/06 20:30:04 espie Exp $ */
+/* $OpenBSD: res_init.c,v 1.34 2005/12/22 06:52:11 tedu Exp $ */
/*
* ++Copyright++ 1985, 1989, 1993
@@ -178,27 +178,24 @@ _res_init(int usercall)
int dots;
#endif
- if (usercall == 0) {
- if (_resp->options & RES_INIT &&
- _resp->reschktime >= time(NULL))
+ if (!usercall && _resp->options & RES_INIT &&
+ _resp->reschktime >= time(NULL))
+ return (0);
+ _resp->reschktime = time(NULL) + __res_chktime;
+ if (stat(_PATH_RESCONF, &sb) != -1) {
+ if (!usercall && timespeccmp(&sb.st_mtimespec,
+ &_resp->restimespec, ==))
return (0);
- _resp->reschktime = time(NULL) + __res_chktime;
- if (stat(_PATH_RESCONF, &sb) != -1) {
- if (timespeccmp(&sb.st_mtimespec,
- &_resp->restimespec, ==))
- return (0);
- else
- _resp->restimespec = sb.st_mtimespec;
- } else {
- /*
- * Lost the file, in chroot?
- * Don' trash settings
- */
- if (timespecisset(&_resp->restimespec))
- return (0);
- }
- } else
- _resp->reschktime = time(NULL) + __res_chktime;
+ else
+ _resp->restimespec = sb.st_mtimespec;
+ } else {
+ /*
+ * Lost the file, in chroot?
+ * Don't trash settings
+ */
+ if (!usercall && timespecisset(&_resp->restimespec))
+ return (0);
+ }
/*