convinced the io.open stuff to work properly

This commit is contained in:
Izaya 2017-09-15 19:30:04 +10:00
parent 3c84f6224b
commit 580f975263
1 changed files with 13 additions and 2 deletions

View File

@ -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