[PATCH 2/2] s4-pyrpc: Fix talloc hierachy in dceprc interface functions.

Stefan (metze) Metzmacher metze at samba.org
Fri Feb 14 10:22:44 MST 2014


Hi Andreas,

that's the wrong way... more comments later...

metze
Am 14.02.2014 18:03, schrieb Andreas Schneider:
> Signed-off-by: Andreas Schneider <asn at samba.org>
> ---
>  source4/librpc/rpc/pyrpc.c      | 22 +++++++---------------
>  source4/librpc/rpc/pyrpc_util.c | 15 +++++++--------
>  2 files changed, 14 insertions(+), 23 deletions(-)
> 
> diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c
> index 0de3681..d77b35d 100644
> --- a/source4/librpc/rpc/pyrpc.c
> +++ b/source4/librpc/rpc/pyrpc.c
> @@ -356,7 +356,6 @@ static PyObject *dcerpc_interface_new(PyTypeObject *type, PyObject *args, PyObje
>  	} else {
>  		struct tevent_context *event_ctx;
>  		struct loadparm_context *lp_ctx;
> -		struct cli_credentials *credentials;
>  
>  		event_ctx = s4_event_context_init(ret->mem_ctx);
>  		if (event_ctx == NULL) {
> @@ -372,20 +371,13 @@ static PyObject *dcerpc_interface_new(PyTypeObject *type, PyObject *args, PyObje
>  			return NULL;
>  		}
>  
> -		credentials = cli_credentials_from_py_object(py_credentials);
> -		if (credentials == NULL) {
> -			PyErr_SetString(PyExc_TypeError, "Expected credentials");
> -			TALLOC_FREE(ret->mem_ctx);
> -			return NULL;
> -		}
> -		status = dcerpc_pipe_connect(ret->mem_ctx, &ret->pipe, binding_string, 
> -			     table, credentials, event_ctx, lp_ctx);
> -
> -		/*
> -		 * the event context is cached under the connection,
> -		 * so let it be a child of it.
> -		 */
> -		talloc_steal(ret->pipe->conn, event_ctx);
> +		status = dcerpc_pipe_connect_creds_helper(ret->mem_ctx,
> +							  event_ctx,
> +							  binding_string,
> +							  table,
> +							  py_credentials,
> +							  lp_ctx,
> +							  &ret->pipe);
>  	}
>  
>  	if (!NT_STATUS_IS_OK(status)) {
> diff --git a/source4/librpc/rpc/pyrpc_util.c b/source4/librpc/rpc/pyrpc_util.c
> index f90f350..c887181 100644
> --- a/source4/librpc/rpc/pyrpc_util.c
> +++ b/source4/librpc/rpc/pyrpc_util.c
> @@ -200,14 +200,13 @@ PyObject *py_dcerpc_interface_init_helper(PyTypeObject *type, PyObject *args, Py
>  
>  		ret->pipe = talloc_steal(ret->mem_ctx, ret->pipe);
>  	} else {
> -		credentials = cli_credentials_from_py_object(py_credentials);
> -		if (credentials == NULL) {
> -			PyErr_SetString(PyExc_TypeError, "Expected credentials");
> -			talloc_free(mem_ctx);
> -			return NULL;
> -		}
> -		status = dcerpc_pipe_connect(event_ctx, &ret->pipe, binding_string,
> -		             table, credentials, event_ctx, lp_ctx);
> +		status = dcerpc_pipe_connect_creds_helper(ret->mem_ctx,
> +							  event_ctx,
> +							  binding_string,
> +							  table,
> +							  py_credentials,
> +							  lp_ctx,
> +							  &ret->pipe);
>  	}
>  	if (NT_STATUS_IS_ERR(status)) {
>  		PyErr_SetNTSTATUS(status);
> 



More information about the samba-technical mailing list