summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/dhclient/dhclient.c7
-rw-r--r--sbin/dhclient/dispatch.c19
2 files changed, 7 insertions, 19 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 48f5c21bf27..d4b2cd2b63e 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.393 2016/11/25 14:46:57 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.394 2017/01/23 04:45:59 deraadt Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -426,6 +426,8 @@ die:
char **saved_argv;
+int sock;
+
int
main(int argc, char *argv[])
{
@@ -439,7 +441,7 @@ main(int argc, char *argv[])
struct passwd *pw;
char *ignore_list = NULL;
ssize_t tailn;
- int rtfilter, sock, tailfd;
+ int rtfilter, tailfd;
saved_argv = argv;
@@ -522,7 +524,6 @@ main(int argc, char *argv[])
memset(ifi->ssid, 0, sizeof(ifi->ssid));
memcpy(ifi->ssid, nwid.i_nwid, nwid.i_len);
}
- close(sock);
/* Put us into the correct rdomain */
ifi->rdomain = get_rdomain(ifi->name);
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 555d3436a3f..ee6d83a0765 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.111 2016/10/06 16:29:17 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.112 2017/01/23 04:45:59 deraadt Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -229,17 +229,13 @@ void
interface_link_forceup(char *ifname)
{
struct ifreq ifr;
- int sock;
-
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- error("Can't create socket");
+ extern int sock;
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) {
note("interface_link_forceup: SIOCGIFFLAGS failed (%s)",
strerror(errno));
- close(sock);
return;
}
@@ -248,7 +244,6 @@ interface_link_forceup(char *ifname)
if (ioctl(sock, SIOCSIFFLAGS, (caddr_t)&ifr) == -1) {
note("interface_link_forceup: SIOCSIFFLAGS DOWN failed (%s)",
strerror(errno));
- close(sock);
return;
}
@@ -256,11 +251,8 @@ interface_link_forceup(char *ifname)
if (ioctl(sock, SIOCSIFFLAGS, (caddr_t)&ifr) == -1) {
note("interface_link_forceup: SIOCSIFFLAGS UP failed (%s)",
strerror(errno));
- close(sock);
return;
}
-
- close(sock);
}
int
@@ -268,10 +260,7 @@ interface_status(struct interface_info *ifi)
{
struct ifreq ifr;
struct ifmediareq ifmr;
- int sock;
-
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- error("Can't create socket");
+ extern int sock;
/* Get interface flags. */
memset(&ifr, 0, sizeof(ifr));
@@ -313,10 +302,8 @@ interface_status(struct interface_info *ifi)
/* Assume 'active' if IFM_AVALID is not set. */
active:
- close(sock);
return (1);
inactive:
- close(sock);
return (0);
}