9f4c393295
./gluon-wan:25:1: (W122) setting read-only field ? of global arg ./gluon-wan:29:1: (W311) value assigned to variable ok is unused
32 lines
697 B
Lua
Executable File
32 lines
697 B
Lua
Executable File
#!/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
|
|
local args = {[0] = arg[1], unpack(arg)}
|
|
table.remove(args, 1)
|
|
|
|
local _
|
|
_, err = unistd.execp(args[0], args)
|
|
|
|
io.stderr:write(string.format("gluon-wan: exec failed: %s\n", err))
|
|
os.exit(1)
|