diff options
Diffstat (limited to 'sbin/dhclient/kroute.c')
-rw-r--r-- | sbin/dhclient/kroute.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c index 6db356bf9ef..d9d6b16b871 100644 --- a/sbin/dhclient/kroute.c +++ b/sbin/dhclient/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.138 2017/08/14 22:12:59 krw Exp $ */ +/* $OpenBSD: kroute.c,v 1.139 2017/08/18 15:06:11 krw Exp $ */ /* * Copyright 2012 Kenneth R Westerback <krw@openbsd.org> @@ -553,6 +553,9 @@ priv_write_resolv_conf(char *contents) size_t sz; int fd; + if (contents == NULL) + return; + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); @@ -561,15 +564,13 @@ priv_write_resolv_conf(char *contents) return; } - if (contents != NULL) { - sz = strlen(contents); - n = write(fd, contents, sz); - if (n == -1) - log_warn("Couldn't write contents to '%s'", path); - else if ((size_t)n < sz) - log_warnx("Short contents write to '%s' (%zd vs %zu)", - path, n, sz); - } + sz = strlen(contents); + n = write(fd, contents, sz); + if (n == -1) + log_warn("Couldn't write contents to '%s'", path); + else if ((size_t)n < sz) + log_warnx("Short contents write to '%s' (%zd vs %zu)", + path, n, sz); close(fd); } @@ -704,7 +705,8 @@ set_resolv_conf(char *name, uint8_t *rtsearch, unsigned int rtsearch_len, if (len == 0) { free(dn); - return; + contents = NULL; + goto done; } rslt = asprintf(&courtesy, "# Generated by %s dhclient\n", name); @@ -733,6 +735,7 @@ set_resolv_conf(char *name, uint8_t *rtsearch, unsigned int rtsearch_len, if (config->resolv_tail != NULL) strlcat(contents, config->resolv_tail, len); +done: rslt = imsg_compose(unpriv_ibuf, IMSG_SET_RESOLV_CONF, 0, 0, -1, contents, len); if (rslt == -1) |