projects
/
project
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Drop support for luaposix and bitlib (obsoleted by nixio)
[project/luci.git]
/
libs
/
web
/
luasrc
/
sauth.lua
diff --git
a/libs/web/luasrc/sauth.lua
b/libs/web/luasrc/sauth.lua
index
5d3dc95
..
e5cb178
100644
(file)
--- 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")
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 {}
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)
for i, file in pairs(files) do
local fname = sessionpath .. "/" .. file
local stat = luci.fs.stat(fname)
- if stat and stat.type == "reg
ular" and stat.a
time + sessiontime < now then
+ if stat and stat.type == "reg
" and stat.m
time + sessiontime < now then
luci.fs.unlink(fname)
end
end
luci.fs.unlink(fname)
end
end
@@
-45,8
+47,7
@@
end
--- Prepare session storage by creating the session directory.
function prepare()
--- 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!")
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
if not sane(sessionpath .. "/" .. id) then
return
end
+ luci.fs.utime(sessionpath .. "/" .. id)
return luci.fs.readfile(sessionpath .. "/" .. id)
end
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")
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, "mode
str
")
== (file and "rw-------" or "rwx------")
end
== (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
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
end