NAME
getid
, getname
,
allparams
, getparams
,
setparams
, CREATE
,
UPDATE
, ATTACH
,
DYING
—
Lua binding to
jail(3)
SYNOPSIS
local jail = require('jail')
jid, err = jail.getid(name)
name, err = jail.getname(jid)
params, err = jail.allparams()
jid, res = jail.getparams(jid|name, params [, flags
])jid, err = jail.setparams(jid|name, params, flags
)jail.CREATE
jail.UPDATE
jail.ATTACH
jail.DYING
DESCRIPTION
Thejail
module is a binding to the
jail(3) library. It provides a string-oriented interface for the
jail_get(2) and
jail_set(2) system calls.
jid, err = jail.getid(name)
- Get the jail identifier (jid) as an integer. name is the name of a jail or a jid in the form of a string.
name, err = jail.getname(jid)
- Get the name of a jail as a string for the given jid (an integer).
params, err = jail.allparams()
- Get a list of all supported parameter names (as strings). See jail(8) for descriptions of the core jail parameters.
jid, res = jail.getparams(jid|name, params [, flags
])- Get a table of the requested parameters for the given jail.
jid|name
can either be the jid as an integer or the jid or name as a string.params
is a list of parameter names.flags
is an optional integer representing the flag bits to apply for the operation. See the list of flags below. Only theDYING
flag is valid to set. jid, err = jail.setparams(jid|name, params [, flags
])- Set parameters for a given jail. This is used to create, update, attach
to, or destroy a jail.
jid|name
can either be the jid as an integer or the jid or name as a string.params
is a table of parameters to apply to the jail, where each key in the table is a parameter name as a string and each value is a string that will be converted to the internal value type by jailparam_import(3).flags
is an optional integer representing the flag bits to apply for the operation. See the list of flags below.
The flags
arguments are an integer
bitwise-or combination of one or more of the following flags:
jail.CREATE
- Used with
setparams
() to create a new jail. The jail must not already exist, unless combined withUPDATE
. jail.UPDATE
- Used with
setparams
() to modify an existing jail. The jail must already exist, unless combined withCREATE
. jail.ATTACH
- Used with
setparams
() in combination withCREATE
orUPDATE
to attach the current process to a jail. jail.DYING
- Allow operating on a jail that is in the process of being removed.
RETURN VALUES
The getid
() and
setparams
() functions return a jail identifier
integer on success, or nil
and an error message
string if an error occurred.
The getname
() function returns a jail name
string on success, or nil
and an error message
string if an error occurred.
The allparams
() function returns a list of
parameter name strings on success, or nil
and an
error message string if an error occurred.
The getparams
() function returns a jail
identifier integer and a table of jail parameters with parameter name
strings as keys and strings for values on success, or
nil
and an error message string if an error
occurred.
EXAMPLES
Set the hostname of jail “foo” to “foo.bar”:
local jail = require('jail') jid, err = jail.setparams("foo", {["host.hostname"]="foo.bar"}, jail.UPDATE) if not jid then error(err) end
Retrieve the hostname of jail “foo”:
local jail = require('jail') jid, res = jail.getparams("foo", {"host.hostname"}) if not jid then error(res) end print(res["host.hostname"])
SEE ALSO
HISTORY
The jail
Lua module for flua first
appeared in FreeBSD 13.0.
AUTHORS
Ryan Moeller, with inspiration from
NetBSD gpio(3lua), by
Mark Balmer.