canwrite(p) actually works now
This commit is contained in:
parent
dcb37236af
commit
4e3b65ad38
@ -17,14 +17,16 @@ do
|
||||
return tacl
|
||||
end
|
||||
local function canread(fn)
|
||||
fn = fs.canonical(fn)
|
||||
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)
|
||||
fn = fs.canonical(fn)
|
||||
if os.getuid() ~= "superuser" and fsattr[fn] then
|
||||
if not parseacl(getattr(fn,"write"))[os.getuid()] then return false end
|
||||
if not parseacl(fsattr[fn].write)[os.getuid()] then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
@ -32,7 +34,7 @@ do
|
||||
fs.canread = canread
|
||||
fs.canwrite = canwrite
|
||||
local function getattr(fn,k)
|
||||
fn = fs.simplify(fn)
|
||||
fn = fs.canonical(fn)
|
||||
if not canread(fn) then return false end
|
||||
if fsattr[fn] then
|
||||
return fsattr[fn][k]
|
||||
@ -41,7 +43,7 @@ do
|
||||
end
|
||||
end
|
||||
local function setattr(fn,k,v)
|
||||
fn = fs.simplify(fn)
|
||||
fn = fs.canonical(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()])
|
||||
@ -86,6 +88,10 @@ do
|
||||
end
|
||||
return pt, pt[1], spt
|
||||
end
|
||||
function fs.canonical(p)
|
||||
local _,d,rp = fs.resolve(p)
|
||||
return fs.simplify("/"..d.."/"..rp)
|
||||
end
|
||||
function fs.exec(fc,m,...)
|
||||
return fT[fc][m](...)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user