summaryrefslogtreecommitdiffstats
path: root/src/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-09-05 17:01:59 +0100
committerRoy Marples <roy@marples.name>2020-09-05 17:01:59 +0100
commite80f2a5aeaf2e249ca6b6a10090f64c69ea99719 (patch)
tree36f35ea6dca4c3c16e0dc9ba0f93ea47553493c0 /src/dhcpcd.c
parentbb70c7ebdf80a3ee7d5146a877061503bf58c6d4 (diff)
downloaddhcpcd-e80f2a5aeaf2e249ca6b6a10090f64c69ea99719.tar.xz
privsep: Fix prior for FreeBSD.
Diffstat (limited to 'src/dhcpcd.c')
-rw-r--r--src/dhcpcd.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c
index 86b994f8..c8589fe3 100644
--- a/src/dhcpcd.c
+++ b/src/dhcpcd.c
@@ -2246,14 +2246,6 @@ printpidfile:
logerr("socketpair");
goto exit_failure;
}
-#ifdef HAVE_CAPSICUM
- if (ps_rights_limit_fdpair(fork_fd) == -1 ||
- ps_rights_limit_fdpair(stderr_fd) == 1)
- {
- logerr("ps_rights_limit_fdpair");
- goto exit_failure;
- }
-#endif
switch (pid = fork()) {
case -1:
logerr("fork");
@@ -2263,6 +2255,14 @@ printpidfile:
close(fork_fd[0]);
logseterrfd(stderr_fd[1]);
close(stderr_fd[0]);
+#ifdef PRIVSEP_RIGHTS
+ if (ps_rights_limit_fd(fork_fd[1]) == -1 ||
+ ps_rights_limit_fd(stderr_fd[1]) == 1)
+ {
+ logerr("ps_rights_limit_fdpair");
+ goto exit_failure;
+ }
+#endif
if (freopen(_PATH_DEVNULL, "w", stdout) == NULL ||
freopen(_PATH_DEVNULL, "w", stderr) == NULL)
logerr("freopen");
@@ -2289,6 +2289,14 @@ printpidfile:
close(fork_fd[1]);
ctx.stderr_fd = stderr_fd[0];
close(stderr_fd[1]);
+#ifdef PRIVSEP_RIGHTS
+ if (ps_rights_limit_fd(fork_fd[0]) == -1 ||
+ ps_rights_limit_fd(stderr_fd[0]) == 1)
+ {
+ logerr("ps_rights_limit_fdpair");
+ goto exit_failure;
+ }
+#endif
setproctitle("[launcher]");
eloop_event_add(ctx.eloop, ctx.fork_fd, dhcpcd_fork_cb, &ctx);
eloop_event_add(ctx.eloop, ctx.stderr_fd, dhcpcd_stderr_cb, &ctx);