diff options
author | Steven Barth <steven@midlink.org> | 2009-06-21 13:42:26 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-06-21 13:42:26 +0000 |
commit | 30b216f774c2404a965807ddb93a4a4b2aaeac04 (patch) | |
tree | 2d4bbdadc263f495e358af0fda9baf5b02274c3b /libs/web | |
parent | 2baab00b19fc6eb4e0aca4da035292e37d94a640 (diff) |
Drop support for luaposix and bitlib (obsoleted by nixio)
Mark luci.fs as deprecated
Diffstat (limited to 'libs/web')
-rw-r--r-- | libs/web/luasrc/dispatcher.lua | 11 | ||||
-rw-r--r-- | libs/web/luasrc/sauth.lua | 16 | ||||
-rw-r--r-- | libs/web/luasrc/template.lua | 10 |
3 files changed, 23 insertions, 14 deletions
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index 71d2a5c74..b0f6c1e4d 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -30,6 +30,7 @@ local sys = require "luci.sys" local init = require "luci.init" local util = require "luci.util" local http = require "luci.http" +local nixio = require "nixio", require "nixio.util" module("luci.dispatcher", package.seeall) context = util.threadlocal() @@ -210,7 +211,8 @@ function dispatch(request) if (c and c.index) or not track.notemplate then local tpl = require("luci.template") local media = track.mediaurlbase or luci.config.main.mediaurlbase - if not pcall(tpl.Template, "themes/%s/header" % fs.basename(media)) then + if not tpl.Template("themes/%s/header" % fs.basename(media)) then + --if not pcall(tpl.Template, "themes/%s/header" % fs.basename(media)) then media = nil for name, theme in pairs(luci.config.themes) do if name:sub(1,1) ~= "." and pcall(tpl.Template, @@ -411,7 +413,7 @@ function createindex_plain(path, suffixes) if cachedate > realdate then assert( sys.process.info("uid") == fs.stat(indexcache, "uid") - and fs.stat(indexcache, "mode") == "rw-------", + and fs.stat(indexcache, "modestr") == "rw-------", "Fatal: Indexcache is not sane!" ) @@ -438,8 +440,9 @@ function createindex_plain(path, suffixes) end if indexcache then - fs.writefile(indexcache, util.get_bytecode(index)) - fs.chmod(indexcache, "a-rwx,u+rw") + local f = nixio.open(indexcache, "w", 600) + f:writeall(util.get_bytecode(index)) + f:close() end end diff --git a/libs/web/luasrc/sauth.lua b/libs/web/luasrc/sauth.lua index 5d3dc95ca..e5cb17845 100644 --- a/libs/web/luasrc/sauth.lua +++ b/libs/web/luasrc/sauth.lua @@ -19,6 +19,8 @@ require("luci.fs") require("luci.util") require("luci.sys") require("luci.config") +local nixio = require "nixio", require "nixio.util" +local fs = require "nixio.fs" luci.config.sauth = luci.config.sauth or {} @@ -37,7 +39,7 @@ function clean() for i, file in pairs(files) do local fname = sessionpath .. "/" .. file local stat = luci.fs.stat(fname) - if stat and stat.type == "regular" and stat.atime + sessiontime < now then + if stat and stat.type == "reg" and stat.mtime + sessiontime < now then luci.fs.unlink(fname) end end @@ -45,8 +47,7 @@ end --- Prepare session storage by creating the session directory. function prepare() - luci.fs.mkdir(sessionpath) - luci.fs.chmod(sessionpath, "a-rwx,u+rwx") + fs.mkdir(sessionpath, 700) if not sane() then error("Security Exception: Session path is not sane!") @@ -67,6 +68,7 @@ function read(id) if not sane(sessionpath .. "/" .. id) then return end + luci.fs.utime(sessionpath .. "/" .. id) return luci.fs.readfile(sessionpath .. "/" .. id) end @@ -76,7 +78,7 @@ end function sane(file) return luci.sys.process.info("uid") == luci.fs.stat(file or sessionpath, "uid") - and luci.fs.stat(file or sessionpath, "mode") + and luci.fs.stat(file or sessionpath, "modestr") == (file and "rw-------" or "rwx------") end @@ -91,8 +93,10 @@ function write(id, data) if not id:match("^%w+$") then error("Session ID is not sane!") end - luci.fs.writefile(sessionpath .. "/" .. id, data) - luci.fs.chmod(sessionpath .. "/" .. id, "a-rwx,u+rw") + + local f = nixio.open(sessionpath .. "/" .. id, "w", 600) + f:writeall(data) + f:close() end 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) |