py_security: Fix comparison between two dom_sid objects
authorAmitay Isaacs <amitay@gmail.com>
Thu, 18 Aug 2011 05:11:20 +0000 (15:11 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 19 Aug 2011 06:35:03 +0000 (16:35 +1000)
dom_sid_compare() function can return values other than -1, 0, 1.
Python requires compare function to return value from [-1, 0, 1].

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/librpc/ndr/py_security.c

index 2d038cfcca8d06695c040fa8c698ffa101c41488..7f79796ea261a480e474b2dfb6f94634d5bd5747 100644 (file)
@@ -72,11 +72,19 @@ static PyObject *py_dom_sid_split(PyObject *py_self, PyObject *args)
 static int py_dom_sid_cmp(PyObject *py_self, PyObject *py_other)
 {
        struct dom_sid *self = pytalloc_get_ptr(py_self), *other;
 static int py_dom_sid_cmp(PyObject *py_self, PyObject *py_other)
 {
        struct dom_sid *self = pytalloc_get_ptr(py_self), *other;
+       int val;
+
        other = pytalloc_get_ptr(py_other);
        if (other == NULL)
                return -1;
 
        other = pytalloc_get_ptr(py_other);
        if (other == NULL)
                return -1;
 
-       return dom_sid_compare(self, other);
+       val =  dom_sid_compare(self, other);
+       if (val > 0) {
+               return 1;
+       } else if (val < 0) {
+               return -1;
+       }
+       return 0;
 }
 
 static PyObject *py_dom_sid_str(PyObject *py_self)
 }
 
 static PyObject *py_dom_sid_str(PyObject *py_self)