openvpn: proto handler; write params to config file
authorPaul Donald <redacted>
Thu, 12 Mar 2026 13:48:52 +0000 (14:48 +0100)
committerHannu Nyman <redacted>
Sun, 15 Mar 2026 06:45:36 +0000 (08:45 +0200)
writing the command line to a config file avoids
formatting pitfalls for the command line.

Signed-off-by: Paul Donald <redacted>
net/openvpn/files/lib/netifd/proto/openvpn.sh

index 6694b49a7c0c8840976a926bccee9aa14c9067f1..2b01e79066c9dc639a3bb2388ec069a475fce35c 100755 (executable)
@@ -111,6 +111,7 @@ proto_openvpn_init_config() {
 
 proto_openvpn_setup() {
        local config="$1"
+       local conf_file="/var/run/openvpn.$config.conf"
        local exec_params cd_dir
 
        exec_params=
@@ -238,7 +239,10 @@ proto_openvpn_setup() {
        fi
 
        eval "set -- $exec_params"
-       proto_run_command "$config" openvpn "$@"
+       umask 077
+       printf "%b\n" "${exec_params//--/\\n}" > "$conf_file"
+       umask 022
+       proto_run_command "$config" openvpn --config "$conf_file"
 
        # last param wins; user provided status or syslog supersedes.
 }
@@ -254,6 +258,7 @@ proto_openvpn_renew() {
 proto_openvpn_teardown() {
        local iface="$1"
        rm -f \
+               "/var/run/openvpn.$iface.conf" \
                "/var/run/openvpn.$iface.pass" \
                "/var/run/openvpn.$iface.auth" \
                "/var/run/openvpn.$iface.status" 
git clone https://git.99rst.org/PROJECT