mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
Implement as_sddl.
This commit is contained in:
parent
fc50f7ecba
commit
a4afed1e9a
@ -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):
|
||||
|
@ -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 }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user