From: Roy Marples Date: Wed, 20 May 2020 11:23:25 +0000 (+0100) Subject: OpenBSD: Fix non privsep builds. X-Git-Tag: v9.1.0~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed42d4f666a2d6a03f8ae901dd864b8db39c635c;p=thirdparty%2Fdhcpcd.git OpenBSD: Fix non privsep builds. --- diff --git a/src/if-bsd.c b/src/if-bsd.c index 981f9b2a..7bc1d732 100644 --- a/src/if-bsd.c +++ b/src/if-bsd.c @@ -364,17 +364,18 @@ if_linkaddr(struct sockaddr_dl *sdl, const struct interface *ifp) static int if_indirect_ioctl(struct dhcpcd_ctx *ctx, const char *ifname, unsigned long cmd, void *data, size_t len) { + struct ifreq ifr = { .ifr_flags = 0 }; -#ifdef HAVE_PLEDGE - return (int)ps_root_indirectioctl(ctx, cmd, ifname, data, len); +#if defined(PRIVSEP) && defined(HAVE_PLEDGE) + if (IN_PRIVSEP(ctx)) + return (int)ps_root_indirectioctl(ctx, cmd, ifname, data, len); #else - struct ifreq ifr = { .ifr_flags = 0 }; + UNUSED(len); +#endif strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); ifr.ifr_data = data; - UNUSED(len); return ioctl(ctx->pf_inet_fd, cmd, &ifr); -#endif } #endif diff --git a/src/ipv6.c b/src/ipv6.c index 9e3b62f6..025174bc 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -1091,10 +1091,12 @@ ipv6_anyglobal(struct interface *sifp) #ifdef BSD bool forwarding; -#ifdef HAVE_PLEDGE - forwarding = ps_root_ip6forwarding(sifp->ctx) == 1; +#if defined(PRIVSEP) && defined(HAVE_PLEDGE) + if (IN_PRIVSEP(sifp->ctx)) + forwarding = ps_root_ip6forwarding(sifp->ctx) == 1; + else #else - forwarding = ip6_forwarding(NULL) == 1; + forwarding = ip6_forwarding(NULL) == 1; #endif #endif