can only r/w attributes if you have r/w permissions in the attributes

This commit is contained in:
Izaya 2017-09-15 15:58:42 +10:00
parent 016e4f2d58
commit 366a420930
1 changed files with 20 additions and 0 deletions

View File

@ -3,7 +3,23 @@ do
local dfsattr = {read = "*", write = "*"}
local fsattr = {}
local fT,hT = {},{["_c"]=0}
local function parseacl(acl)
acl = acl or ""
local tacl = {}
if acl == "*" then
setmetatable(tacl,{__index = function() return true end})
else
for n in acl:gmatch("[^,]+") do
tacl[n] = true
log(n)
end
end
return tacl
end
local function getattr(fn,k)
if os.getuid() ~= "superuser" then
if not parseacl(fsattr[fn].read or "")[os.getuid()] then return false end
end
if fsattr[fn] then
return fsattr[fn][k]
else
@ -12,6 +28,10 @@ do
end
local function setattr(fn,k,v)
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})