summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2017-06-28 16:31:53 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2017-06-28 16:31:53 +0000
commitfff79b468219a645ef89a426751a9f6dd79575bd (patch)
tree6485b542b5545e019a176c299d6cf3b5ba36ad3e /sbin
parentcae59cb09ca47817add2d87658502e9dd1d96485 (diff)
Only pass required fields of interface_info to priv_* functions
and friends. i.e. ifi->name, ifi->rdomain, or both.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/dhclient.c4
-rw-r--r--sbin/dhclient/kroute.c36
-rw-r--r--sbin/dhclient/privsep.c14
-rw-r--r--sbin/dhclient/privsep.h20
4 files changed, 35 insertions, 39 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index b4c1fb3d155..3934ee8f2d9 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.451 2017/06/28 14:35:43 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.452 2017/06/28 16:31:52 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -1005,7 +1005,7 @@ bind_lease(struct interface_info *ifi)
goto newlease;
}
- ifi->offer->resolv_conf = resolv_conf_contents(ifi,
+ ifi->offer->resolv_conf = resolv_conf_contents(ifi->name,
&options[DHO_DOMAIN_NAME], &options[DHO_DOMAIN_NAME_SERVERS],
&options[DHO_DOMAIN_SEARCH]);
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c
index 145f065c181..37a7de4fa3a 100644
--- a/sbin/dhclient/kroute.c
+++ b/sbin/dhclient/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.98 2017/06/28 15:45:32 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.99 2017/06/28 16:31:52 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
@@ -141,7 +141,7 @@ flush_routes(void)
}
void
-priv_flush_routes(struct interface_info *ifi)
+priv_flush_routes(char *name, int rdomain)
{
char ifname[IF_NAMESIZE];
struct sockaddr *rti_info[RTAX_MAX];
@@ -159,7 +159,7 @@ priv_flush_routes(struct interface_info *ifi)
mib[3] = AF_INET;
mib[4] = NET_RT_FLAGS;
mib[5] = RTF_GATEWAY;
- mib[6] = ifi->rdomain;
+ mib[6] = rdomain;
while (1) {
if (sysctl(mib, 7, NULL, &needed, NULL, 0) == -1) {
@@ -223,8 +223,8 @@ priv_flush_routes(struct interface_info *ifi)
if (if_indextoname(rtm->rtm_index, ifname) &&
sa_in &&
sa_in->sin_addr.s_addr == INADDR_ANY &&
- rtm->rtm_tableid == ifi->rdomain &&
- strcmp(ifi->name, ifname) == 0)
+ rtm->rtm_tableid == rdomain &&
+ strcmp(name, ifname) == 0)
delete_route(s, rtm);
break;
default:
@@ -431,7 +431,7 @@ add_route(struct in_addr dest, struct in_addr netmask,
}
void
-priv_add_route(struct interface_info *ifi, struct imsg_add_route *imsg)
+priv_add_route(int rdomain, struct imsg_add_route *imsg)
{
char destbuf[INET_ADDRSTRLEN], gatewaybuf[INET_ADDRSTRLEN];
char maskbuf[INET_ADDRSTRLEN], ifabuf[INET_ADDRSTRLEN];
@@ -455,7 +455,7 @@ priv_add_route(struct interface_info *ifi, struct imsg_add_route *imsg)
rtm.rtm_version = RTM_VERSION;
rtm.rtm_type = RTM_ADD;
- rtm.rtm_tableid = ifi->rdomain;
+ rtm.rtm_tableid = rdomain;
rtm.rtm_priority = RTP_NONE;
rtm.rtm_msglen = sizeof(rtm);
rtm.rtm_addrs = imsg->addrs;
@@ -598,8 +598,7 @@ delete_address(struct in_addr addr)
}
void
-priv_delete_address(struct interface_info *ifi,
- struct imsg_delete_address *imsg)
+priv_delete_address(char *name, struct imsg_delete_address *imsg)
{
struct ifaliasreq ifaliasreq;
struct sockaddr_in *in;
@@ -613,7 +612,7 @@ priv_delete_address(struct interface_info *ifi,
fatal("socket open failed");
memset(&ifaliasreq, 0, sizeof(ifaliasreq));
- strncpy(ifaliasreq.ifra_name, ifi->name, sizeof(ifaliasreq.ifra_name));
+ strncpy(ifaliasreq.ifra_name, name, sizeof(ifaliasreq.ifra_name));
in = (struct sockaddr_in *)&ifaliasreq.ifra_addr;
in->sin_family = AF_INET;
@@ -652,15 +651,14 @@ set_interface_mtu(int mtu)
}
void
-priv_set_interface_mtu(struct interface_info *ifi,
- struct imsg_set_interface_mtu *imsg)
+priv_set_interface_mtu(char *name, struct imsg_set_interface_mtu *imsg)
{
struct ifreq ifr;
int s;
memset(&ifr, 0, sizeof(ifr));
- strlcpy(ifr.ifr_name, ifi->name, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_mtu = imsg->mtu;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
@@ -696,7 +694,7 @@ add_address(struct in_addr addr, struct in_addr mask)
}
void
-priv_add_address(struct interface_info *ifi, struct imsg_add_address *imsg)
+priv_add_address(char *name, struct imsg_add_address *imsg)
{
struct ifaliasreq ifaliasreq;
struct sockaddr_in *in;
@@ -706,7 +704,7 @@ priv_add_address(struct interface_info *ifi, struct imsg_add_address *imsg)
fatal("socket open failed");
memset(&ifaliasreq, 0, sizeof(ifaliasreq));
- strncpy(ifaliasreq.ifra_name, ifi->name, sizeof(ifaliasreq.ifra_name));
+ strncpy(ifaliasreq.ifra_name, name, sizeof(ifaliasreq.ifra_name));
/* The actual address in ifra_addr. */
in = (struct sockaddr_in *)&ifaliasreq.ifra_addr;
@@ -745,13 +743,13 @@ write_resolv_conf(u_int8_t *contents, size_t sz)
}
void
-priv_write_resolv_conf(struct interface_info *ifi, u_int8_t *contents, size_t sz)
+priv_write_resolv_conf(int rdomain, u_int8_t *contents, size_t sz)
{
const char *path = "/etc/resolv.conf";
ssize_t n;
int fd;
- if (!resolv_conf_priority(ifi->rdomain))
+ if (!resolv_conf_priority(rdomain))
return;
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC,
@@ -876,7 +874,7 @@ done:
* create /etc/resolv.conf
*/
char *
-resolv_conf_contents(struct interface_info *ifi,
+resolv_conf_contents(char *name,
struct option_data *domainname, struct option_data *nameservers,
struct option_data *domainsearch)
{
@@ -934,7 +932,7 @@ resolv_conf_contents(struct interface_info *ifi,
return (NULL);
}
- rslt = asprintf(&courtesy, "# Generated by %s dhclient\n", ifi->name);
+ rslt = asprintf(&courtesy, "# Generated by %s dhclient\n", name);
if (rslt == -1)
fatalx("no memory for courtesy line");
len += strlen(courtesy);
diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c
index 3833ce5e7f7..604e2a23650 100644
--- a/sbin/dhclient/privsep.c
+++ b/sbin/dhclient/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.51 2017/06/28 14:35:43 krw Exp $ */
+/* $OpenBSD: privsep.c,v 1.52 2017/06/28 16:31:52 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -54,7 +54,7 @@ dispatch_imsg(struct interface_info *ifi, struct imsgbuf *ibuf)
sizeof(struct imsg_delete_address))
log_warnx("bad IMSG_DELETE_ADDRESS");
else
- priv_delete_address(ifi, imsg.data);
+ priv_delete_address(ifi->name, imsg.data);
break;
case IMSG_ADD_ADDRESS:
@@ -62,14 +62,14 @@ dispatch_imsg(struct interface_info *ifi, struct imsgbuf *ibuf)
sizeof(struct imsg_add_address))
log_warnx("bad IMSG_ADD_ADDRESS");
else
- priv_add_address(ifi, imsg.data);
+ priv_add_address(ifi->name, 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);
+ priv_flush_routes(ifi->name, ifi->rdomain);
break;
case IMSG_ADD_ROUTE:
@@ -77,7 +77,7 @@ dispatch_imsg(struct interface_info *ifi, struct imsgbuf *ibuf)
sizeof(struct imsg_add_route))
log_warnx("bad IMSG_ADD_ROUTE");
else
- priv_add_route(ifi, imsg.data);
+ priv_add_route(ifi->rdomain, imsg.data);
break;
case IMSG_SET_INTERFACE_MTU:
@@ -85,14 +85,14 @@ dispatch_imsg(struct interface_info *ifi, struct imsgbuf *ibuf)
sizeof(struct imsg_set_interface_mtu))
log_warnx("bad IMSG_SET_INTERFACE_MTU");
else
- priv_set_interface_mtu(ifi, imsg.data);
+ priv_set_interface_mtu(ifi->name, imsg.data);
break;
case IMSG_WRITE_RESOLV_CONF:
if (imsg.hdr.len <= IMSG_HEADER_SIZE)
log_warnx("short IMSG_WRITE_RESOLV_CONF");
else
- priv_write_resolv_conf(ifi, imsg.data,
+ priv_write_resolv_conf(ifi->rdomain, imsg.data,
imsg.hdr.len - IMSG_HEADER_SIZE);
break;
diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h
index c2319a0f84d..64243ae2c22 100644
--- a/sbin/dhclient/privsep.h
+++ b/sbin/dhclient/privsep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.h,v 1.39 2017/06/28 14:35:43 krw Exp $ */
+/* $OpenBSD: privsep.h,v 1.40 2017/06/28 16:31:52 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -55,17 +55,15 @@ void add_direct_route(struct in_addr, struct in_addr, struct in_addr);
void add_default_route(struct in_addr, struct in_addr);
void add_static_routes(struct option_data *, struct in_addr);
void add_classless_static_routes(struct option_data *, struct in_addr);
-void priv_add_route(struct interface_info *, struct imsg_add_route *);
-void priv_flush_routes(struct interface_info *);
+void priv_add_route(int, struct imsg_add_route *);
+void priv_flush_routes(char *, int);
-char *resolv_conf_contents(struct interface_info *ifi, struct option_data *,
- struct option_data *, struct option_data *);
+char *resolv_conf_contents(char *, struct option_data *,
+ struct option_data *, struct option_data *);
void write_resolv_conf(u_int8_t *, size_t);
-void priv_write_resolv_conf(struct interface_info *, u_int8_t *, size_t);
+void priv_write_resolv_conf(int, u_int8_t *, size_t);
-void priv_delete_address(struct interface_info *,
- struct imsg_delete_address *);
-void priv_add_address(struct interface_info *, struct imsg_add_address *);
+void priv_delete_address(char *, struct imsg_delete_address *);
+void priv_add_address(char *, struct imsg_add_address *);
-void priv_set_interface_mtu(struct interface_info *,
- struct imsg_set_interface_mtu *);
+void priv_set_interface_mtu(char *, struct imsg_set_interface_mtu *);