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
#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