diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-07-11 20:19:31 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-07-11 20:19:31 +0000 |
commit | 8324616f00def549000758766ac2837fd500c635 (patch) | |
tree | 626ffb9ad4dcd7baabcb95a29c6f9171c5fb8e9d /sbin | |
parent | ddf2470b2e659ff6d94d5a9598f87946299a38c4 (diff) |
Don't write out a new resolv.conf until the new address is added
and we become responsible for the interface. Don't write out a new
resolv.conf when our address has been deleted and we are no longer
responsible for the interface. Less writing is more better.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/dhclient.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 8ab2ba4269b..89a08a98d21 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.312 2014/07/09 15:16:38 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.313 2014/07/11 20:19:30 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -304,6 +304,8 @@ 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) { @@ -368,7 +370,8 @@ routehandler(void) } /* Something has happened. Try to write out the resolv.conf. */ - if (client->active && client->active->resolv_conf) + if (client->active && client->active->resolv_conf && + client->flags & IS_RESPONSIBLE) 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, @@ -891,11 +894,6 @@ bind_lease(void) 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. */ |