2018-11-21 11:05:07 +00:00
|
|
|
#!/usr/bin/lua
|
|
|
|
|
|
|
|
local GROUP = 'gluon-mesh-vpn'
|
|
|
|
|
|
|
|
local grp = require 'posix.grp'
|
|
|
|
local unistd = require 'posix.unistd'
|
|
|
|
|
|
|
|
if #arg < 1 then
|
|
|
|
io.stderr:write('Usage: gluon-wan <command> ...\n')
|
|
|
|
os.exit(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
local g = grp.getgrnam(GROUP)
|
|
|
|
if not g then
|
|
|
|
io.stderr:write(string.format("gluon-wan: unable to find group '%s'\n", GROUP))
|
|
|
|
os.exit(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
local ok, err = unistd.setpid('g', g.gr_gid)
|
|
|
|
if ok ~= 0 then
|
|
|
|
io.stderr:write(string.format("gluon-wan: unable to change to group: %s\n", err))
|
|
|
|
os.exit(1)
|
|
|
|
end
|
2019-06-10 17:01:04 +00:00
|
|
|
local args = {[0] = arg[1], unpack(arg)}
|
|
|
|
table.remove(args, 1)
|
2018-11-21 11:05:07 +00:00
|
|
|
|
2019-06-10 17:01:04 +00:00
|
|
|
local _
|
|
|
|
_, err = unistd.execp(args[0], args)
|
2018-11-21 11:05:07 +00:00
|
|
|
|
|
|
|
io.stderr:write(string.format("gluon-wan: exec failed: %s\n", err))
|
|
|
|
os.exit(1)
|