4 (c) 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
15 module("luci.sauth", package.seeall)
18 require("luci.config")
21 luci.config.sauth = luci.config.sauth or {}
22 sessionpath = luci.config.sauth.sessionpath
23 sessiontime = tonumber(luci.config.sauth.sessiontime)
28 local files = luci.fs.dir(sessionpath)
34 for i, file in pairs(files) do
35 local fname = sessionpath .. "/" .. file
36 local stat = luci.fs.stat(fname)
37 if stat and stat.type == "regular" and stat.atime + sessiontime < now then
44 luci.fs.mkdir(sessionpath)
45 luci.fs.chmod(sessionpath, "a-rwx,u+rwx")
53 return luci.fs.readfile(sessionpath .. "/" .. id)
56 function write(id, data)
57 if not luci.fs.stat(sessionpath) then
60 luci.fs.writefile(sessionpath .. "/" .. id, data)
61 luci.fs.chmod(sessionpath .. "/" .. id, "a-rwx,u+rw")