summaryrefslogtreecommitdiffstats
path: root/src/if-bsd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-01-16 21:47:27 +0000
committerRoy Marples <roy@marples.name>2020-01-16 21:47:27 +0000
commit27d704b6b325c59cd3aa3bf80bf5476508fbc07e (patch)
tree30055a5edd6c2d257fa7d0d7052262d863cf9c8d /src/if-bsd.c
parent9bbb1e2b27fe4803ef133bda2158882f701433e2 (diff)
downloaddhcpcd-27d704b6b325c59cd3aa3bf80bf5476508fbc07e.tar.xz
BSD: Ignore messages from ourself in privsep.
Diffstat (limited to 'src/if-bsd.c')
-rw-r--r--src/if-bsd.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/if-bsd.c b/src/if-bsd.c
index 599bdf05..6fddb02e 100644
--- a/src/if-bsd.c
+++ b/src/if-bsd.c
@@ -1245,12 +1245,15 @@ if_rtm(struct dhcpcd_ctx *ctx, const struct rt_msghdr *rtm)
if (rtm->rtm_errno != 0)
return 0;
+ /* Ignore messages from ourself. */
#ifdef PRIVSEP
- /* Ignore messages from the route process.
- * We'll get the result of them regardless. */
- if (rtm->rtm_pid == ctx->ps_root_pid)
- return 0;
+ if (ctx->ps_root_pid != 0) {
+ if (rtm->rtm_pid == ctx->ps_root_pid)
+ return 0;
+ } else
#endif
+ if (rtm->rtm_pid == getpid())
+ return 0;
if (if_copyrt(ctx, &rt, rtm) == -1)
return errno == ENOTSUP ? 0 : -1;
@@ -1292,6 +1295,21 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
errno = EINVAL;
return -1;
}
+
+#ifdef HAVE_IFAM_PID
+#ifdef PRIVSEP
+ if (ctx->ps_root_pid != 0) {
+ if (ifam->ifam_pid == ctx->ps_root_pid)
+ return 0;
+ } else
+#endif
+ if (ifam->ifam_pid == getpid())
+ return 0;
+ pid = ifam->ifam_pid;
+#else
+ pid = 0;
+#endif
+
if (~ifam->ifam_addrs & RTA_IFA)
return 0;
if ((ifp = if_findindex(ctx->ifaces, ifam->ifam_index)) == NULL)
@@ -1301,12 +1319,6 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
ifam->ifam_msglen - sizeof(*ifam), rti_info) == -1)
return -1;
-#ifdef HAVE_IFAM_PID
- pid = ifam->ifam_pid;
-#else
- pid = 0;
-#endif
-
#ifdef HAVE_IFAM_ADDRFLAGS
addrflags = ifam->ifam_addrflags;
#endif