diff options
author | Tim Potter <tpot@samba.org> | 2004-09-15 21:17:26 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:45 -0500 |
commit | dabb37c547dd44a5eb0b11c516208d4416c6655f (patch) | |
tree | 96ccfc2a3cdc9f8decc746e36b13584b350198be | |
parent | d9d634ce97b2fd7d49410d26271eacd98660bbc4 (diff) | |
download | samba-dabb37c547dd44a5eb0b11c516208d4416c6655f.tar.gz samba-dabb37c547dd44a5eb0b11c516208d4416c6655f.tar.bz2 samba-dabb37c547dd44a5eb0b11c516208d4416c6655f.zip |
r2357: Start coding conversion routines for security descriptors, acls and sids.
(This used to be commit c8d13a809b5b01823a62e5868bac47e1f2f25092)
-rw-r--r-- | source4/scripting/swig/dcerpc.i | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 75b078ad16..ea7b3d79a2 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -132,9 +132,62 @@ struct security_descriptor *security_descriptor_ptr_from_python(TALLOC_CTX *mem_ return NULL; } -PyObject *security_descriptor_to_python(struct security_descriptor *obj) +PyObject *dom_sid_to_python(struct dom_sid *obj) { - return PyDict_New(); + return PyString_FromString("<sid>"); +} + +PyObject *security_acl_to_python(struct security_acl *obj) +{ + PyObject *result = PyDict_New(); + PyObject *ace_list; + int i; + + if (!obj) { + Py_INCREF(Py_None); + return Py_None; + } + + PyDict_SetItem(result, PyString_FromString("revision"), PyInt_FromLong(obj->revision)); + PyDict_SetItem(result, PyString_FromString("size"), PyInt_FromLong(obj->size)); + + ace_list = PyList_New(obj->num_aces); + + for(i = 0; i < obj->num_aces; i++) { + PyObject *ace = PyDict_New(); + + PyDict_SetItem(ace, PyString_FromString("type"), PyInt_FromLong(obj->aces[i].type)); + PyDict_SetItem(ace, PyString_FromString("flags"), PyInt_FromLong(obj->aces[i].flags)); + PyDict_SetItem(ace, PyString_FromString("access_mask"), PyInt_FromLong(obj->aces[i].access_mask)); + PyDict_SetItem(ace, PyString_FromString("trustee"), dom_sid_to_python(&obj->aces[i].trustee)); + + PyList_SetItem(ace_list, i, ace); + } + + PyDict_SetItem(result, PyString_FromString("aces"), ace_list); + + return result; +} + +PyObject *security_descriptor_to_python(TALLOC_CTX *mem_ctx, struct security_descriptor *obj) +{ + PyObject *result = PyDict_New(); + + if (!obj) { + Py_INCREF(Py_None); + return Py_None; + } + + PyDict_SetItem(result, PyString_FromString("revision"), PyInt_FromLong(obj->revision)); + PyDict_SetItem(result, PyString_FromString("type"), PyInt_FromLong(obj->type)); + + PyDict_SetItem(result, PyString_FromString("owner_sid"), dom_sid_to_python(obj->owner_sid)); + PyDict_SetItem(result, PyString_FromString("group_sid"), dom_sid_to_python(obj->group_sid)); + + PyDict_SetItem(result, PyString_FromString("sacl"), security_acl_to_python(obj->sacl)); + PyDict_SetItem(result, PyString_FromString("dacl"), security_acl_to_python(obj->dacl)); + + return result; } struct dom_sid2 *dom_sid2_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) @@ -142,7 +195,7 @@ struct dom_sid2 *dom_sid2_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) return NULL; } -PyObject *dom_sid2_to_python(struct dom_sid2 *obj) +PyObject *dom_sid2_to_python(TALLOC_CTX *mem_ctx, struct dom_sid2 *obj) { return PyDict_New(); } |