diff options
author | Tim Potter <tpot@samba.org> | 2004-09-18 08:41:26 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:49 -0500 |
commit | b02b2fa3473a8249a8a69eb5cc08ab207503ecd0 (patch) | |
tree | dbded1e57786bb35171182978caaa2ce7bbe5c2f /source4/scripting | |
parent | 4a6313a543c7be6b7f4e1b68b23bc8fa62be70b2 (diff) | |
download | samba-b02b2fa3473a8249a8a69eb5cc08ab207503ecd0.tar.gz samba-b02b2fa3473a8249a8a69eb5cc08ab207503ecd0.tar.bz2 samba-b02b2fa3473a8249a8a69eb5cc08ab207503ecd0.zip |
r2408: Tridge suggested that all the structures from misc.idl (policy handles,
sids, security descriptors and acls) can be automatically generated
instead of hand-written. Fix up the swig wrapper generator and helper
routines to do this. (Only works for policy handles right now though and
arrays are to be converted into lists instead of being binary blobs).
Fix up wrapper generation for modules that don't define an interface
(e.g misc.idl).
(This used to be commit 160dc90921ecc136a25ae88e5c28800ddda5722a)
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/swig/dcerpc.i | 134 |
1 files changed, 2 insertions, 132 deletions
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 3b596e85e1..64d757c634 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -140,146 +140,15 @@ PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj) return PyString_FromString(obj); } -struct policy_handle *policy_handle_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) -{ - return (struct policy_handle *)PyString_AsString(obj); -} - -PyObject *policy_handle_ptr_to_python(TALLOC_CTX *mem_ctx, struct policy_handle *handle) -{ - return PyString_FromStringAndSize((char *)handle, sizeof(*handle)); -} - -PyObject *dom_sid_ptr_to_python(TALLOC_CTX *mem_ctx, struct dom_sid *obj) -{ - return PyString_FromString(dom_sid_string(mem_ctx, obj)); -} - -struct dom_sid *dom_sid_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) -{ - return dom_sid_parse_talloc(mem_ctx, PyString_AsString(obj)); -} - #define dom_sid2_ptr_to_python dom_sid_ptr_to_python #define dom_sid2_ptr_from_python dom_sid_ptr_from_python -void dom_sid_from_python(TALLOC_CTX *mem_ctx, struct dom_sid *sid, PyObject *obj) -{ - memset(sid, 0, sizeof(struct dom_sid)); // XXX -} - -PyObject *security_acl_ptr_to_python(TALLOC_CTX *mem_ctx, 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_ptr_to_python(mem_ctx, &obj->aces[i].trustee)); - - PyList_SetItem(ace_list, i, ace); - } - - PyDict_SetItem(result, PyString_FromString("aces"), ace_list); - - return result; -} - -struct security_acl *security_acl_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) -{ - struct security_acl *acl = talloc(mem_ctx, sizeof(struct security_acl)); - PyObject *ace_list; - int i, len; - - acl->revision = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("revision"))); - acl->size = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("size"))); - ace_list = PyDict_GetItem(obj, PyString_FromString("aces")); - - len = PyList_Size(ace_list); - acl->num_aces = len; - acl->aces = talloc(mem_ctx, len * sizeof(struct security_ace)); - - for (i = 0; i < len; i++) { - acl->aces[i].type = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("type"))); - acl->aces[i].flags = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("flags"))); - acl->aces[i].size = 0; - acl->aces[i].access_mask = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("access_mask"))); - - dom_sid_from_python(mem_ctx, &acl->aces[i].trustee, PyDict_GetItem(obj, PyString_FromString("trustee"))); - } - - return acl; -} - -PyObject *security_descriptor_ptr_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_ptr_to_python(mem_ctx, obj->owner_sid)); - PyDict_SetItem(result, PyString_FromString("group_sid"), dom_sid_ptr_to_python(mem_ctx, obj->group_sid)); - - PyDict_SetItem(result, PyString_FromString("sacl"), security_acl_ptr_to_python(mem_ctx, obj->sacl)); - PyDict_SetItem(result, PyString_FromString("dacl"), security_acl_ptr_to_python(mem_ctx, obj->dacl)); - - return result; -} - -struct security_descriptor *security_descriptor_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) -{ - struct security_descriptor *sd = talloc(mem_ctx, sizeof(struct security_descriptor)); - - sd->revision = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("revision"))); - sd->type = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("type"))); - - sd->owner_sid = security_descriptor_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("owner_sid"))); - sd->group_sid = security_descriptor_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("group_sid"))); - - sd->sacl = security_acl_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("sacl"))); - sd->dacl = security_acl_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("dacl"))); - - return sd; -} - -struct samr_Password *samr_Password_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) -{ - return NULL; -} - -PyObject *samr_Password_ptr_to_python(TALLOC_CTX *mem_ctx, struct samr_Password *obj) -{ - Py_INCREF(Py_None); - return Py_None; -} - %} %include "samba.i" %init %{ -/* setup_logging("python", DEBUG_STDOUT); */ + setup_logging("python", DEBUG_STDOUT); lp_load(dyn_CONFIGFILE, True, False, False); load_interfaces(); ntstatus_exception = PyErr_NewException("dcerpc.NTSTATUS", NULL, NULL); @@ -329,5 +198,6 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *username, const char *password); +%include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" |