summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-full/luasrc
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-full/luasrc
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-full/luasrc')
-rw-r--r--modules/admin-full/luasrc/controller/admin/system.lua29
1 files changed, 23 insertions, 6 deletions
diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua
index 862a741cde..14fd813c38 100644
--- a/modules/admin-full/luasrc/controller/admin/system.lua
+++ b/modules/admin-full/luasrc/controller/admin/system.lua
@@ -197,13 +197,30 @@ end
function action_upgrade()
require("luci.model.uci")
+
local ret = nil
local plat = luci.fs.mtime("/lib/upgrade/platform.sh")
-
- local image = luci.http.upload("image")
+ 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 image then
+
+ if plat and fname then
local kpattern = nil
if keepcfg then
local files = luci.model.uci.get_all("luci", "flash_keep")
@@ -214,8 +231,8 @@ function action_upgrade()
end
end
end
- ret = luci.sys.flash(image, kpattern)
+ ret = luci.sys.flash(tmpfile, kpattern)
end
-
+
luci.template.render("admin_system/upgrade", {sysupgrade=plat, ret=ret})
end \ No newline at end of file