added some programs to manage permissions from the shell
This commit is contained in:
parent
ae083f57d9
commit
1ffec30452
19
exec/addperm.lua
Normal file
19
exec/addperm.lua
Normal 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
19
exec/rmperm.lua
Normal 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
|
Loading…
Reference in New Issue
Block a user