From 629b5ffdd92af78d7122bfa28ef955ebe536ad8d Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 20 Sep 2019 12:57:16 +0200 Subject: [PATCH] nl80211: do not confuse open connections with WEP ones Signed-off-by: Jo-Philipp Wich --- iwinfo_nl80211.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 2a4cc1e..6e438a7 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -1605,15 +1605,21 @@ static int nl80211_get_encryption(const char *ifname, char *buf) "group_cipher", wpa_groupwise, sizeof(wpa_groupwise), "key_mgmt", wpa_key_mgmt, sizeof(wpa_key_mgmt))) { - /* WEP */ + /* WEP or Open */ if (!strcmp(wpa_key_mgmt, "NONE")) { parse_wpa_ciphers(wpa_pairwise, &c->pair_ciphers); parse_wpa_ciphers(wpa_groupwise, &c->group_ciphers); - c->enabled = !!(c->pair_ciphers | c->group_ciphers); - c->auth_suites |= IWINFO_KMGMT_NONE; - c->auth_algs |= IWINFO_AUTH_OPEN; /* XXX: assumption */ + if (c->pair_ciphers != 0 && c->pair_ciphers != IWINFO_CIPHER_NONE) { + c->enabled = 1; + c->auth_suites = IWINFO_KMGMT_NONE; + c->auth_algs = IWINFO_AUTH_OPEN | IWINFO_AUTH_SHARED; + } + else { + c->pair_ciphers = 0; + c->group_ciphers = 0; + } } /* WPA */ @@ -1690,11 +1696,12 @@ static int nl80211_get_encryption(const char *ifname, char *buf) break; } - c->enabled = c->auth_algs ? 1 : 0; c->pair_ciphers |= nl80211_check_wepkey(wep_key0); c->pair_ciphers |= nl80211_check_wepkey(wep_key1); c->pair_ciphers |= nl80211_check_wepkey(wep_key2); c->pair_ciphers |= nl80211_check_wepkey(wep_key3); + + c->enabled = (c->auth_algs && c->pair_ciphers) ? 1 : 0; } c->group_ciphers = c->pair_ciphers; -- 2.30.2