summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/dhclient.c20
-rw-r--r--sbin/dhclient/privsep.h3
2 files changed, 18 insertions, 5 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 5fc75992c6b..7cd9d46b3d6 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.223 2013/02/02 02:47:16 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.224 2013/02/02 04:18:29 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -291,8 +291,7 @@ routehandler(void)
}
/* Something has happened. Try to write out the resolv.conf. */
- if (client->active && client->active->resolv_conf &&
- resolv_conf_priority(ifi->rdomain))
+ 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,
@@ -1929,7 +1928,7 @@ char *
resolv_conf_contents(struct option_data *domainname,
struct option_data *nameservers)
{
- char *dn, *ns, *nss[MAXNS], *contents, *p;
+ char *dn, *ns, *nss[MAXNS], *contents, *courtesy, *p;
size_t len;
int i, rslt;
@@ -1973,11 +1972,19 @@ resolv_conf_contents(struct option_data *domainname,
return (NULL);
}
+ rslt = asprintf(&courtesy, "# Generated by %s dhclient\n", ifi->name);
+ if (rslt == -1)
+ error("no memory for courtesy line");
+ len += strlen(courtesy);
+
len++; /* Need room for terminating NUL. */
contents = calloc(1, len);
if (contents == NULL)
error("no memory for resolv.conf contents");
+ strlcat(contents, courtesy, len);
+ free(courtesy);
+
strlcat(contents, dn, len);
free(dn);
@@ -2203,6 +2210,7 @@ write_file(char *path, int flags, mode_t mode, uid_t uid, gid_t gid,
size_t rslt;
imsg = calloc(1, sizeof(*imsg) + sz);
+ imsg->rdomain = ifi->rdomain;
rslt = strlcpy(imsg->path, path, MAXPATHLEN);
if (rslt >= MAXPATHLEN) {
@@ -2233,6 +2241,10 @@ priv_write_file(struct imsg_write_file *imsg)
ssize_t n;
int fd;
+ if ((strcmp("/etc/resolv.conf", imsg->path) == 0) &&
+ !resolv_conf_priority(imsg->rdomain))
+ return;
+
fd = open(imsg->path, imsg->flags, imsg->mode);
if (fd == -1) {
note("Couldn't open '%s': %s", imsg->path, strerror(errno));
diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h
index 8e7625323be..89147155b8b 100644
--- a/sbin/dhclient/privsep.h
+++ b/sbin/dhclient/privsep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.h,v 1.13 2013/01/27 02:45:46 krw Exp $ */
+/* $OpenBSD: privsep.h,v 1.14 2013/02/02 04:18:30 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -67,6 +67,7 @@ struct imsg_cleanup {
struct imsg_write_file {
char path[MAXPATHLEN];
+ int rdomain;
int flags;
mode_t mode;
size_t len;