From ae613d8298280e48adfdf255859c1e65f47cc610 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 20 Nov 2011 10:59:09 +0100 Subject: [PATCH] capabilities: Ignore EOPNOTSUPP. Also fixes SEGV in capabilities module, when an exception is raised. --- python/src/capabilities.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/src/capabilities.c b/python/src/capabilities.c index c33607a7f..fb5574d13 100644 --- a/python/src/capabilities.c +++ b/python/src/capabilities.c @@ -29,7 +29,7 @@ PyObject * get_capabilities(PyObject *self, PyObject *args) { const char *filename; cap_t cap_d; - char *exception = NULL; + char exception[STRING_SIZE]; if (!PyArg_ParseTuple(args, "s", &filename)) { /* XXX raise exception */ @@ -38,7 +38,10 @@ get_capabilities(PyObject *self, PyObject *args) { cap_d = cap_get_file(filename); if (cap_d == NULL) { - if (errno != ENODATA) { + if (errno == EOPNOTSUPP) { + /* Return nothing, if the operation is not supported. */ + Py_RETURN_NONE; + } else if (errno != ENODATA) { snprintf(exception, STRING_SIZE - 1, "Failed to get capabilities of file %s (%s).", filename, strerror(errno)); PyErr_SetString(PyExc_RuntimeError, exception); -- 2.39.5