luci-proto-openvpn: fix permissions and write promise
authorPaul Donald <redacted>
Thu, 12 Mar 2026 16:44:59 +0000 (17:44 +0100)
committerPaul Donald <redacted>
Thu, 12 Mar 2026 16:46:33 +0000 (17:46 +0100)
structure the promise so uci.set functions properly.

Signed-off-by: Paul Donald <redacted>
protocols/luci-proto-openvpn/htdocs/luci-static/resources/protocol/openvpn.js
protocols/luci-proto-openvpn/root/usr/share/rpcd/acl.d/luci-proto-openvpn.json [moved from protocols/luci-proto-openvpn/root/usr/share/rpcd/acl.d/luci-openvpn.json with 57% similarity]

index 84f27a7b4c1d94125b1ffbec792ea40c5764aad9..da1b698deec09070c72c8a8b45c2a19f4d682e74 100644 (file)
@@ -1863,12 +1863,13 @@ return network.registerProtocol('openvpn', {
                };
                ovconf.write = function(sid, value) {
                        const config_name = `/etc/openvpn/${sid}/${sid}_config.cfg`;
-                       fs.exec_direct('/bin/mkdir', ['-p', `/etc/openvpn/${sid}/`]).then(result => {
-                               fs.write(config_name, value).catch(() => {});
-                               uci.set(this.config, sid, 'config', config_name);
+                       return fs.exec('/bin/mkdir', ['-p', `/etc/openvpn/${sid}/`]).then(() => {
+                               return fs.write(config_name, value);
+                       }).then(() => {
+                               try {
+                                       uci.set(this.config, sid, 'config', config_name);
+                               } catch (err) {}
                        });
-
-                       return 
                };
                ovconf.rmempty = true;
        },
similarity index 57%
rename from protocols/luci-proto-openvpn/root/usr/share/rpcd/acl.d/luci-openvpn.json
rename to protocols/luci-proto-openvpn/root/usr/share/rpcd/acl.d/luci-proto-openvpn.json
index e79dbca9e2bf44652892389b5737bd271a09cdd1..af4ea82b2fc981c5486da411b992d72b16baa071 100644 (file)
@@ -2,23 +2,27 @@
        "luci-proto-openvpn": {
                "description": "Grant access to LuCI openvpn procedures",
                "read": {
+                       "file": {
+                               "/bin/mkdir -p /etc/openvpn/*": [ "exec" ],
+                               "/etc/openvpn/*": [ "read" ]
+                       },
                        "ubus": {
                                "luci.openvpn": [
                                        "*"
                                ]
                        },
-                       "uci": [ "openvpn", "openvpn_recipes" ]
+                       "uci": [ "network" ]
                },
                "write": {
                        "file": {
-                               "/etc/openvpn/*": [ "write" ]
+                               "/etc/openvpn/*": [ "write", "remove" ]
                        },
                        "ubus": {
                                "luci.openvpn": [
                                        "*"
                                ]
                        },
-                       "uci": [ "openvpn" ]
+                       "uci": [ "network" ]
                }
        }
 }
git clone https://git.99rst.org/PROJECT