Hello,
I'd like to have jsil(2) moved to COMPAT_FREEBSD11 for the release of
12.0, which means that userspace utilities will need to be moved off of
jail(2) and onto jail_set(2).
In the case of py-freebsd, the PyFB_jail function uses the old jail(2)
interface. It's simple enough to change that to use jail_setv(3)
instead, and add libjail. Perhaps it would be better to add a new
function for a more complete interface to jail_set(2), but that's beyond
the scope of just making sure the program doesn't stop working.
Considering it uses Python 2.7, I don't know if there's much interest in
updating its functionality.
I'm including an updated version of patch-src-jail.c, as well as a new
patch-src-.libraries.def - but I don't know how to make the later patch
actually get used; so all I can say right now is this ought to work if I
knew how to get the patches right.
Thanks,
Jamie
--- src/.libraries.def.orig 2018-08-16 14:17:29.351517000 -0600
+++ src/.libraries.def
@@ -1,3 +1,6 @@
#if __FreeBSD_version >= 500101
geom
#endif
+#if __FreeBSD_version >= 800101
+jail
+#endif
--- src/jail.c.orig 2005-05-08 00:55:00.000000000 -0600
+++ src/jail.c
@@ -27,6 +27,7 @@
*/
#include <sys/jail.h>
+#include <jail.h>
static char PyFB_jail__doc__[] =
"jail(path, hostname, ip_number):\n"
@@ -39,23 +40,23 @@
static PyObject *
PyFB_jail(PyObject *self, PyObject *args)
{
- struct jail jp;
- char *ipaddr;
+ char *j_path, *j_hostname, *j_ipaddr;foo
+ int error;
- if (!PyArg_ParseTuple(args, "sss:jail", &(jp.path),
- &(jp.hostname), &ipaddr))
+ if (!PyArg_ParseTuple(args, "sss:jail", &j_path,
+ &j_hostname, &j_ipaddr))
return NULL;
- jp.version = 0;
- jp.ip_number = inet_addr(ipaddr);
+ error = jail_setv(JAIL_CREATE | JAIL_ATTACH,
+ "path", j_path,
+ "host.hostname", j_hostname,
+ "ip4.addr", j_ipaddr,
+ NULL);
- if (jp.ip_number == INADDR_NONE) {
- PyErr_SetString(PyExc_ValueError, "malformed internet address");
- return NULL;
- }
-
- if (jail(&jp) == -1)
+ if (error == -1) {
+ PyErr_SetString(PyExc_ValueError, jail_errmsg);
return OSERROR();
+ }
Py_RETURN_NONE;
}
_______________________________________________
freebsd-python@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-python
To unsubscribe, send any mail to "freebsd-python-unsubscr...@freebsd.org"