summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hessler <phessler@cvs.openbsd.org>2018-11-25 12:10:39 +0000
committerPeter Hessler <phessler@cvs.openbsd.org>2018-11-25 12:10:39 +0000
commit298aea3d8c2745b020889aa551cb50e63f45cfcc (patch)
tree9c595c963b779381b39fb2a1720ceb8da96a1c68
parentad491da8ade2f21f514ba1b5be8a3b7930803ec0 (diff)
merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1) OK stsp@
-rw-r--r--sbin/ifconfig/ifconfig.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 07d7f47bc62..d2c598130ef 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.384 2018/11/20 20:49:26 phessler Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.385 2018/11/25 12:10:38 phessler Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -1909,7 +1909,7 @@ setifwpa(const char *val, int d)
wpa.i_enabled = d;
if (actions & A_JOIN) {
- memcpy(&join.i_wpaparams, &wpa, sizeof(join.i_wpaparams));
+ join.i_wpaparams.i_enabled = d;
join.i_flags |= IEEE80211_JOIN_WPA;
return;
}
@@ -1940,6 +1940,12 @@ setifwpaprotos(const char *val, int d)
}
free(optlist);
+ if (actions & A_JOIN) {
+ join.i_wpaparams.i_protos = rval;
+ join.i_flags |= IEEE80211_JOIN_WPA;
+ return;
+ }
+
memset(&wpa, 0, sizeof(wpa));
(void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name));
if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) < 0)
@@ -1949,12 +1955,6 @@ setifwpaprotos(const char *val, int d)
wpa.i_ciphers = 0;
wpa.i_groupcipher = 0;
- if (actions & A_JOIN) {
- memcpy(&join.i_wpaparams, &wpa, sizeof(join.i_wpaparams));
- join.i_flags |= IEEE80211_JOIN_WPA;
- return;
- }
-
if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) < 0)
err(1, "SIOCS80211WPAPARMS");
}
@@ -1981,6 +1981,14 @@ setifwpaakms(const char *val, int d)
}
free(optlist);
+ if (actions & A_JOIN) {
+ join.i_wpaparams.i_akms = rval;
+ join.i_wpaparams.i_enabled =
+ ((rval & IEEE80211_WPA_AKM_8021X) != 0);
+ join.i_flags |= IEEE80211_JOIN_WPA;
+ return;
+ }
+
memset(&wpa, 0, sizeof(wpa));
(void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name));
if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) < 0)
@@ -1989,12 +1997,6 @@ setifwpaakms(const char *val, int d)
/* Enable WPA for 802.1x here. PSK case is handled in setifwpakey(). */
wpa.i_enabled = ((rval & IEEE80211_WPA_AKM_8021X) != 0);
- if (actions & A_JOIN) {
- memcpy(&join.i_wpaparams, &wpa, sizeof(join.i_wpaparams));
- join.i_flags |= IEEE80211_JOIN_WPA;
- return;
- }
-
if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) < 0)
err(1, "SIOCS80211WPAPARMS");
}
@@ -2042,18 +2044,18 @@ setifwpaciphers(const char *val, int d)
}
free(optlist);
+ if (actions & A_JOIN) {
+ join.i_wpaparams.i_ciphers = rval;
+ join.i_flags |= IEEE80211_JOIN_WPA;
+ return;
+ }
+
memset(&wpa, 0, sizeof(wpa));
(void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name));
if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) < 0)
err(1, "SIOCG80211WPAPARMS");
wpa.i_ciphers = rval;
- if (actions & A_JOIN) {
- memcpy(&join.i_wpaparams, &wpa, sizeof(join.i_wpaparams));
- join.i_flags |= IEEE80211_JOIN_WPA;
- return;
- }
-
if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) < 0)
err(1, "SIOCS80211WPAPARMS");
}
@@ -2076,7 +2078,7 @@ setifwpagroupcipher(const char *val, int d)
wpa.i_groupcipher = cipher;
if (actions & A_JOIN) {
- memcpy(&join.i_wpaparams, &wpa, sizeof(join.i_wpaparams));
+ join.i_wpaparams.i_groupcipher = cipher;
join.i_flags |= IEEE80211_JOIN_WPA;
return;
}