DCE/RPC(Python): Rename py_talloc_import to py_talloc_steal.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 30 Jul 2009 18:04:42 +0000 (20:04 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 30 Jul 2009 18:04:42 +0000 (20:04 +0200)
 Use py_talloc_reference in DCE/RPC code, fixes
access to SAMR pipe.

lib/talloc/pytalloc.c
lib/talloc/pytalloc.h
pidl/lib/Parse/Pidl/Samba4/Python.pm
source4/lib/registry/pyregistry.c
source4/librpc/ndr/py_security.c
source4/scripting/python/examples/samr.py

index 3ce49d6d61fccb83d4ca93dbfcc995f911fc6695..646aac87f25003083499448cb00ccef2d211f450 100644 (file)
@@ -35,7 +35,7 @@ void py_talloc_dealloc(PyObject* self)
 /**
  * Import an existing talloc pointer into a Python object.
  */
-PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, 
+PyObject *py_talloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, 
                                                   void *ptr)
 {
        py_talloc_Object *ret = (py_talloc_Object *)py_type->tp_alloc(py_type, 0);
@@ -56,14 +56,14 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
  * original parent, and creating a reference to the object in the python
  * object
  */
-PyObject *py_talloc_reference(PyTypeObject *py_type, void *ptr)
+PyObject *py_talloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr)
 {
        py_talloc_Object *ret = (py_talloc_Object *)py_type->tp_alloc(py_type, 0);
        ret->talloc_ctx = talloc_new(NULL);
        if (ret->talloc_ctx == NULL) {
                return NULL;
        }
-       if (talloc_reference(ret->talloc_ctx, ptr) == NULL) {
+       if (talloc_reference(ret->talloc_ctx, mem_ctx) == NULL) {
                return NULL;
        }
        ret->ptr = ptr;
index 00282c4ba0e972b0d76609a425922211a6a72157..3bfb272958744b059fe348ac2d0e3edebf406e58 100644 (file)
@@ -42,13 +42,14 @@ void py_talloc_dealloc(PyObject* self);
 #define py_talloc_get_ptr(py_obj) (((py_talloc_Object *)py_obj)->ptr)
 #define py_talloc_get_mem_ctx(py_obj)  ((py_talloc_Object *)py_obj)->talloc_ctx
 
-PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
-PyObject *py_talloc_reference(PyTypeObject *py_type, void *ptr);
-#define py_talloc_import(py_type, talloc_ptr) py_talloc_import_ex(py_type, talloc_ptr, talloc_ptr)
+PyObject *py_talloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
+PyObject *py_talloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
+#define py_talloc_steal(py_type, talloc_ptr) py_talloc_steal_ex(py_type, talloc_ptr, talloc_ptr)
+#define py_talloc_reference(py_type, talloc_ptr) py_talloc_reference_ex(py_type, talloc_ptr, talloc_ptr)
 
 /* Sane default implementation of reprfunc. */
 PyObject *py_talloc_default_repr(PyObject *py_obj);
 
-#define py_talloc_new(type, typeobj) py_talloc_import(typeobj, talloc_zero(NULL, type))
+#define py_talloc_new(type, typeobj) py_talloc_steal(typeobj, talloc_zero(NULL, type))
 
 #endif /* _PY_TALLOC_H_ */
index d27192d6ddb76e31399606ed3eec5c67c51604f3..462f8333e1fa629671306c9807cd616562a1080a 100644 (file)
@@ -1030,7 +1030,7 @@ sub ConvertObjectToPythonData($$$$$;$)
                        error($location, "Unable to determine origin of type `" . mapTypeName($ctype) . "'");
                        return "NULL"; # FIXME!
                }
-               return "py_talloc_import_ex($ctype_name, $mem_ctx, $cvar)";
+               return "py_talloc_reference_ex($ctype_name, $mem_ctx, $cvar)";
        }
 
        fatal($location, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar");
index 30becbb1bbc09b9bdf9b3828e8487346b9a4a21a..f68bfd15ef5deddd8f93bb2eee70d94879f68097 100644 (file)
@@ -53,7 +53,7 @@ static PyObject *py_get_predefined_key_by_name(PyObject *self, PyObject *args)
        result = reg_get_predefined_key_by_name(ctx, name, &key);
        PyErr_WERROR_IS_ERR_RAISE(result);
 
-       return py_talloc_import(&PyRegistryKey, key);
+       return py_talloc_steal(&PyRegistryKey, key);
 }
 
 static PyObject *py_key_del_abs(PyObject *self, PyObject *args)
