summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-mini/luasrc/controller/mini
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-07-16 14:26:40 +0000
committerSteven Barth <steven@midlink.org>2008-07-16 14:26:40 +0000
commit66a6492ae5aa9779af6d22eaddf0f5f253ed1189 (patch)
tree2b6b0ffb33b9b17a38ea51dc0c9dcf2790850310 /modules/admin-mini/luasrc/controller/mini
parent65cde96c5b05e04c24b0f272b577df67193d7c0b (diff)
libs/web: Prevent luci.http to prematurely parse the POST data
modules/admin-mini: Added fw-upgrade page
Diffstat (limited to 'modules/admin-mini/luasrc/controller/mini')
-rw-r--r--modules/admin-mini/luasrc/controller/mini/system.lua62
1 files changed, 61 insertions, 1 deletions
diff --git a/modules/admin-mini/luasrc/controller/mini/system.lua b/modules/admin-mini/luasrc/controller/mini/system.lua
index 7b13e20c62..3b3fea228d 100644
--- a/modules/admin-mini/luasrc/controller/mini/system.lua
+++ b/modules/admin-mini/luasrc/controller/mini/system.lua
@@ -20,7 +20,9 @@ function index()
local i18n = luci.i18n.translate
entry({"mini", "system"}, call("action_reboot"), i18n("system"))
- entry({"mini", "system", "reboot"}, call("action_reboot"), i18n("reboot"), 10)
+ entry({"admin", "system", "passwd"}, call("action_passwd"), i18n("a_s_changepw"), 10)
+ entry({"mini", "system", "upgrade"}, call("action_upgrade"), i18n("a_s_flash"), 20)
+ entry({"mini", "system", "reboot"}, call("action_reboot"), i18n("reboot"), 30)
end
function action_reboot()
@@ -29,4 +31,62 @@ function action_reboot()
if reboot then
luci.sys.reboot()
end
+end
+
+function action_upgrade()
+ require("luci.model.uci")
+
+ local ret = nil
+ local plat = luci.fs.mtime("/lib/upgrade/platform.sh")
+ local tmpfile = "/tmp/firmware.img"
+
+ local file
+ luci.http.setfilehandler(
+ function(meta, chunk, eof)
+ if not file then
+ file = io.open(tmpfile, "w")
+ end
+ if chunk then
+ file:write(chunk)
+ end
+ if eof then
+ file:close()
+ end
+ end
+ )
+
+ local fname = luci.http.formvalue("image")
+ local keepcfg = luci.http.formvalue("keepcfg")
+
+ if plat and fname then
+ local kpattern = nil
+ if keepcfg then
+ local files = luci.model.uci.get_all("luci", "flash_keep")
+ if files.luci and files.luci.flash_keep then
+ kpattern = ""
+ for k,v in pairs(files.luci.flash_keep) do
+ kpattern = kpattern .. " " .. v
+ end
+ end
+ end
+ ret = luci.sys.flash(tmpfile, kpattern)
+ end
+
+ luci.template.render("mini/upgrade", {sysupgrade=plat, ret=ret})
+end
+
+function action_passwd()
+ local p1 = luci.http.formvalue("pwd1")
+ local p2 = luci.http.formvalue("pwd2")
+ local stat = nil
+
+ if p1 or p2 then
+ if p1 == p2 then
+ stat = luci.sys.user.setpasswd("root", p1)
+ else
+ stat = 10
+ end
+ end
+
+ luci.template.render("mini/passwd", {stat=stat})
end \ No newline at end of file