luci-proto-openvpn: fix permissions and write promise

structure the promise so uci.set functions properly.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald
2026-03-12 17:44:59 +01:00
parent 3da0ac5f94
commit 8fa4744ebe
2 changed files with 13 additions and 8 deletions

View 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;
},

View 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" ]
}
}
}