summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2014-11-17 16:18:20 +0000
committerkrw <krw@openbsd.org>2014-11-17 16:18:20 +0000
commit9cfa73d5f58ac41363233ddb21911f97ba646772 (patch)
tree7eaecd329b8726c1d3fd66823b67bfa8cd831b74
parent"reload" should fail if the service is not running in the first place. (diff)
downloadwireguard-openbsd-9cfa73d5f58ac41363233ddb21911f97ba646772.tar.xz
wireguard-openbsd-9cfa73d5f58ac41363233ddb21911f97ba646772.zip
Further juggle startup code, putting config file reading after forking
the priv child but before getting hardware link. Reducing further the possibly inappropriate information the priv child could read.
-rw-r--r--sbin/dhclient/dhclient.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index a1572c00b8c..ee8a46d7f33 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.331 2014/11/16 21:05:24 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.332 2014/11/17 16:18:20 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -462,11 +462,6 @@ main(int argc, char *argv[])
ifi = calloc(1, sizeof(*ifi));
if (ifi == NULL)
error("ifi calloc");
- config = calloc(1, sizeof(*config));
- if (config == NULL)
- error("config calloc");
- TAILQ_INIT(&config->reject_list);
-
get_ifname(argv[0]);
tzset();
@@ -477,6 +472,22 @@ main(int argc, char *argv[])
error("setting routing table to %u: '%s'", ifi->rdomain,
strerror(errno));
+ if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC,
+ PF_UNSPEC, socket_fd) == -1)
+ error("socketpair: %s", strerror(errno));
+
+ fork_privchld(socket_fd[0], socket_fd[1]);
+
+ close(socket_fd[0]);
+ if ((unpriv_ibuf = malloc(sizeof(struct imsgbuf))) == NULL)
+ error("no memory for unpriv_ibuf");
+ imsg_init(unpriv_ibuf, socket_fd[1]);
+
+ config = calloc(1, sizeof(*config));
+ if (config == NULL)
+ error("config calloc");
+ TAILQ_INIT(&config->reject_list);
+
read_client_conf(); /* Needed for config->link_timeout below! */
if (interface_status(ifi->name) == 0) {
@@ -515,17 +526,6 @@ main(int argc, char *argv[])
if_register_receive();
if_register_send();
- if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC,
- PF_UNSPEC, socket_fd) == -1)
- error("socketpair: %s", strerror(errno));
-
- fork_privchld(socket_fd[0], socket_fd[1]);
-
- close(socket_fd[0]);
- if ((unpriv_ibuf = malloc(sizeof(struct imsgbuf))) == NULL)
- error("no memory for unpriv_ibuf");
- imsg_init(unpriv_ibuf, socket_fd[1]);
-
if (path_dhclient_db == NULL && asprintf(&path_dhclient_db, "%s.%s",
_PATH_DHCLIENT_DB, ifi->name) == -1)
error("asprintf");