From d13e86d4c2d4c1c8970a20cc1f3214b266f57ed0 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Sun, 13 Jan 2019 02:14:22 +0800 Subject: procd: Add wrapper for uci_validate_section() This adds a wrapper (uci_load_validate) for uci_validate_section() that allows callers (through a callback function) to access the values set by uci_validate_section(), without having to manually declare a (potentially long) list of local variables. The callback function receives two arguments when called, the config section name and the return value of uci_validate_section(). If no callback function is given, then the wrapper exits with the value returned by uci_validate_section(). This also updates several init scripts to use the new wrapper function. Signed-off-by: Jeffery To --- package/network/services/dropbear/files/dropbear.init | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'package/network/services/dropbear') diff --git a/package/network/services/dropbear/files/dropbear.init b/package/network/services/dropbear/files/dropbear.init index eef2643c14..2ea637ee1a 100755 --- a/package/network/services/dropbear/files/dropbear.init +++ b/package/network/services/dropbear/files/dropbear.init @@ -29,7 +29,7 @@ append_ports() validate_section_dropbear() { - uci_validate_section dropbear dropbear "${1}" \ + uci_load_validate dropbear dropbear "$1" "$2" \ 'PasswordAuth:bool:1' \ 'enable:bool:1' \ 'Interface:string' \ @@ -48,12 +48,9 @@ validate_section_dropbear() dropbear_instance() { - local PasswordAuth enable Interface GatewayPorts \ - RootPasswordAuth RootLogin rsakeyfile \ - BannerFile Port SSHKeepAlive IdleTimeout \ - MaxAuthTries RecvWindowSize mdns ipaddrs + local ipaddrs - validate_section_dropbear "${1}" || { + [ "$2" = 0 ] || { echo "validation failed" return 1 } @@ -135,7 +132,7 @@ start_service() . /lib/functions/network.sh config_load "${NAME}" - config_foreach dropbear_instance dropbear + config_foreach validate_section_dropbear dropbear dropbear_instance } service_triggers() -- cgit v1.2.3