summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-01-22 14:49:51 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-01-22 14:49:51 +0100
commita4afed1e9a28498885382daf96ab7b8997821dca (patch)
tree072b663d6975e697d7b5c7a1e80883db00bbb90b /source4
parentfc50f7ecbab4bf273697f2114a723eae917251bb (diff)
downloadsamba-a4afed1e9a28498885382daf96ab7b8997821dca.tar.gz
samba-a4afed1e9a28498885382daf96ab7b8997821dca.tar.bz2
samba-a4afed1e9a28498885382daf96ab7b8997821dca.zip
Implement as_sddl.
Diffstat (limited to 'source4')
-rw-r--r--source4/libcli/security/tests/bindings.py10
-rw-r--r--source4/librpc/ndr/py_security.c20
2 files changed, 29 insertions, 1 deletions
diff --git a/source4/libcli/security/tests/bindings.py b/source4/libcli/security/tests/bindings.py
index f556a23e01..24ee01c37f 100644
--- a/source4/libcli/security/tests/bindings.py
+++ b/source4/libcli/security/tests/bindings.py
@@ -57,6 +57,16 @@ class SecurityDescriptorTests(unittest.TestCase):
self.assertEquals(desc.sacl, None)
self.assertEquals(desc.type, 0x8004)
+ def test_as_sddl(self):
+ text = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
+ dom = security.dom_sid("S-2-0-0")
+ desc1 = security.descriptor.from_sddl(text, dom)
+ desc2 = security.descriptor.from_sddl(desc1.as_sddl(dom), dom)
+ self.assertEquals(desc1.group_sid, desc2.group_sid)
+ self.assertEquals(desc1.owner_sid, desc2.owner_sid)
+ self.assertEquals(desc1.sacl, desc2.sacl)
+ self.assertEquals(desc1.type, desc2.type)
+
class DomSidTests(unittest.TestCase):
def test_parse_sid(self):
diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c
index e1b50def1d..93e4a093f3 100644
--- a/source4/librpc/ndr/py_security.c
+++ b/source4/librpc/ndr/py_security.c
@@ -33,7 +33,7 @@ static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods)
for (i = 0; methods[i].ml_name; i++) {
PyObject *descr;
if (methods[i].ml_flags & METH_CLASS)
- descr = PyCFunction_New(&methods[i], type);
+ descr = PyCFunction_New(&methods[i], (PyObject *)type);
else
descr = PyDescr_NewMethod(type, &methods[i]);
PyDict_SetItemString(dict, methods[i].ml_name,
@@ -187,6 +187,22 @@ static PyObject *py_descriptor_from_sddl(PyObject *self, PyObject *args)
return py_talloc_import((PyTypeObject *)self, secdesc);
}
+static PyObject *py_descriptor_as_sddl(PyObject *self, PyObject *py_sid)
+{
+ struct dom_sid *sid = py_talloc_get_ptr(py_sid);
+ struct security_descriptor *desc = py_talloc_get_ptr(self);
+ char *text;
+ PyObject *ret;
+
+ text = sddl_encode(NULL, desc, sid);
+
+ ret = PyString_FromString(text);
+
+ talloc_free(text);
+
+ return ret;
+}
+
static PyMethodDef py_descriptor_extra_methods[] = {
{ "sacl_add", (PyCFunction)py_descriptor_sacl_add, METH_VARARGS,
"S.sacl_add(ace) -> None\n"
@@ -199,6 +215,8 @@ static PyMethodDef py_descriptor_extra_methods[] = {
NULL },
{ "from_sddl", (PyCFunction)py_descriptor_from_sddl, METH_VARARGS|METH_CLASS,
NULL },
+ { "as_sddl", (PyCFunction)py_descriptor_as_sddl, METH_O,
+ NULL },
{ NULL }
};