From b5cd786bc11674fbbd7b4a34bd1dc23e3681c9c7 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 7 Sep 2008 23:56:32 +0000 Subject: [PATCH] Backported wpa_supplicant/hostapd checks for WiFi Encryption configuration --- i18n/english/luasrc/i18n/wifi.en.lua | 1 + i18n/english/luasrc/i18n/wifi.en.xml | 2 + i18n/german/luasrc/i18n/wifi.de.lua | 1 + i18n/german/luasrc/i18n/wifi.de.xml | 2 + .../luasrc/model/cbi/admin_network/wifi.lua | 37 +++++++++++++++++-- .../luasrc/controller/mini/network.lua | 2 +- .../admin-mini/luasrc/model/cbi/mini/wifi.lua | 31 ++++++++++++++-- 7 files changed, 67 insertions(+), 9 deletions(-) diff --git a/i18n/english/luasrc/i18n/wifi.en.lua b/i18n/english/luasrc/i18n/wifi.en.lua index 4d1b4a23c5..2a0ef02e91 100644 --- a/i18n/english/luasrc/i18n/wifi.en.lua +++ b/i18n/english/luasrc/i18n/wifi.en.lua @@ -32,3 +32,4 @@ wifi_ff = 'Fast Frames' wifi_wmm = 'WMM Mode' wifi_xr = 'XR Support' wifi_ar = 'AR Support' +wifi_wpareq = 'WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP and ad-hoc mode) to be installed.' diff --git a/i18n/english/luasrc/i18n/wifi.en.xml b/i18n/english/luasrc/i18n/wifi.en.xml index fa9c7b09bd..3e3f18a2b7 100644 --- a/i18n/english/luasrc/i18n/wifi.en.xml +++ b/i18n/english/luasrc/i18n/wifi.en.xml @@ -37,4 +37,6 @@ XR Support AR Support +WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP and ad-hoc mode) to be installed. + \ No newline at end of file diff --git a/i18n/german/luasrc/i18n/wifi.de.lua b/i18n/german/luasrc/i18n/wifi.de.lua index 03825fae91..e16ec1e095 100644 --- a/i18n/german/luasrc/i18n/wifi.de.lua +++ b/i18n/german/luasrc/i18n/wifi.de.lua @@ -32,3 +32,4 @@ wifi_ff = 'Schnelle Frames' wifi_wmm = 'WMM Modus' wifi_xr = 'XR-Unterstützung' wifi_ar = 'AR-Unterstützung' +wifi_wpareq = 'Für WPA-Verschlüsselung muss wpa_supplicant (für Clientmodus) oder hostapd (für AP und Ad-hoc-Modus) installiert sein.' diff --git a/i18n/german/luasrc/i18n/wifi.de.xml b/i18n/german/luasrc/i18n/wifi.de.xml index ea6b34cfe9..5b35f6554f 100644 --- a/i18n/german/luasrc/i18n/wifi.de.xml +++ b/i18n/german/luasrc/i18n/wifi.de.xml @@ -37,4 +37,6 @@ XR-Unterstützung AR-Unterstützung +Für WPA-Verschlüsselung muss wpa_supplicant (für Clientmodus) oder hostapd (für AP und Ad-hoc-Modus) installiert sein. + \ No newline at end of file diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua index cbcc8110e8..0e5d85dbe1 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua @@ -163,6 +163,7 @@ if hwtype == "atheros" then wds = s:option(Flag, "wds", translate("a_w_wds")) wds:depends({mode="ap"}) wds:depends({mode="sta"}) + wds.rmempty = true wdssep = s:option(Flag, "wdssep", translate("wifi_wdssep")) wdssep:depends({mode="ap", wds="1"}) wdssep.optional = true @@ -232,14 +233,42 @@ end ------------------- WiFI-Encryption ------------------- encr = s:option(ListValue, "encryption", translate("encryption")) +encr:depends({mode="ap"}) +encr:depends({mode="sta"}) +encr:depends({mode="adhoc"}) +encr:depends({mode="ahdemo"}) +encr:depends({mode="wds"}) + encr:value("none", "No Encryption") encr:value("wep", "WEP") -encr:value("psk", "WPA-PSK") -encr:value("psk2", "WPA2-PSK") if hwtype == "atheros" or hwtype == "mac80211" then - encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="sta"}) - encr:value("wpa2i", "WPA2-EAP", {mode="ap"}, {mode="sta"}) + local supplicant = luci.fs.mtime("/usr/sbin/wpa_supplicant") + local hostapd = luci.fs.mtime("/usr/sbin/hostapd") + + if hostapd and supplicant then + encr:value("psk", "WPA-PSK") + encr:value("psk2", "WPA2-PSK") + encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="sta"}) + encr:value("wpa2i", "WPA2-EAP", {mode="ap"}, {mode="sta"}) + elseif hostapd and not supplicant then + encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="adhoc"}, {mode="ahdemo"}) + encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="adhoc"}, {mode="ahdemo"}) + encr:value("wpa", "WPA-EAP", {mode="ap"}) + encr:value("wpa2i", "WPA2-EAP", {mode="ap"}) + encr.description = translate("wifi_wpareq") + elseif not hostapd and supplicant then + encr:value("psk", "WPA-PSK", {mode="sta"}) + encr:value("psk2", "WPA2-PSK", {mode="sta"}) + encr:value("wpa", "WPA-EAP", {mode="sta"}) + encr:value("wpa2i", "WPA2-EAP", {mode="sta"}) + encr.description = translate("wifi_wpareq") + else + encr.description = translate("wifi_wpareq") + end +elseif hwtype == "broadcom" then + encr:value("psk", "WPA-PSK") + encr:value("psk2", "WPA2-PSK") end encr:depends("mode", "ap") diff --git a/modules/admin-mini/luasrc/controller/mini/network.lua b/modules/admin-mini/luasrc/controller/mini/network.lua index 1ea6dc52cb..e1a82e6c5a 100644 --- a/modules/admin-mini/luasrc/controller/mini/network.lua +++ b/modules/admin-mini/luasrc/controller/mini/network.lua @@ -21,6 +21,6 @@ function index() entry({"mini", "network"}, alias("mini", "network", "index"), i18n("network"), 20) entry({"mini", "network", "index"}, cbi("mini/network"), i18n("general"), 1) - entry({"mini", "network", "wifi"}, cbi("mini/wifi"), i18n("wifi"), 10) + entry({"mini", "network", "wifi"}, cbi("mini/wifi"), i18n("wifi"), 10).i18n="wifi" entry({"mini", "network", "dhcp"}, cbi("mini/dhcp"), "DHCP", 20) end \ No newline at end of file diff --git a/modules/admin-mini/luasrc/model/cbi/mini/wifi.lua b/modules/admin-mini/luasrc/model/cbi/mini/wifi.lua index e36d39be94..cbf3d6a254 100644 --- a/modules/admin-mini/luasrc/model/cbi/mini/wifi.lua +++ b/modules/admin-mini/luasrc/model/cbi/mini/wifi.lua @@ -208,10 +208,33 @@ end encr = s:option(ListValue, "encryption", translate("encryption")) encr:value("none", "No Encryption") encr:value("wep", "WEP") -encr:value("psk", "WPA-PSK") -encr:value("wpa", "WPA-Radius", {mode="ap"}) -encr:value("psk2", "WPA2-PSK") -encr:value("wpa2i", "WPA2-Radius", {mode="ap"}) + +if hwtype == "atheros" or hwtype == "mac80211" then + local supplicant = luci.fs.mtime("/usr/sbin/wpa_supplicant") + local hostapd = luci.fs.mtime("/usr/sbin/hostapd") + + if hostapd and supplicant then + encr:value("psk", "WPA-PSK") + encr:value("psk2", "WPA2-PSK") + encr:value("wpa", "WPA-Radius", {mode="ap"}) + encr:value("wpa2i", "WPA2-Radius", {mode="ap"}) + elseif hostapd and not supplicant then + encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="adhoc"}) + encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="adhoc"}) + encr:value("wpa", "WPA-Radius", {mode="ap"}) + encr:value("wpa2i", "WPA2-Radius", {mode="ap"}) + encr.description = translate("wifi_wpareq") + elseif not hostapd and supplicant then + encr:value("psk", "WPA-PSK", {mode="sta"}) + encr:value("psk2", "WPA2-PSK", {mode="sta"}) + encr.description = translate("wifi_wpareq") + else + encr.description = translate("wifi_wpareq") + end +elseif hwtype == "broadcom" then + encr:value("psk", "WPA-PSK") + encr:value("psk2", "WPA2-PSK") +end key = s:option(Value, "key", translate("key")) key:depends("encryption", "wep") -- 2.30.2