# HG changeset patch # User Roy Marples # Date 1602080913 -3600 # Node ID 7100066d2c7e3ed434d70b3f93cac0e710c49341 # Parent 5b2272a0f3c3be0e1c455e16e1d4e3b38ea4e953 privsep: Only start network proxy if we need to Do this before starting it rather than it shutting down. diff -r 5b2272a0f3c3 -r 7100066d2c7e src/privsep-inet.c --- a/src/privsep-inet.c Wed Oct 07 14:37:35 2020 +0100 +++ b/src/privsep-inet.c Wed Oct 07 15:28:33 2020 +0100 @@ -89,6 +89,28 @@ } #endif +bool +ps_inet_canstart(const struct dhcpcd_ctx *ctx) +{ + +#ifdef INET + if ((ctx->options & (DHCPCD_IPV4 | DHCPCD_MASTER)) == + (DHCPCD_IPV4 | DHCPCD_MASTER)) + return true; +#endif +#if defined(INET6) && !defined(__sun) + if (ctx->options & DHCPCD_IPV6) + return true; +#endif +#ifdef DHCP6 + if ((ctx->options & (DHCPCD_IPV6 | DHCPCD_MASTER)) == + (DHCPCD_IPV6 | DHCPCD_MASTER)) + return true; +#endif + + return false; +} + static int ps_inet_startcb(void *arg) { diff -r 5b2272a0f3c3 -r 7100066d2c7e src/privsep-inet.h --- a/src/privsep-inet.h Wed Oct 07 14:37:35 2020 +0100 +++ b/src/privsep-inet.h Wed Oct 07 15:28:33 2020 +0100 @@ -29,6 +29,7 @@ #ifndef PRIVSEP_INET_H #define PRIVSEP_INET_H +bool ps_inet_canstart(const struct dhcpcd_ctx *); pid_t ps_inet_start(struct dhcpcd_ctx *); int ps_inet_stop(struct dhcpcd_ctx *); ssize_t ps_inet_cmd(struct dhcpcd_ctx *, struct ps_msghdr *, struct msghdr *); diff -r 5b2272a0f3c3 -r 7100066d2c7e src/privsep.c --- a/src/privsep.c Wed Oct 07 14:37:35 2020 +0100 +++ b/src/privsep.c Wed Oct 07 15:28:33 2020 +0100 @@ -467,13 +467,11 @@ /* No point in spawning the generic network listener if we're * not going to use it. */ - if (!(ctx->options & (DHCPCD_MASTER | DHCPCD_IPV6))) + if (!ps_inet_canstart(ctx)) goto started_net; switch (pid = ps_inet_start(ctx)) { case -1: - if (errno == ENXIO) - return 0; return -1; case 0: return 0;