diff --git a/exec/addperm.lua b/exec/addperm.lua new file mode 100644 index 0000000..345814f --- /dev/null +++ b/exec/addperm.lua @@ -0,0 +1,19 @@ +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 diff --git a/exec/rmperm.lua b/exec/rmperm.lua new file mode 100644 index 0000000..6f7d9b6 --- /dev/null +++ b/exec/rmperm.lua @@ -0,0 +1,19 @@ +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] = false + 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