added some programs to manage permissions from the shell

This commit is contained in:
Izaya 2017-09-15 19:57:11 +10:00
parent 3c6ac7db1a
commit 50d77f2904
2 changed files with 38 additions and 0 deletions

19
exec/addperm.lua Normal file
View File

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

19
exec/rmperm.lua Normal file
View File

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