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)
17 require("luci.config")
20 luci.config.sauth = luci.config.sauth or {}
21 sessionpath = luci.config.sauth.sessionpath
22 sessiontime = luci.config.sauth.sessiontime
27 local files = luci.fs.dir(sessionpath)
33 for i, file in files do
34 local fname = sessionpath .. "/" .. file
35 local stat = luci.fs.stat(fname)
36 if stat and stat.type == "regular" and stat.atime + sessiontime < now then
43 luci.fs.mkdir(sessionpath)
44 luci.fs.chmod(sessionpath, "a-rwx,u+rw")
49 return luci.fs.readfile(sessionpath .. "/" .. id)
52 function write(id, data)
53 if not luci.fs.stat(sessionpath) then
56 luci.fs.writefile(sessionpath .. "/" .. id, data)
57 luci.fs.chmod(sessionpath .. "/" .. id, "a-rwx,u+rw")