Codebase list python-unshare / 3bb32e0
New upstream version 0.2 Martín Ferrari 7 years ago
6 changed file(s) with 41 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
0 setup.py
1 unshare.c
2 COPYING
+0
-16
PKG-INFO less more
0 Metadata-Version: 1.0
1 Name: python-unshare
2 Version: 0.1
3 Summary: Python bindings for the Linux unshare() syscall
4 Home-page: http://code.google.com/p/python-unshare/
5 Author: Martin Ferrari
6 Author-email: martin.ferrari@gmail.com
7 License: GPLv2
8 Description: This simple extension provides bindings to the Linux unshare() syscall, added in kernel version 2.6.16
9
10 By using unshare(), new and interesting features of the Linux kernel can be exploited, such as:
11
12 * Creating a new network name space (CLONE_NEWNET)
13 * Creating a new file system mount name space (CLONE_NEWNS)
14 * Reverting other features shared from clone()
15 Platform: Linux
0 This simple extension provides bindings to the Linux `unshare()` syscall, added in kernel version 2.6.16
1
2 By using `unshare()`, new and interesting features of the Linux kernel can be exploited, such as:
3
4 * Creating a new network name space (`CLONE_NEWNET`)
5 * Creating a new file system mount name space (`CLONE_NEWNS`)
6 * Reverting other features shared from `clone()`
7
8 This library provides an equivalent of the (recently added) util-linux command-line program `unshare`.
0 [clean]
1 all = 1
1313
1414 setup(
1515 name = 'python-unshare',
16 version = '0.1',
16 version = '0.2',
1717 description = 'Python bindings for the Linux unshare() syscall',
1818 long_description = longdesc,
1919 author = 'Martin Ferrari',
3232 return PyErr_SetFromErrno(PyExc_OSError);
3333 Py_RETURN_NONE;
3434 }
35
36 static PyObject * _setns(PyObject *self, PyObject *args) {
37 int fd, nstype, ret;
38 if (!PyArg_ParseTuple(args, "ii", &fd, &nstype))
39 return NULL;
40 ret = setns(fd, nstype);
41 if(ret == -1)
42 return PyErr_SetFromErrno(PyExc_OSError);
43 Py_RETURN_NONE;
44 }
45
3546 static PyMethodDef methods[] = {
3647 {"unshare", _unshare, METH_VARARGS,
3748 "unshare(flags)\n\n"
4354 " CLONE_SYSVSEM CLONE_NEWUTS CLONE_NEWIPC CLONE_NEWUSER "
4455 "CLONE_NEWPID\n"
4556 " CLONE_NEWNET\n"
57 },
58 {"setns", _setns, METH_VARARGS,
59 "setns(fd, nstype)\n\n"
60 "Reassociate the calling thread with a new namespace.\n"
61 "fd is a filedescriptor referring to a namespace.\n"
62 "nstype specifies which type of namespace the calling thread\n"
63 "may be reassociated with.\n\n"
64 "Possible values for nstype:\n"
65 " 0 Allow any type of namespace to be joined.\n"
66 " CLONE_NEWIPC fd must refer to an IPC namespace.\n"
67 " CLONE_NEWNET fd must refer to a network namespace.\n"
68 " CLONE_NEWNS fd must refer to a mount namespace.\n"
69 " CLONE_NEWPID fd must refer to a descendant PID namespace.\n"
70 " CLONE_NEWUSER fd must refer to a user namespace.\n"
71 " CLONE_NEWUTS fd must refer to a UTS namespace.\n"
4672 },
4773 {NULL, NULL, 0, NULL}
4874 };