From cab958f67711700b540ee421b17a1f0e0efc798c Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Fri, 15 Sep 2017 17:40:34 +1000 Subject: [PATCH] moved checks to more generic canread() and canwrite() functions --- modules/lib/fs.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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})