]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
OpenBSD: Fix non privsep builds.
authorRoy Marples <roy@marples.name>
Wed, 20 May 2020 11:23:25 +0000 (12:23 +0100)
committerRoy Marples <roy@marples.name>
Wed, 20 May 2020 11:23:25 +0000 (12:23 +0100)
src/if-bsd.c
src/ipv6.c

index 981f9b2a14443dd974bf4c415c536ba34ad9ca3c..7bc1d7321c34118bb7253a808135fd06c7432572 100644 (file)
@@ -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
 
index 9e3b62f6578823e3c104dbe354534aaa3b98acdd..025174bcb56cce4b014b28739d66035dd61ee605 100644 (file)
@@ -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