]> git.ipfire.org Git - people/stevee/pakfire.git/blobdiff - python/src/util.c
Create an extra namespace for build environments and private network.
[people/stevee/pakfire.git] / python / src / util.c
index ed555f5496dc8d9ed6fca6fa1973b6a39278230e..acea90a0d642da13178a34542ae05b8e933874b4 100644 (file)
 #                                                                             #
 #############################################################################*/
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include <Python.h>
 
+#include <errno.h>
+#include <sched.h>
 #include <sys/personality.h>
 #include <unistd.h>
 
+#include "config.h"
 #include "util.h"
 
 PyObject *_personality(PyObject *self, PyObject *args) {
@@ -52,6 +59,21 @@ PyObject *_sync(PyObject *self, PyObject *args) {
        Py_RETURN_NONE;
 }
 
+PyObject *_unshare(PyObject *self, PyObject *args) {
+       int flags = 0;
+
+       if (!PyArg_ParseTuple(args, "i", &flags)) {
+               return NULL;
+       }
+
+       int ret = unshare(flags);
+       if (ret < 0) {
+               return PyErr_SetFromErrno(PyExc_RuntimeError);
+       }
+
+       return Py_BuildValue("i", ret);
+}
+
 PyObject *version_compare(PyObject *self, PyObject *args) {
        Pool *pool;
        const char *evr1, *evr2;