From: Paul Donald Date: Thu, 12 Mar 2026 03:45:27 +0000 (+0100) Subject: openvpn: ucode proto script improvements X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=c0faf0714d5f42a0676847ab4995f228252179cd;p=openwrt-packages.git openvpn: ucode proto script improvements fix the pop() bug write options to a config file in case argv length > 63 netifd has a hard limit of 64 argv entries for its ucode proto.run_command whereby '--param' is one, and its 'option string' is two. follow-up to affa96dc816653475bebef94d21443434cb1532c Signed-off-by: Paul Donald --- diff --git a/net/openvpn/files/lib/netifd/proto/openvpn.uc b/net/openvpn/files/lib/netifd/proto/openvpn.uc index 127cda5e6..c48f16421 100755 --- a/net/openvpn/files/lib/netifd/proto/openvpn.uc +++ b/net/openvpn/files/lib/netifd/proto/openvpn.uc @@ -8,6 +8,7 @@ const OPENVPN_PASS = '/var/run/openvpn.%s.pass'; const OPENVPN_AUTH = '/var/run/openvpn.%s.auth'; const OPENVPN_PID = '/var/run/openvpn.%s.pid'; const OPENVPN_STATUS = '/var/run/openvpn.%s.status'; +const OPENVPN_CONF = '/var/run/openvpn.%s.conf'; function openvpn_exists() { @@ -442,7 +443,7 @@ function proto_setup(proto) { if (cfg.config && cfg.config !== '') { if (index(cfg.config, '/') >= 0) { let parts = split(cfg.config, '/'); - parts.pop(); + pop(parts); cd_dir = join('/', parts); if (cd_dir == '') cd_dir = `/etc/openvpn/${iface}`; } @@ -467,18 +468,25 @@ function proto_setup(proto) { // assemble the final command line let cmd = [ - OPENVPN, '--cd', cd_dir, '--status', statusfile, '--syslog', sprintf('openvpn_%s', iface), '--tmp-dir', '/var/run', '--writepid', sprintf(OPENVPN_PID, iface), - // join(' ', params) ...params ]; + // netifd has an argv array length hard limit of 64 including final \0 + if (length(cmd) > 63) { + let conffile = sprintf(OPENVPN_CONF, iface); + fs.writefile(conffile, replace(join(' ', cmd), '--', '\n')); + cmd = [ + '--config', conffile, + ]; + } + // run_command needs an argv array - proto.run_command(cmd); + proto.run_command([OPENVPN, ...cmd]); // do not call proto.update_link() here - OpenVPN will handle if_up } @@ -506,6 +514,7 @@ function proto_teardown(proto) { fs.unlink(sprintf(OPENVPN_AUTH, iface)); fs.unlink(sprintf(OPENVPN_STATUS, iface)); fs.unlink(sprintf(OPENVPN_PID, iface)); + fs.unlink(sprintf(OPENVPN_CONF, iface)); let link_data = { ifname: iface