summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-01-22 14:37:59 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-01-22 14:37:59 +0100
commitfc50f7ecbab4bf273697f2114a723eae917251bb (patch)
treea1d8d0b4e2fac1502ca83c1a6ba5995578a90e03 /source4/librpc/ndr
parent8f68a716fdefb153811d7d930fdd73df9963246a (diff)
downloadsamba-fc50f7ecbab4bf273697f2114a723eae917251bb.tar.gz
Support parsing sddl for security descriptors.
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r--source4/librpc/ndr/py_security.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c
index 08542640b99..e1b50def1d4 100644
--- a/source4/librpc/ndr/py_security.c
+++ b/source4/librpc/ndr/py_security.c
@@ -31,7 +31,11 @@ static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods)
type->tp_dict = PyDict_New();
dict = type->tp_dict;
for (i = 0; methods[i].ml_name; i++) {
- PyObject *descr = PyDescr_NewMethod(type, &methods[i]);
+ PyObject *descr;
+ if (methods[i].ml_flags & METH_CLASS)
+ descr = PyCFunction_New(&methods[i], type);
+ else
+ descr = PyDescr_NewMethod(type, &methods[i]);
PyDict_SetItemString(dict, methods[i].ml_name,
descr);
}
@@ -160,7 +164,28 @@ static PyObject *py_descriptor_sacl_del(PyObject *self, PyObject *args)
static PyObject *py_descriptor_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)
{
return py_talloc_import(self, security_descriptor_initialise(NULL));
-}
+}
+
+static PyObject *py_descriptor_from_sddl(PyObject *self, PyObject *args)
+{
+ struct security_descriptor *secdesc;
+ char *sddl;
+ PyObject *py_sid;
+ struct dom_sid *sid;
+
+ if (!PyArg_ParseTuple(args, "sO", &sddl, &py_sid))
+ return NULL;
+
+ sid = py_talloc_get_ptr(py_sid);
+
+ secdesc = sddl_decode(NULL, sddl, sid);
+ if (secdesc == NULL) {
+ PyErr_SetString(PyExc_TypeError, "Unable to parse SDDL");
+ return NULL;
+ }
+
+ return py_talloc_import((PyTypeObject *)self, secdesc);
+}
static PyMethodDef py_descriptor_extra_methods[] = {
{ "sacl_add", (PyCFunction)py_descriptor_sacl_add, METH_VARARGS,
@@ -172,6 +197,8 @@ static PyMethodDef py_descriptor_extra_methods[] = {
NULL },
{ "sacl_del", (PyCFunction)py_descriptor_sacl_del, METH_VARARGS,
NULL },
+ { "from_sddl", (PyCFunction)py_descriptor_from_sddl, METH_VARARGS|METH_CLASS,
+ NULL },
{ NULL }
};