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