X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=libs%2Fweb%2Fluasrc%2Ftemplate.lua;h=83efd220092309d6b75c937d4638db7725240db5;hb=30b216f774c2404a965807ddb93a4a4b2aaeac04;hp=dc6e5bb7ddc9417f54bd281da10cb09ad69228c9;hpb=2baab00b19fc6eb4e0aca4da035292e37d94a640;p=project%2Fluci.git diff --git a/libs/web/luasrc/template.lua b/libs/web/luasrc/template.lua index dc6e5bb7d..83efd2200 100644 --- a/libs/web/luasrc/template.lua +++ b/libs/web/luasrc/template.lua @@ -31,6 +31,7 @@ local table = require "table" local string = require "string" local config = require "luci.config" local coroutine = require "coroutine" +local nixio = require "nixio", require "nixio.util" local tostring, pairs, loadstring = tostring, pairs, loadstring local setmetatable, loadfile = setmetatable, loadfile @@ -177,7 +178,7 @@ function Template.__init__(self, name) if not fs.mtime(cdir) then fs.mkdir(cdir, true) - fs.chmod(fs.dirname(cdir), "a+rxw") + fs.chmod(fs.dirname(cdir), 777) end assert(tplmt or commt, "No such template: " .. name) @@ -190,14 +191,15 @@ function Template.__init__(self, name) if source then local compiled, err = compile(source) - fs.writefile(compiledfile, util.get_bytecode(compiled)) - fs.chmod(compiledfile, "a-rwx,u+rw") + local f = nixio.open(compiledfile, "w", 600) + f:writeall(util.get_bytecode(compiled)) + f:close() self.template = compiled end else assert( sys.process.info("uid") == fs.stat(compiledfile, "uid") - and fs.stat(compiledfile, "mode") == "rw-------", + and fs.stat(compiledfile, "modestr") == "rw-------", "Fatal: Cachefile is not sane!" ) self.template, err = loadfile(compiledfile)