}
#endif
+#ifdef PRIVSEP
+ ps_init(&ctx);
+#endif
+
#ifndef SMALL
if (ctx.options & DHCPCD_DUMPLEASE &&
ioctl(fileno(stdin), FIONREAD, &i, sizeof(i)) == 0 &&
i > 0)
{
+ ctx.options |= DHCPCD_FORKED; /* pretend child process */
+#ifdef PRIVSEP
+ if (IN_PRIVSEP(&ctx) && ps_mastersandbox(&ctx) == -1)
+ goto exit_failure;
+#endif
ifp = calloc(1, sizeof(*ifp));
if (ifp == NULL) {
logerr(__func__);
if (freopen(_PATH_DEVNULL, "r", stdin) == NULL)
logerr("%s: freopen stdin", __func__);
-
-#ifdef PRIVSEP
- ps_init(&ctx);
-#endif
-
#if defined(USE_SIGNALS) && !defined(THERE_IS_NO_FORK)
if (xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, fork_fd) == -1 ||
xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, stderr_fd) == -1)
}
#ifdef PRIVSEP_RIGHTS
- if (ps_rights_limit_ioctl(ctx->pf_inet_fd) == -1 ||
- ps_rights_limit_fd(ctx->link_fd) == -1 ||
+ if ((ctx->pf_inet_fd != -1 &&
+ ps_rights_limit_ioctl(ctx->pf_inet_fd) == -1) ||
+ (ctx->link_fd != -1 && ps_rights_limit_fd(ctx->link_fd) == -1) ||
ps_rights_limit_stdio() == -1)
{
logerr("%s: cap_rights_limit", __func__);