ps_root_readerrorcb, &psr_ctx) == -1)
return -1;
+ eloop_enter(ctx->ps_eloop);
eloop_start(ctx->ps_eloop, &ctx->sigset);
errno = psr_ctx.psr_error.psr_errno;
ps_root_mreaderrorcb, &psr_ctx) == -1)
return -1;
+ eloop_enter(ctx->ps_eloop);
eloop_start(ctx->ps_eloop, &ctx->sigset);
errno = psr_ctx.psr_error.psr_errno;
ps_freeprocess(psp);
return ret;
- } else if (!(psm->ps_cmd & PS_START))
- return ps_sendpsmmsg(ctx, psp->psp_fd, psm, msg);
- /* Process has already started .... */
+ } else if (psm->ps_cmd & PS_START) {
+ /* Process has already started .... */
+ return 0;
+ }
+
+ err = ps_sendpsmmsg(ctx, psp->psp_fd, psm, msg);
+ if (err == -1) {
+ logerr("%s: failed to send message to pid %d",
+ __func__, psp->psp_pid);
+ shutdown(psp->psp_fd, SHUT_RDWR);
+ close(psp->psp_fd);
+ psp->psp_fd = -1;
+ ps_dostop(ctx, &psp->psp_pid, &psp->psp_fd);
+ ps_freeprocess(psp);
+ }
return 0;
}
(void)ps_sendcmd(ctx, *priv_fd, PS_STOP, 0, NULL, 0);
shutdown(*priv_fd, SHUT_RDWR);
*priv_fd = -1;
+ eloop_exit(ctx->eloop, EXIT_FAILURE);
return -1;
}
#endif
if (*pid == 0)
return 0;
+ if (*fd == -1)
+ goto wait;
+
eloop_event_delete(ctx->eloop, *fd);
if (ps_sendcmd(ctx, *fd, PS_STOP, 0, NULL, 0) == -1 &&
errno != ECONNRESET)
logerr(__func__);
close(*fd);
*fd = -1;
- /* We won't have permission for all processes .... */
-#if 0
- if (kill(*pid, SIGTERM) == -1)
- logerr(__func__);
-#endif
+
+wait:
status = 0;
#ifdef HAVE_CAPSICUM
#ifdef PRIVSEP_DEBUG
logdebugx("%s: %zd", __func__, len);
#endif
- if ((len == -1 || len == 0) && ctx->options & DHCPCD_FORKED)
+ if ((len == -1 || len == 0) && ctx->options & DHCPCD_FORKED &&
+ !(ctx->options & DHCPCD_PRIVSEPROOT))
eloop_exit(ctx->eloop, len == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
return len;
}
#ifdef PRIVSEP_DEBUG
logdebugx("%s: recv fd %d, %zd bytes", __func__, rfd, len);
#endif
- if ((len == -1 || len == 0) && ctx->options & DHCPCD_FORKED) {
- eloop_exit(ctx->eloop, len == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+
+ if (len == -1 || len == 0) {
+ if (ctx->options & DHCPCD_FORKED &&
+ !(ctx->options & DHCPCD_PRIVSEPROOT))
+ eloop_exit(ctx->eloop,
+ len == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
return len;
}
#ifdef PRIVSEP_DEBUG
logdebugx("%s: send fd %d, %zu bytes", __func__, wfd, len);
#endif
- if ((len == -1 || len == 0) && ctx->options & DHCPCD_FORKED)
+ if ((len == -1 || len == 0) && ctx->options & DHCPCD_FORKED &&
+ !(ctx->options & DHCPCD_PRIVSEPROOT))
eloop_exit(ctx->eloop, len == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
return len;
}