[OpenWrt-Devel] [PATCH] Hostapd: Add support for multiple RADIUS servers

amine.ahd amine.ahd at gmail.com
Tue Apr 26 09:15:58 EDT 2016


Hostapd allows more than one RADIUS server to be added in case the main server goes down.
This allows netifd to load a list of RADIUS servers from the wireless confid file and add them to hostapd.
The format of the list in the config file is as follow:
	list auth_servers 'secret at server_addr[:port]'

Signed-off-by: Amine Hamed <amine.ahd at gmail.com>
---
 .../network/services/hostapd/files/netifd.sh       | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/package/network/services/hostapd/files/netifd.sh b/package/network/services/hostapd/files/netifd.sh
index 417cc42..3e371b2 100644
--- a/package/network/services/hostapd/files/netifd.sh
+++ b/package/network/services/hostapd/files/netifd.sh
@@ -125,6 +125,8 @@ hostapd_common_add_bss_config() {
 	config_add_string auth_secret
 	config_add_int 'auth_port:port' 'port:port'
 
+	config_add_array auth_servers
+
 	config_add_string acct_server
 	config_add_string acct_secret
 	config_add_int acct_port
@@ -269,10 +271,31 @@ hostapd_set_bss_options() {
 
 			set_default vlan_naming 1
 
+			# leave the default option for legacy compatibility
 			append bss_conf "auth_server_addr=$auth_server" "$N"
 			append bss_conf "auth_server_port=$auth_port" "$N"
 			append bss_conf "auth_server_shared_secret=$auth_secret" "$N"
 
+			# List of fallback RADIUS servers, ip_add at secret[:port]
+			json_select "auth_servers"
+			local Index="1"
+			while json_get_type Var $Index && [ "$Var" = string ]; do
+				json_get_var Var "$((Index++))"
+
+				ip_addr=$(echo "$Var" | cut -d"@" -f2 | cut -d":" -f1)
+				append bss_conf "auth_server_addr=$ip_addr" "$N"
+
+				port=$(echo "$Var" | cut -d"@" -f2 | cut -d":" -f2)
+				if ! echo "$port" | egrep -q '^[0-9]+$' ; then
+					port=1812
+				fi
+				append bss_conf "auth_server_port=$port" "$N"
+
+				secret=$(echo "$Var" | cut -d"@" -f1)
+				append bss_conf "auth_server_shared_secret=$secret" "$N"
+			done
+			json_select ".."
+			
 			[ -n "$acct_server" ] && {
 				append bss_conf "acct_server_addr=$acct_server" "$N"
 				append bss_conf "acct_server_port=$acct_port" "$N"
-- 
2.6.6
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list