summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2014-07-11 21:08:21 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2014-07-11 21:08:21 +0000
commit10547d2b941f36db6efd503b08b962cf6491fa43 (patch)
tree0823d11d1d8eae5cc0bae58b55978fb22499f2bb /sbin/dhclient/dhclient.c
parent5d2b02e4488800ac59b6fbb22b4a23253de2da79 (diff)
Sigh. Further torture finds a race. Back to drawing board for
reducing resolv.conf writing.
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r--sbin/dhclient/dhclient.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 287006b5829..864efd1360d 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.314 2014/07/11 20:41:41 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.315 2014/07/11 21:08:20 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -304,8 +304,6 @@ routehandler(void)
memset(&b, 0, sizeof(b));
add_address(ifi->name, 0, b, b);
quit = INTERNALSIG;
- /* No need to write out our resolv.conf. */
- client->flags &= ~IS_RESPONSIBLE;
break;
}
if (deleting.s_addr != INADDR_ANY) {
@@ -370,8 +368,7 @@ routehandler(void)
}
/* Something has happened. Try to write out the resolv.conf. */
- if (client->active && client->active->resolv_conf &&
- client->flags & IS_RESPONSIBLE)
+ if (client->active && client->active->resolv_conf)
write_file("/etc/resolv.conf",
O_WRONLY | O_CREAT | O_TRUNC | O_SYNC | O_EXLOCK,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, 0, 0,
@@ -843,13 +840,6 @@ bind_lease(void)
goto newlease;
}
- client->new->resolv_conf = resolv_conf_contents(
- &options[DHO_DOMAIN_NAME], &options[DHO_DOMAIN_NAME_SERVERS]);
-
- /* Replace the old active lease with the new one. */
- client->active = client->new;
- client->new = NULL;
-
/* Deleting the addresses also clears out arp entries. */
delete_addresses(ifi->name, ifi->rdomain);
flush_routes(ifi->name, ifi->rdomain);
@@ -899,7 +889,18 @@ bind_lease(void)
&options[DHO_STATIC_ROUTES]);
}
+ client->new->resolv_conf = resolv_conf_contents(
+ &options[DHO_DOMAIN_NAME], &options[DHO_DOMAIN_NAME_SERVERS]);
+ if (client->new->resolv_conf)
+ write_file("/etc/resolv.conf",
+ O_WRONLY | O_CREAT | O_TRUNC | O_SYNC | O_EXLOCK,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, 0, 0,
+ client->new->resolv_conf, strlen(client->new->resolv_conf));
+
newlease:
+ /* Replace the old active lease with the new one. */
+ client->active = client->new;
+ client->new = NULL;
rewrite_option_db(client->active, lease);
free_client_lease(lease);