From dcb37236af1586f3f4185db2614bc56d54052cb7 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Fri, 15 Sep 2017 19:30:04 +1000 Subject: [PATCH] convinced the io.open stuff to work properly --- modules/lib/fs.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/lib/fs.lua b/modules/lib/fs.lua index edc4822..386228f 100644 --- a/modules/lib/fs.lua +++ b/modules/lib/fs.lua @@ -17,17 +17,22 @@ do return tacl end local function canread(fn) - if os.getuid() ~= "superuser" then + if os.getuid() ~= "superuser" and fsattr[fn] then if not parseacl(fsattr[fn].read or "")[os.getuid()] then return false end end + return true end local function canwrite(fn) - if os.getuid() ~= "superuser" then + if os.getuid() ~= "superuser" and fsattr[fn] then if not parseacl(getattr(fn,"write"))[os.getuid()] then return false end end + return true end fs.parseacl = parseacl + fs.canread = canread + fs.canwrite = canwrite local function getattr(fn,k) + fn = fs.simplify(fn) if not canread(fn) then return false end if fsattr[fn] then return fsattr[fn][k] @@ -36,6 +41,7 @@ do end end local function setattr(fn,k,v) + fn = fs.simplify(fn) 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()]) @@ -84,6 +90,11 @@ do return fT[fc][m](...) end function fs.open(p,m) + if m:sub(1,1) == "r" then + if not canread(p) then return false end + elseif m:sub(1,1) == "w" or m:sub(1,1) == "a" then + if not canwrite(p) then return false end + end local _,d,p = fs.resolve(p) local d = fT[d] if d then