#include <libintl.h>
#include <locale.h>
-#include <sched.h>
#include <solv/solver.h>
{"version_compare", (PyCFunction)version_compare, METH_VARARGS, NULL},
{"get_capabilities", (PyCFunction)get_capabilities, METH_VARARGS, NULL},
{"sync", (PyCFunction)_sync, METH_NOARGS, NULL},
- {"unshare", (PyCFunction)_unshare, METH_VARARGS, NULL},
{"native_arch", (PyCFunction)_pakfire_native_arch, METH_NOARGS, NULL },
{"arch_supported_by_host", (PyCFunction)_pakfire_arch_supported_by_host, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
// Add constants
PyObject* d = PyModule_GetDict(module);
- // Namespace stuff
- PyDict_SetItemString(d, "SCHED_CLONE_NEWIPC", Py_BuildValue("i", CLONE_NEWIPC));
- PyDict_SetItemString(d, "SCHED_CLONE_NEWPID", Py_BuildValue("i", CLONE_NEWPID));
- PyDict_SetItemString(d, "SCHED_CLONE_NEWNET", Py_BuildValue("i", CLONE_NEWNET));
- PyDict_SetItemString(d, "SCHED_CLONE_NEWNS", Py_BuildValue("i", CLONE_NEWNS));
- PyDict_SetItemString(d, "SCHED_CLONE_NEWUTS", Py_BuildValue("i", CLONE_NEWUTS));
-
// Add constants for relations
PyDict_SetItemString(d, "REL_EQ", Py_BuildValue("i", REL_EQ));
PyDict_SetItemString(d, "REL_LT", Py_BuildValue("i", REL_LT));
#include <Python.h>
#include <errno.h>
-#include <sched.h>
#include <time.h>
#include <unistd.h>
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;
# Initialize cgroups
self.cgroup = self._make_cgroup()
- # Unshare namepsace.
- # If this fails because the kernel has no support for CLONE_NEWIPC or CLONE_NEWUTS,
- # we try to fall back to just set CLONE_NEWNS.
- try:
- _pakfire.unshare(_pakfire.SCHED_CLONE_NEWNS|_pakfire.SCHED_CLONE_NEWIPC|_pakfire.SCHED_CLONE_NEWUTS)
- except RuntimeError as e:
- _pakfire.unshare(_pakfire.SCHED_CLONE_NEWNS)
-
- # Optionally enable private networking.
- if self.settings.get("private_network", None):
- _pakfire.unshare(_pakfire.SCHED_CLONE_NEWNET)
-
def __enter__(self):
self.log.debug("Entering %s" % self.path)