summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-06-07 07:18:40 +0000
committerSteven Barth <steven@midlink.org>2008-06-07 07:18:40 +0000
commit0eefbbe91d4aa69559eecdc7203e6c52565fc8a2 (patch)
tree919c9c0ef9ff3a7e18dc63c5e6157f6b4fc08082
parent92fc9cd62f680a36c02be7a9c1364cc215c7d10e (diff)
* libs/web: Fixed secure caching with setuid/setgid handling
-rw-r--r--libs/web/luasrc/template.lua14
1 files changed, 7 insertions, 7 deletions
diff --git a/libs/web/luasrc/template.lua b/libs/web/luasrc/template.lua
index a24c7ed58..cc534ab45 100644
--- a/libs/web/luasrc/template.lua
+++ b/libs/web/luasrc/template.lua
@@ -35,9 +35,6 @@ luci.config.template = luci.config.template or {}
viewdir = luci.config.template.viewdir or luci.sys.libpath() .. "/view"
compiledir = luci.config.template.compiledir or luci.sys.libpath() .. "/view"
--- Enforce cache security
-compiledir = compiledir .. "/" .. luci.sys.process.info("uid")
-
-- Compile modes:
-- none: Never compile, only use precompiled data from files
@@ -148,18 +145,21 @@ function Template.__init__(self, name)
return
end
+ -- Enforce cache security
+ local cdir = compiledir .. "/" .. luci.sys.process.info("uid")
+
-- Compile and build
local sourcefile = viewdir .. "/" .. name .. ".htm"
- local compiledfile = compiledir .. "/" .. luci.http.urlencode(name) .. ".lua"
+ local compiledfile = cdir .. "/" .. luci.http.urlencode(name) .. ".lua"
local err
if compiler_mode == "file" then
local tplmt = luci.fs.mtime(sourcefile)
local commt = luci.fs.mtime(compiledfile)
- if not luci.fs.mtime(compiledir) then
- luci.fs.mkdir(compiledir, true)
- luci.fs.chmod(luci.fs.dirname(compiledir), "a+rxw")
+ if not luci.fs.mtime(cdir) then
+ luci.fs.mkdir(cdir, true)
+ luci.fs.chmod(luci.fs.dirname(cdir), "a+rxw")
end
-- Build if there is no compiled file or if compiled file is outdated