summaryrefslogtreecommitdiffstats
path: root/privsep.lua
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-03-08 16:42:03 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2013-03-08 16:51:15 +0100
commit3e2d86693f6e8920c97fe296491e7741e31f922c (patch)
tree1c755422fd27c7f192243e8eb7f7811193efa1f6 /privsep.lua
parente0cabd6295204fe8a6b54edfc9141302943fdbfb (diff)
downloadprivsep-master.tar.bz2
privsep-master.tar.xz
implement one lua state per connectionHEADmaster
This allows you load various modules into a server lua state and give a performance boost when calling the privileged functions
Diffstat (limited to 'privsep.lua')
-rw-r--r--privsep.lua40
1 files changed, 0 insertions, 40 deletions
diff --git a/privsep.lua b/privsep.lua
deleted file mode 100644
index b6e8f95..0000000
--- a/privsep.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-
-ipcmsg = require("cmsgpack")
-ipcmsg.encode = ipcmsg.pack
-ipcmsg.decode = ipcmsg.unpack
-
-socket = require("socket")
-socket.unix = require("socket.unix")
-
-
-local modules_path = "./modules"
-
-local privsep = {}
-
-function privsep.call_privileged(mod, func, sectoken, args)
- local c = assert(socket.unix())
- assert(c:connect("/var/run/privsep/root.sock"))
-
- local req = { mod = mod, func = func, args = args, sectoken = sectoken }
- c:send(ipcmsg.encode(req))
- local retmsg, errmsg = c:receive("*a")
- if retmsg then
- local data = ipcmsg.decode(retmsg)
- return unpack(data.result or {})
- end
- return nil
-end
-
-function privsep.wrap(modname, sessionid)
- local mod = dofile(modules_path.."/"..modname..".lua")
- local f = {}
- for k,v in pairs(mod) do
- f[k] = function(...)
- return privsep.call_privileged(modname, k, sessionid, {...})
- end
- end
- return f
-end
-
-return privsep
-