openvpn: fix quoting and deprecated option filtering
authorChen Minqiang <redacted>
Thu, 26 Mar 2026 16:40:04 +0000 (00:40 +0800)
committerFlorian Eckert <redacted>
Fri, 27 Mar 2026 13:56:22 +0000 (14:56 +0100)
This patch fixes two issues in the netifd protocol script:

1. Fix logic error in deprecated option filtering:
   Previously, ${f%%:*} was called before checking for the deprecated
   flag (:d). This stripped the suffix and made the check [ "${f#*:}" = "d" ]
   always fail. The cleaning of $f is now deferred until after this check.

2. Improve parameter quoting for specific options:
   - Adds single quotes to --push and --push-remove parameters to handle
     spaces (e.g., "route 10.0.0.0 255.255.255.0").
   - Unifies quoting for 'file' type options to improve shell safety.
   - Refactors the build logic using a case statement for better
     extensibility.

Signed-off-by: Chen Minqiang <redacted>
net/openvpn/Makefile
net/openvpn/files/lib/netifd/proto/openvpn.sh

index c7e87d6eee4d8dd25c3d657c76bafb3d31b429ea..7e1358b9da22c4fa6bcbd35e9f2bedf7adcc5631 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=openvpn
 
 PKG_VERSION:=2.6.19
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE_URL:=\
        https://build.openvpn.net/downloads/releases/ \
index 9bf841cd4c46495fe233ce8280aaf0baec4d5bf6..3e3458af272daa9c2cfc36c4ddd61ee1bd8b781f 100755 (executable)
@@ -23,9 +23,8 @@ option_builder() {
 
        for f in $(eval echo \$"$list_var")
        do
-               f=${f%%:*}
-
                if [ "$action" = "add" ]; then
+                       f=${f%%:*}
                        case "$opt_type" in
                                bool) proto_config_add_boolean "$f:bool" ;;
                                protobool) proto_config_add_boolean "$f:protobool" ;;
@@ -38,6 +37,7 @@ option_builder() {
                        esac
                elif [ "$action" = "build" ]; then
                        [ "${f#*:}" = "d" ] && [ "$ALLOW_DEPRECATED" = 0 ] && continue
+                       f=${f%%:*}
                        case "$opt_type" in
                                bool)
                                        json_get_var v "$f"
@@ -45,12 +45,19 @@ option_builder() {
                                        ;;
                                uinteger|integer|string)
                                        json_get_var v "$f"
-                                       [ -n "$v" ] && append exec_params "--${f//_/-} $v"
+                                       case $f in
+                                               push_remove)
+                                                       [ -n "$v" ] && append exec_params "--${f//_/-} '$v'"
+                                               ;;
+                                               *)
+                                                       [ -n "$v" ] && append exec_params "--${f//_/-} $v"
+                                               ;;
+                                       esac
                                        ;;
                                file)
                                        json_get_var v "$f"
                                        [ -f "$v" ] || continue
-                                       [ -n "$v" ] && append exec_params "--${f//_/-} \"$v\""
+                                       [ -n "$v" ] && append exec_params "--${f//_/-} '$v'"
                                        ;;
                                list)
                                        local type
@@ -62,7 +69,14 @@ option_builder() {
                                                json_get_keys keys
                                                for key in $keys; do
                                                        json_get_var val "$key"
-                                                       append exec_params "--${f//_/-} \"$val\""
+                                                       case $f in
+                                                               push)
+                                                                       append exec_params "--${f//_/-} '$val'"
+                                                               ;;
+                                                               *)
+                                                                       append exec_params "--${f//_/-} $val"
+                                                               ;;
+                                                       esac
                                                done
                                                json_select ..
                                                ;;
git clone https://git.99rst.org/PROJECT