Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115996790
D26927.id78773.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D26927.id78773.diff
View Options
Index: lib/flua/libjail/jail.3lua
===================================================================
--- lib/flua/libjail/jail.3lua
+++ lib/flua/libjail/jail.3lua
@@ -30,11 +30,13 @@
.Dt JAIL 3lua
.Os
.Sh NAME
+.Nm attach ,
.Nm getid ,
.Nm getname ,
.Nm list ,
.Nm allparams ,
.Nm getparams ,
+.Nm remove ,
.Nm setparams ,
.Nm CREATE ,
.Nm UPDATE ,
@@ -48,11 +50,13 @@
.Ed
.Pp
.Bl -tag -width XXXX -compact
+.It Dv ok, err = jail.attach(jid|name)
.It Dv jid, err = jail.getid(name)
.It Dv name, err = jail.getname(jid)
.It Dv params, err = jail.allparams()
.It Dv iter, jail_obj = jail.list([params])
.It Dv jid, res = jail.getparams(jid|name, params [, flags ] )
+.It Dv ok, err = jail.remove(jid|name)
.It Dv jid, err = jail.setparams(jid|name, params, flags )
.It Dv jail.CREATE
.It Dv jail.UPDATE
@@ -71,6 +75,11 @@
.Xr jail_set 2
system calls.
.Bl -tag -width XXXX
+.It Dv ok, err = jail.attach(jid|name)
+Attach to the given jail, identified by an integer
+.Fa jid
+or the
+.Fa name .
.It Dv jid, err = jail.getid(name)
Get the jail identifier
.Pq jid
@@ -114,6 +123,11 @@
Only the
.Dv DYING
flag is valid to set.
+.It Dv ok, err = jail.remove(jid|name)
+Remove the given jail, identified by an integer
+.Fa jid
+or the
+.Fa name .
.It Dv 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.
@@ -188,6 +202,14 @@
The
.Fn list
function returns an iterator over the list of running jails.
+.Pp
+The
+.Fn attach
+and
+.Fn remove
+functions return true on success, or
+.Dv nil
+and an error message string if an error occurred.
.Sh EXAMPLES
Set the hostname of jail
.Dq foo
Index: lib/flua/libjail/lua_jail.c
===================================================================
--- lib/flua/libjail/lua_jail.c
+++ lib/flua/libjail/lua_jail.c
@@ -577,6 +577,68 @@
return (1);
}
+static int
+l_attach(lua_State *L)
+{
+ int jid, type;
+
+ type = lua_type(L, 1);
+ luaL_argcheck(L, type == LUA_TSTRING || type == LUA_TNUMBER, 1,
+ "expected a jail name (string) or id (integer)");
+
+ if (lua_isstring(L, 1)) {
+ /* Resolve it to a jid. */
+ jid = jail_getid(lua_tostring(L, 1));
+ if (jid == -1) {
+ lua_pushnil(L);
+ lua_pushstring(L, jail_errmsg);
+ return (2);
+ }
+ } else {
+ jid = lua_tointeger(L, 1);
+ }
+
+ if (jail_attach(jid) == -1) {
+ lua_pushnil(L);
+ lua_pushstring(L, strerror(errno));
+ return (2);
+ }
+
+ lua_pushboolean(L, 1);
+ return (1);
+}
+
+static int
+l_remove(lua_State *L)
+{
+ int jid, type;
+
+ type = lua_type(L, 1);
+ luaL_argcheck(L, type == LUA_TSTRING || type == LUA_TNUMBER, 1,
+ "expected a jail name (string) or id (integer)");
+
+ if (lua_isstring(L, 1)) {
+ /* Resolve it to a jid. */
+ jid = jail_getid(lua_tostring(L, 1));
+ if (jid == -1) {
+ lua_pushnil(L);
+ lua_pushstring(L, jail_errmsg);
+ return (2);
+ }
+ } else {
+ jid = lua_tointeger(L, 1);
+ }
+
+ if (jail_remove(jid) == -1) {
+ lua_pushnil(L);
+ lua_pushstring(L, strerror(errno));
+ return (2);
+ }
+
+ lua_pushboolean(L, 1);
+ return (1);
+}
+
static const struct luaL_Reg l_jail[] = {
/** Get id of a jail by name.
* @param name jail name (string)
@@ -618,6 +680,18 @@
* close methods
*/
{"list", l_list},
+ /** Attach to a running jail.
+ * @param jid jail id (integer)
+ * @return true (boolean)
+ * or nil, error (string) on error
+ */
+ {"attach", l_attach},
+ /** Remove a running jail.
+ * @param jid jail id (integer)
+ * @return true (boolean)
+ * or nil, error (string) on error
+ */
+ {"remove", l_remove},
{NULL, NULL}
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, May 2, 9:01 AM (18 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17903220
Default Alt Text
D26927.id78773.diff (3 KB)
Attached To
Mode
D26927: jail(3lua): add jail.attach()/jail.remove() methods
Attached
Detach File
Event Timeline
Log In to Comment