From 1ee06bcb81782fe304e0072e91b8c20d894436dc Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 5 Jun 2020 14:39:06 +0100 Subject: [PATCH] BSD: In privsep with no GIFALIAS support? getifaddrs over privsep This makes the heavy weight call even more heavy weight :( --- src/if-bsd.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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) -- 2.47.2