1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-23 02:28:05 +11:00

add access control support to MTFS

This commit is contained in:
Izaya 2020-10-17 18:50:30 +11:00
parent 2363890151
commit 4c462a5d4e
2 changed files with 20 additions and 2 deletions

View File

@ -5,13 +5,28 @@ local rpc = require "rpc"
local tA, tO = shell.parse(...) local tA, tO = shell.parse(...)
if #tA < 1 then if #tA < 1 then
print("Usage: exportfs <directory> [-d] [--rw] [--name=<name>]") print("Usage: exportfs <directory> [-d] [--rw] [--name=<name>] [--allow=hostname[,hostname,...]] [--deny=hostname[,hostname,...]]")
return return
end end
local allow, deny = {}, {}
for host in (tO.allow or ""):gmatch("[^,]+") do
allow[#allow+1] = host
end
for host in (tO.deny or ""):gmatch("[^,]+") do
deny[#deny+1] = host
end
local px = fsproxy.new(tA[1], not tO.rw) local px = fsproxy.new(tA[1], not tO.rw)
local name = tO.name or tA[1] local name = tO.name or tA[1]
for l,m in pairs(px) do for l,m in pairs(px) do
m = not tO.d and m or nil m = not tO.d and m or nil
rpc.register("fs_"..name.."_"..l,m) rpc.register("fs_"..name.."_"..l,m)
for k,v in pairs(allow) do
rpc.allow("fs_"..name.."_"..l,v)
end
for k,v in pairs(deny) do
rpc.deny("fs_"..name.."_"..l,v)
end
end end
print(string.format("%s (%s)", name, (tO.rw and "rw") or "ro")) print(string.format("%s (%s)", name, (tO.rw and "rw") or "ro"))

View File

@ -57,7 +57,10 @@ if px.dirstat then -- use single call for file info
return gce(path, 4) or olm(path) return gce(path, 4) or olm(path)
end end
end end
local iro = px.isReadOnly() local iro,e = px.isReadOnly()
if not iro then
error(e)
end
function px.isReadOnly() function px.isReadOnly()
return iro return iro
end end