diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-06-12 17:47:30 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-06-12 17:47:30 +0200 |
commit | 1aa13ed51ed1c1b62b1ed296383907d953a62698 (patch) | |
tree | f93dccf0e5c1c40d8976bd5c017050f29e345f10 /modules/luci-mod-system/luasrc/model | |
parent | 1818499243102d1896c5a862895e1b4035886ec2 (diff) |
luci-mod-system: prevent clearing rc.local on unrelated submit actions
Fixes: #2760
Fixes: 1c09ee5e4 ("luci-mod-system: fix SimpleForm usage on file editing pages")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-system/luasrc/model')
-rw-r--r-- | modules/luci-mod-system/luasrc/model/cbi/admin_system/startup.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/startup.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/startup.lua index c3f14540e3..99ddb09701 100644 --- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/startup.lua +++ b/modules/luci-mod-system/luasrc/model/cbi/admin_system/startup.lua @@ -7,6 +7,7 @@ local fs = require "nixio.fs" local sys = require "luci.sys" local inits = { } +local handled = false for _, name in ipairs(sys.init.names()) do local index = sys.init.index(name) @@ -49,9 +50,11 @@ end e.write = function(self, section) if inits[section].enabled then + handled = true inits[section].enabled = false return sys.init.disable(inits[section].name) else + handled = true inits[section].enabled = true return sys.init.enable(inits[section].name) end @@ -61,6 +64,7 @@ end start = s:option(Button, "start", translate("Start")) start.inputstyle = "apply" start.write = function(self, section) + handled = true sys.call("/etc/init.d/%s %s >/dev/null" %{ inits[section].name, self.option }) end @@ -87,7 +91,7 @@ function t.cfgvalue() end function f.handle(self, state, data) - if state == FORM_VALID then + if not handled and state == FORM_VALID then if data.rcs then fs.writefile("/etc/rc.local", data.rcs:gsub("\r\n", "\n")) else |