diff --git a/modules/lib/fs.lua b/modules/lib/fs.lua index 235b2ef..c093d40 100644 --- a/modules/lib/fs.lua +++ b/modules/lib/fs.lua @@ -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})