@@ -84,7 +84,7 @@ static PyObject *py_get_predefined_key(PyObject *self, PyObject *args)
        result = reg_get_predefined_key(ctx, hkey, &key);
        PyErr_WERROR_IS_ERR_RAISE(result);
 
-       return py_talloc_import(&PyRegistryKey, key);
+       return py_talloc_steal(&PyRegistryKey, key);
 }
 
 static PyObject *py_diff_apply(PyObject *self, PyObject *args)
@@ -140,7 +140,7 @@ static PyObject *registry_new(PyTypeObject *type, PyObject *args, PyObject *kwar
        struct registry_context *ctx;
        result = reg_open_local(NULL, &ctx);
        PyErr_WERROR_IS_ERR_RAISE(result);
-       return py_talloc_import(&PyRegistry, ctx);
+       return py_talloc_steal(&PyRegistry, ctx);
 }
 
 static PyMethodDef registry_methods[] = {
@@ -299,7 +299,7 @@ static PyObject *py_open_samba(PyObject *self, PyObject *args, PyObject *kwargs)
                return NULL;
        }
        
-       return py_talloc_import(&PyRegistry, reg_ctx);
+       return py_talloc_steal(&PyRegistry, reg_ctx);
 }
 
 static PyObject *py_open_directory(PyObject *self, PyObject *args)
@@ -314,7 +314,7 @@ static PyObject *py_open_directory(PyObject *self, PyObject *args)
        result = reg_open_directory(NULL, location, &key);
        PyErr_WERROR_IS_ERR_RAISE(result);
 
-       return py_talloc_import(&PyHiveKey, key);
+       return py_talloc_steal(&PyHiveKey, key);
 }
 
 static PyObject *py_create_directory(PyObject *self, PyObject *args)
@@ -329,7 +329,7 @@ static PyObject *py_create_directory(PyObject *self, PyObject *args)
        result = reg_create_directory(NULL, location, &key);
        PyErr_WERROR_IS_ERR_RAISE(result);
 
-       return py_talloc_import(&PyHiveKey, key);
+       return py_talloc_steal(&PyHiveKey, key);
 }
 
 static PyObject *py_open_ldb_file(PyObject *self, PyObject *args, PyObject *kwargs)
@@ -368,7 +368,7 @@ static PyObject *py_open_ldb_file(PyObject *self, PyObject *args, PyObject *kwar
                                                           tevent_context_init(NULL), lp_ctx, &key);
        PyErr_WERROR_IS_ERR_RAISE(result);
 
-       return py_talloc_import(&PyHiveKey, key);
+       return py_talloc_steal(&PyHiveKey, key);
 }
 
 static PyObject *py_str_regtype(PyObject *self, PyObject *args)
index 7ac4d34bafc1f10b88ffed96e57ba171553defc0..8ab790d4701b95af3c227e39f799daf16b99b819 100644 (file)
@@ -163,7 +163,7 @@ 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));
+       return py_talloc_steal(self, security_descriptor_initialise(NULL));
 }
 
 static PyObject *py_descriptor_from_sddl(PyObject *self, PyObject *args)
@@ -184,7 +184,7 @@ static PyObject *py_descriptor_from_sddl(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       return py_talloc_import((PyTypeObject *)self, secdesc);
+       return py_talloc_steal((PyTypeObject *)self, secdesc);
 }
 
 static PyObject *py_descriptor_as_sddl(PyObject *self, PyObject *args)
@@ -316,7 +316,7 @@ static PyObject *py_token_set_privilege(PyObject *self, PyObject *args)
 
 static PyObject *py_token_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)
 {
-       return py_talloc_import(self, security_token_initialise(NULL));
+       return py_talloc_steal(self, security_token_initialise(NULL));
 }      
 
 static PyMethodDef py_token_extra_methods[] = {
@@ -378,7 +378,7 @@ static PyObject *py_random_sid(PyObject *self)
 
         sid = dom_sid_parse_talloc(NULL, str);
        talloc_free(str);
-       ret = py_talloc_import(&dom_sid_Type, sid);
+       ret = py_talloc_steal(&dom_sid_Type, sid);
        return ret;
 }
 
index b3ea117b4024a77a42afaec5776690e196be964f..17ac3543208b5362947f21aa990fc21b57337399 100755 (executable)
@@ -24,7 +24,7 @@ import sys
 
 sys.path.insert(0, "bin/python")
 
-from samba.dcerpc import samr, security, lsa
+from samba.dcerpc import samr, security
 
 def display_lsa_string(str):
     return str.string