diff options
author | Volker Lendecke <vl@samba.org> | 2021-04-16 17:22:12 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2021-04-19 18:18:32 +0000 |
commit | 439b7ccdc1b1c91c66c1a7c83e340fa044c26377 (patch) | |
tree | 0ebae526a77dfc9e474c3faed4062742782a0a68 /source4 | |
parent | d298623c85dcf2d018c5ad83b9959b805ad42929 (diff) | |
download | samba-439b7ccdc1b1c91c66c1a7c83e340fa044c26377.tar.gz |
librpc: Add py_descriptor_richcmp() equality function
Only a python3 version. Do we still need the python2 flavor?
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source4')
-rw-r--r-- | source4/librpc/ndr/py_security.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c index 7e260ae2157..f3cc9d13a7f 100644 --- a/source4/librpc/ndr/py_security.c +++ b/source4/librpc/ndr/py_security.c @@ -309,9 +309,46 @@ static PyMethodDef py_descriptor_extra_methods[] = { {0} }; +static PyObject *py_descriptor_richcmp( + PyObject *py_self, PyObject *py_other, int op) +{ + struct security_descriptor *self = pytalloc_get_ptr(py_self); + struct security_descriptor *other = pytalloc_get_ptr(py_other); + bool eq; + + if (other == NULL) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + + eq = security_descriptor_equal(self, other); + + switch(op) { + case Py_EQ: + if (eq) { + Py_RETURN_TRUE; + } else { + Py_RETURN_FALSE; + } + break; + case Py_NE: + if (eq) { + Py_RETURN_FALSE; + } else { + Py_RETURN_TRUE; + } + break; + default: + break; + } + + return Py_NotImplemented; +} + static void py_descriptor_patch(PyTypeObject *type) { type->tp_new = py_descriptor_new; + type->tp_richcompare = py_descriptor_richcmp; PyType_AddMethods(type, py_descriptor_extra_methods); } |