CAP_NET_BIND_SERVICE is special, in all cases.
authorDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Tue, 26 Feb 2008 22:51:12 +0000 (22:51 +0000)
committerDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Tue, 26 Feb 2008 22:51:12 +0000 (22:51 +0000)
python/vserverimpl.c

index a568fb2..5e28fa2 100644 (file)
@@ -59,6 +59,8 @@ static inline PyObject *inc_and_ret_none(void)
 
 #define NONE  inc_and_ret_none()
 
+#define PL_INSECURE_BCAPS      (vc_get_insecurebcaps() | (1 << VC_CAP_NET_BIND_SERVICE))
+
 /*
  * context create
  */
@@ -71,7 +73,7 @@ vserver_chcontext(PyObject *self, PyObject *args)
 
   if (!PyArg_ParseTuple(args, "I|K", &ctx, &bcaps))
     return NULL;
-  bcaps |= ~(vc_get_insecurebcaps() | (1 << VC_CAP_NET_BIND_SERVICE));
+  bcaps |= ~PL_INSECURE_BCAPS;
 
   if ((ctx_is_new = pl_chcontext(ctx, bcaps, 0)) < 0)
     return PyErr_SetFromErrno(PyExc_OSError);
@@ -301,7 +303,7 @@ vserver_set_bcaps(PyObject *self, PyObject *args)
   if (!PyArg_ParseTuple(args, "IK", &ctx, &caps.bcaps))
     return NULL;
 
-  caps.bmask = vc_get_insecurebcaps();
+  caps.bmask = PL_INSECURE_BCAPS;
   caps.cmask = caps.ccaps = 0;
   if (vc_set_ccaps(ctx, &caps) == -1 && errno != ESRCH)
     return PyErr_SetFromErrno(PyExc_OSError);
@@ -341,7 +343,7 @@ vserver_get_bcaps(PyObject *self, PyObject *args)
       caps.bcaps = 0;
   }
 
-  return Py_BuildValue("K", caps.bcaps & vc_get_insecurebcaps());
+  return Py_BuildValue("K", caps.bcaps & PL_INSECURE_BCAPS);
 }
 
 static PyObject *