+static PyObject *
+vserver_set_ccaps(PyObject *self, PyObject *args)
+{
+ xid_t ctx;
+ struct vc_ctx_caps caps;
+
+ if (!PyArg_ParseTuple(args, "IK", &ctx, &caps.ccaps))
+ return NULL;
+
+ caps.cmask = PL_INSECURE_CCAPS;
+ caps.bmask = caps.bcaps = 0;
+ if (vc_set_ccaps(ctx, &caps) == -1 && errno != ESRCH)
+ return PyErr_SetFromErrno(PyExc_OSError);
+
+ return NONE;
+}
+
+static PyObject *
+vserver_text2ccaps(PyObject *self, PyObject *args)
+{
+ struct vc_ctx_caps caps = { .ccaps = 0 };
+ const char *list;
+ int len;
+ struct vc_err_listparser err;
+
+ if (!PyArg_ParseTuple(args, "s#", &list, &len))
+ return NULL;
+
+ vc_list2ccap(list, len, &err, &caps);
+
+ return Py_BuildValue("K", caps.ccaps);
+}
+
+static PyObject *
+vserver_get_ccaps(PyObject *self, PyObject *args)
+{
+ xid_t ctx;
+ struct vc_ctx_caps caps;
+
+ if (!PyArg_ParseTuple(args, "I", &ctx))
+ return NULL;
+
+ if (vc_get_ccaps(ctx, &caps) == -1) {
+ if (errno != ESRCH)
+ return PyErr_SetFromErrno(PyExc_OSError);
+ else
+ caps.ccaps = 0;
+ }
+
+ return Py_BuildValue("K", caps.ccaps & PL_INSECURE_CCAPS);
+}
+
+static PyObject *
+vserver_ccaps2text(PyObject *self, PyObject *args)
+{
+ struct vc_ctx_caps caps = { .ccaps = 0 };
+ PyObject *list;
+ const char *cap;
+
+ if (!PyArg_ParseTuple(args, "K", &caps.ccaps))
+ return NULL;
+
+ list = PyString_FromString("");
+
+ while ((cap = vc_loccap2text(&caps.ccaps)) != NULL) {
+ if (list == NULL)
+ break;
+ PyString_ConcatAndDel(&list, PyString_FromFormat(
+ (PyString_Size(list) > 0 ? ",%s" : "%s" ),
+ cap));
+ }
+
+ return list;
+}
+