summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-01-25 22:39:48 +0100
committerJo-Philipp Wich <jo@mein.io>2022-01-25 22:43:17 +0100
commit18b1130711b6ff7aacba98034e2bd7f4893b33df (patch)
tree8190511b8d1cbd6f0c2802229a71549f33040d42 /applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua
parente3846833a508e6d7e144ffa24953464f6e9bb6ff (diff)
luci-app-openvpn: fix stray uci permission warning
The OpenVPN file view uses a dummy Map() instance to render the breadcrumb template which triggers a uci permission error since the view is being rendered by a form() action which does not set up the expected permission flags. CBI Map() instances should only be used for cbi() dispatch targets. Solve the issue by appending the breadcrumb template directly to the SimpleForm() instance and by removing the redundant dummy Map() instance. Fixes: #4370 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua')
-rw-r--r--applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua26
1 files changed, 15 insertions, 11 deletions
diff --git a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua
index 9d50601b1f..fa823964ac 100644
--- a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua
+++ b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua
@@ -7,32 +7,36 @@ local uci = require("luci.model.uci").cursor()
local cfg_file = uci:get("openvpn", arg[1], "config")
local auth_file = cfg_file:match("(.+)%..+").. ".auth"
-local m = Map("openvpn")
+local function makeForm(id, title, desc)
+ local t = Template("openvpn/pageswitch")
+ t.mode = "file"
+ t.instance = arg[1]
-local p = m:section( SimpleSection )
-p.template = "openvpn/pageswitch"
-p.mode = "file"
-p.instance = arg[1]
+ local f = SimpleForm(id, title, desc)
+ f:append(t)
+
+ return f
+end
if not cfg_file or not fs.access(cfg_file) then
- local f = SimpleForm("error", nil, translatef("The OVPN config file (%s) could not be found, please check your configuration.", cfg_file or "n/a"))
+ local f = makeForm("error", nil, translatef("The OVPN config file (%s) could not be found, please check your configuration.", cfg_file or "n/a"))
f:append(Template("openvpn/ovpn_css"))
f.reset = false
f.submit = false
- return m, f
+ return f
end
if fs.stat(cfg_file).size >= 102400 then
- f = SimpleForm("error", nil,
+ local f = makeForm("error", nil,
translatef("The size of the OVPN config file (%s) is too large for online editing in LuCI (&ge; 100 KB). ", cfg_file)
.. translate("Please edit this file directly in a terminal session."))
f:append(Template("openvpn/ovpn_css"))
f.reset = false
f.submit = false
- return m, f
+ return f
end
-f = SimpleForm("cfg", nil)
+f = makeForm("cfg", nil)
f:append(Template("openvpn/ovpn_css"))
f.submit = translate("Save")
f.reset = false
@@ -79,4 +83,4 @@ function s.handle(self, state, data2)
return true
end
-return m, f
+return f