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