From d18170ad7bbe5cdc98e45f892b4eff776eb38a3f Mon Sep 17 00:00:00 2001 From: krw Date: Fri, 7 Jul 2017 15:39:30 +0000 Subject: [PATCH] dispatch_imsg() only needs to know name and rdomain. No more struct interface_info knowledge in privsep.[ch] --- sbin/dhclient/dhclient.c | 5 +++-- sbin/dhclient/privsep.c | 18 ++++++++---------- sbin/dhclient/privsep.h | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 94659f6aa21..940049c6b4e 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.457 2017/07/07 14:53:06 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.458 2017/07/07 15:39:30 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -2091,7 +2091,8 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2) continue; } - got_imsg_hup = dispatch_imsg(ifi, ioctlfd, routefd, priv_ibuf); + got_imsg_hup = dispatch_imsg(ifi->name, ifi->rdomain, ioctlfd, + routefd, priv_ibuf); if (got_imsg_hup) quit = SIGHUP; } diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c index 09ffe76375f..4bb01951299 100644 --- a/sbin/dhclient/privsep.c +++ b/sbin/dhclient/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.54 2017/07/02 09:11:13 krw Exp $ */ +/* $OpenBSD: privsep.c,v 1.55 2017/07/07 15:39:30 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -36,7 +36,7 @@ #include "privsep.h" int -dispatch_imsg(struct interface_info *ifi, int ioctlfd, int routefd, +dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd, struct imsgbuf *ibuf) { struct imsg imsg; @@ -55,8 +55,7 @@ dispatch_imsg(struct interface_info *ifi, int ioctlfd, int routefd, sizeof(struct imsg_delete_address)) log_warnx("bad IMSG_DELETE_ADDRESS"); else - priv_delete_address(ifi->name, ioctlfd, - imsg.data); + priv_delete_address(name, ioctlfd, imsg.data); break; case IMSG_ADD_ADDRESS: @@ -64,15 +63,14 @@ dispatch_imsg(struct interface_info *ifi, int ioctlfd, int routefd, sizeof(struct imsg_add_address)) log_warnx("bad IMSG_ADD_ADDRESS"); else - priv_add_address(ifi->name, ioctlfd, imsg.data); + priv_add_address(name, ioctlfd, imsg.data); break; case IMSG_FLUSH_ROUTES: if (imsg.hdr.len != IMSG_HEADER_SIZE) log_warnx("bad IMSG_FLUSH_ROUTES"); else - priv_flush_routes(ifi->name, routefd, - ifi->rdomain); + priv_flush_routes(name, routefd, rdomain); break; case IMSG_ADD_ROUTE: @@ -80,7 +78,7 @@ dispatch_imsg(struct interface_info *ifi, int ioctlfd, int routefd, sizeof(struct imsg_add_route)) log_warnx("bad IMSG_ADD_ROUTE"); else - priv_add_route(ifi->rdomain, imsg.data); + priv_add_route(rdomain, imsg.data); break; case IMSG_SET_INTERFACE_MTU: @@ -88,14 +86,14 @@ dispatch_imsg(struct interface_info *ifi, int ioctlfd, int routefd, sizeof(struct imsg_set_interface_mtu)) log_warnx("bad IMSG_SET_INTERFACE_MTU"); else - priv_set_interface_mtu(ifi->name, ioctlfd, + priv_set_interface_mtu(name, ioctlfd, imsg.data); break; case IMSG_WRITE_RESOLV_CONF: if (imsg.hdr.len <= IMSG_HEADER_SIZE) log_warnx("short IMSG_WRITE_RESOLV_CONF"); - else if (resolv_conf_priority(ifi->rdomain, routefd)) + else if (resolv_conf_priority(rdomain, routefd)) priv_write_resolv_conf(imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); break; diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h index c4775e16961..c2b0ab4d149 100644 --- a/sbin/dhclient/privsep.h +++ b/sbin/dhclient/privsep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.h,v 1.41 2017/07/01 23:27:56 krw Exp $ */ +/* $OpenBSD: privsep.h,v 1.42 2017/07/07 15:39:30 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -49,7 +49,7 @@ struct imsg_set_interface_mtu { int mtu; }; -int dispatch_imsg(struct interface_info *, int, int, struct imsgbuf *); +int dispatch_imsg(char *, int, int, int, struct imsgbuf *); void add_direct_route(struct in_addr, struct in_addr, struct in_addr); void add_default_route(struct in_addr, struct in_addr); -- 2.20.1