OC-PsychOS/exec/addperm.lua

20 lines
559 B
Lua

local tA = {...}
if #tA < 3 then return false, "not enough arguments" end
local rwx = table.remove(tA,1):sub(1,1):lower()
if rwx ~= "r" and rwx ~= "w" and rwx ~= "x" then return false, "not a valid mode" end
local trwx = {r = "read", w = "write", x = "execute"}
local nrwx = trwx[rwx]
local un = table.remove(tA,1)
for k,v in ipairs(tA) do
local cacl = fs.parseacl(fs.getattr(v,nrwx)) or {}
cacl[un] = true
local sacl = ""
for l,m in pairs(cacl) do
if m then
sacl = l .. ","
end
end
print(v.."\t"..nrwx.." = "..sacl)
fs.setattr(v,nrwx,sacl)
end