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