summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-12-16 00:16:02 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-12-16 00:16:02 +0100
commit530758dc2a6dd6dce083789b328e16e51ba6573d (patch)
treefaa06cc24e7adb49f012c9fd2c67599ec83513c8 /source4/librpc/ndr
parent2be233ebe39d6ce584848a7e6bbd68b011dd6930 (diff)
downloadsamba-530758dc2a6dd6dce083789b328e16e51ba6573d.tar.gz
samba-530758dc2a6dd6dce083789b328e16e51ba6573d.tar.bz2
samba-530758dc2a6dd6dce083789b328e16e51ba6573d.zip
Add python extensions for dom_sid.
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r--source4/librpc/ndr/py_security.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c
new file mode 100644
index 0000000000..6888f14375
--- /dev/null
+++ b/source4/librpc/ndr/py_security.c
@@ -0,0 +1,58 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "libcli/security/security.h"
+
+static PyObject *py_dom_sid_eq(PyObject *self, PyObject *args)
+{
+ struct dom_sid *this = py_talloc_get_ptr(self), *other;
+ PyObject *py_other;
+
+ if (!PyArg_ParseTuple(args, "O", &py_other))
+ return NULL;
+
+ other = py_talloc_get_type(py_other, struct dom_sid);
+ if (other == NULL)
+ return Py_False;
+
+ return dom_sid_equal(this, other)?Py_True:Py_False;
+}
+
+static PyObject *py_dom_sid_str(PyObject *self)
+{
+ struct dom_sid *this = py_talloc_get_ptr(self);
+ char *str = dom_sid_string(NULL, this);
+ PyObject *ret = PyString_FromString(str);
+ talloc_free(str);
+ return ret;
+}
+
+static PyObject *py_dom_sid_repr(PyObject *self)
+{
+ struct dom_sid *this = py_talloc_get_ptr(self);
+ char *str = dom_sid_string(NULL, this);
+ PyObject *ret = PyString_FromFormat("dom_sid('%s')", str);
+ talloc_free(str);
+ return ret;
+}
+
+#define PY_DOM_SID_REPR py_dom_sid_repr
+
+#define PY_DOM_SID_EXTRA_METHODS \
+ { "__eq__", (PyCFunction)py_dom_sid_eq, METH_VARARGS, "S.__eq__(x) -> S == x" }, \
+ { "__str__", (PyCFunction)py_dom_sid_str, METH_NOARGS, "S.__str__() -> str(S)" }, \