From b7b559049eb9baf21b81910a5a443c5a294ba743 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Fri, 29 Nov 2019 15:53:48 +0100 Subject: [PATCH] Raise better error message on un-owned but valid Entry deletion --- acl.c | 5 +++++ tests/test_acls.py | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/acl.c b/acl.c index ed21fb6..b5f887b 100644 --- a/acl.c +++ b/acl.c @@ -570,6 +570,11 @@ static PyObject* ACL_delete_entry(PyObject *obj, PyObject *args) { if (!PyArg_ParseTuple(args, "O!", &Entry_Type, &e)) return NULL; + if (e->parent_acl != obj) { + PyErr_SetString(PyExc_ValueError, + "Can't remove un-owned entry"); + return NULL; + } if(acl_delete_entry(self->acl, e->entry) == -1) return PyErr_SetFromErrno(PyExc_IOError); diff --git a/tests/test_acls.py b/tests/test_acls.py index 710a129..4721201 100644 --- a/tests/test_acls.py +++ b/tests/test_acls.py @@ -597,6 +597,15 @@ class TestModification: with pytest.raises(EnvironmentError): acl.delete_entry(e) + def test_delete_unowned(self): + """Test delete Entry from the ACL""" + a = posix1e.ACL() + b = posix1e.ACL() + e = a.append() + e.tag_type = posix1e.ACL_OTHER + with pytest.raises(ValueError, match="un-owned entry"): + b.delete_entry(e) + # This currently fails as this deletion seems to be accepted :/ @pytest.mark.xfail(reason="Entry deletion is unreliable") def testDeleteInvalidEntry(self): -- 2.39.5