diff mbox

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

Message ID 1461220774-16115-1-git-send-email-amine.ahd@gmail.com
State Changes Requested
Headers show

Commit Message

amine ahd April 21, 2016, 6:39 a.m. UTC
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 ...
list auth_ports ...
list auth_secrets ...

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

Comments

John Crispin April 25, 2016, 1:32 p.m. UTC | #1
On 21/04/2016 08:39, amine.ahd wrote:
> 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 ...
> list auth_ports ...
> list auth_secrets ...
> 

keeping 3 lists in sync is not a good solution. please use a single list
and a notation such as secret@host:port

	John

> Signed-off-by: Amine Hamed <amine.ahd@gmail.com>
> ---
>  .../network/services/hostapd/files/netifd.sh       | 28 ++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/package/network/services/hostapd/files/netifd.sh b/package/network/services/hostapd/files/netifd.sh
> index 417cc42..ed772ff 100644
> --- a/package/network/services/hostapd/files/netifd.sh
> +++ b/package/network/services/hostapd/files/netifd.sh
> @@ -125,6 +125,10 @@ 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_array auth_secrets
> +	config_add_array auth_ports
> +	
>  	config_add_string acct_server
>  	config_add_string acct_secret
>  	config_add_int acct_port
> @@ -269,10 +273,34 @@ 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
> +			json_select "auth_servers"
> +			local Index="1"
> +			while json_get_type Var $Index && [ "$Var" = string ]; do
> +				json_get_var Var "$((Index))"
> +				append bss_conf "auth_server_addr=$Var" "$N"
> +				json_select ".."
> +				
> +				json_select "auth_ports"
> +				json_get_var Var "$((Index))"
> +				set_default Var 1812
> +				append bss_conf "auth_server_port=$Var" "$N"
> +				json_select ".."
> +				
> +				json_select "auth_secrets"
> +				json_get_var Var "$((Index++))"
> +				append bss_conf "auth_server_shared_secret=$Var" "$N"
> +				json_select ".."
> +				
> +				json_select "auth_servers"
> +			done
> +			json_select ".."
> +			
>  			[ -n "$acct_server" ] && {
>  				append bss_conf "acct_server_addr=$acct_server" "$N"
>  				append bss_conf "acct_server_port=$acct_port" "$N"
>
diff mbox

Patch

diff --git a/package/network/services/hostapd/files/netifd.sh b/package/network/services/hostapd/files/netifd.sh
index 417cc42..ed772ff 100644
--- a/package/network/services/hostapd/files/netifd.sh
+++ b/package/network/services/hostapd/files/netifd.sh
@@ -125,6 +125,10 @@  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_array auth_secrets
+	config_add_array auth_ports
+	
 	config_add_string acct_server
 	config_add_string acct_secret
 	config_add_int acct_port
@@ -269,10 +273,34 @@  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
+			json_select "auth_servers"
+			local Index="1"
+			while json_get_type Var $Index && [ "$Var" = string ]; do
+				json_get_var Var "$((Index))"
+				append bss_conf "auth_server_addr=$Var" "$N"
+				json_select ".."
+				
+				json_select "auth_ports"
+				json_get_var Var "$((Index))"
+				set_default Var 1812
+				append bss_conf "auth_server_port=$Var" "$N"
+				json_select ".."
+				
+				json_select "auth_secrets"
+				json_get_var Var "$((Index++))"
+				append bss_conf "auth_server_shared_secret=$Var" "$N"
+				json_select ".."
+				
+				json_select "auth_servers"
+			done
+			json_select ".."
+			
 			[ -n "$acct_server" ] && {
 				append bss_conf "acct_server_addr=$acct_server" "$N"
 				append bss_conf "acct_server_port=$acct_port" "$N"