From: Roy Marples Date: Fri, 5 Jun 2020 13:39:06 +0000 (+0100) Subject: BSD: In privsep with no GIFALIAS support? getifaddrs over privsep X-Git-Tag: v9.1.2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ee06bcb81782fe304e0072e91b8c20d894436dc;p=thirdparty%2Fdhcpcd.git BSD: In privsep with no GIFALIAS support? getifaddrs over privsep This makes the heavy weight call even more heavy weight :( --- diff --git a/src/if-bsd.c b/src/if-bsd.c index 495d9acb..6f2746d0 100644 --- a/src/if-bsd.c +++ b/src/if-bsd.c @@ -1364,7 +1364,18 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam) struct ifaddrs *ifaddrs = NULL, *ifa; sa = rti_info[RTAX_IFA]; - getifaddrs(&ifaddrs); +#ifdef PRIVSEP_GETIFADDRS + if (IN_PRIVSEP(ctx)) { + if (ps_root_getifaddrs(ctx, &ifaddrs) == -1) { + logerr("ps_root_getifaddrs"); + break; + } + } else +#endif + if (getifaddrs(&ifaddrs) == -1) { + logerr("getifaddrs"); + break; + } for (ifa = ifaddrs; ifa; ifa = ifa->ifa_next) { if (ifa->ifa_addr == NULL) continue; @@ -1372,6 +1383,11 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam) strcmp(ifa->ifa_name, ifp->name) == 0) break; } +#ifdef PRIVSEP_GETIFADDRS + if (IN_PRIVSEP(ctx)) + free(ifaddrs); + else +#endif freeifaddrs(ifaddrs); if (ifam->ifam_type == RTM_DELADDR) { if (ifa != NULL)