moved checks to more generic canread() and canwrite() functions
This commit is contained in:
parent
ed7032c274
commit
cab958f677
@ -16,11 +16,19 @@ do
|
||||
end
|
||||
return tacl
|
||||
end
|
||||
fs.parseacl = parseacl
|
||||
local function getattr(fn,k)
|
||||
local function canread(fn)
|
||||
if os.getuid() ~= "superuser" then
|
||||
if not parseacl(fsattr[fn].read or "")[os.getuid()] then return false end
|
||||
end
|
||||
end
|
||||
local function canwrite(fn)
|
||||
if os.getuid() ~= "superuser" then
|
||||
if not parseacl(getattr(fn,"write"))[os.getuid()] then return false end
|
||||
end
|
||||
end
|
||||
fs.parseacl = parseacl
|
||||
local function getattr(fn,k)
|
||||
if not canread(fn) then return false end
|
||||
if fsattr[fn] then
|
||||
return fsattr[fn][k]
|
||||
else
|
||||
@ -28,11 +36,9 @@ do
|
||||
end
|
||||
end
|
||||
local function setattr(fn,k,v)
|
||||
if not canwrite(fn) then return false end
|
||||
if k:find("\t") or v:find("\t") then return false end
|
||||
log(parseacl(getattr(fn,"write"))[os.getuid()])
|
||||
if os.getuid() ~= "superuser" then
|
||||
if not parseacl(getattr(fn,"write"))[os.getuid()] then return false end
|
||||
end
|
||||
if not fsattr[fn] then
|
||||
fsattr[fn] = {}
|
||||
setmetatable(fsattr[fn],{__index=dfsattr})
|
||||
|
Loading…
Reference in New Issue
Block a user