[PATCH 1/2] s4-pyrpc: Add dcerpc_pipe_connect_creds_helper().

Andreas Schneider asn at samba.org
Fri Feb 14 10:03:00 MST 2014


Signed-off-by: Andreas Schneider <asn at samba.org>
---
 source4/librpc/rpc/pyrpc_util.c | 35 +++++++++++++++++++++++++++++++++++
 source4/librpc/rpc/pyrpc_util.h |  8 ++++++++
 2 files changed, 43 insertions(+)

diff --git a/source4/librpc/rpc/pyrpc_util.c b/source4/librpc/rpc/pyrpc_util.c
index ab6caac..f90f350 100644
--- a/source4/librpc/rpc/pyrpc_util.c
+++ b/source4/librpc/rpc/pyrpc_util.c
@@ -86,6 +86,41 @@ static NTSTATUS pyrpc_irpc_connect(TALLOC_CTX *mem_ctx, const char *irpc_server,
 	return NT_STATUS_OK;
 }
 
+NTSTATUS dcerpc_pipe_connect_creds_helper(TALLOC_CTX *mem_ctx,
+					  struct tevent_context *ev_ctx,
+					  const char *binding,
+					  const struct ndr_interface_table *table,
+					  PyObject *py_credentials,
+					  struct loadparm_context *lp_ctx,
+					  struct dcerpc_pipe **pp)
+{
+	struct cli_credentials *credentials;
+	NTSTATUS status;
+
+	credentials = cli_credentials_from_py_object(py_credentials);
+	if (credentials == NULL) {
+		PyErr_SetString(PyExc_TypeError, "Expected credentials");
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	status = dcerpc_pipe_connect(mem_ctx,
+				     pp,
+				     binding,
+				     table,
+				     credentials,
+				     ev_ctx,
+				     lp_ctx);
+	if (NT_STATUS_IS_OK(status)) {
+		/*
+		 * The event context is cached under the connection,
+		 * so let it be a child of it.
+		 */
+		talloc_steal((*pp)->conn, ev_ctx);
+	}
+
+	return status;
+}
+
 PyObject *py_dcerpc_interface_init_helper(PyTypeObject *type, PyObject *args, PyObject *kwargs,
 					  const struct ndr_interface_table *table)
 {
diff --git a/source4/librpc/rpc/pyrpc_util.h b/source4/librpc/rpc/pyrpc_util.h
index 837a33b..9252729 100644
--- a/source4/librpc/rpc/pyrpc_util.h
+++ b/source4/librpc/rpc/pyrpc_util.h
@@ -46,6 +46,14 @@ struct PyNdrRpcMethodDef {
 	const struct ndr_interface_table *table;
 };
 
+NTSTATUS dcerpc_pipe_connect_creds_helper(TALLOC_CTX *mem_ctx,
+					  struct tevent_context *ev_ctx,
+					  const char *binding,
+					  const struct ndr_interface_table *table,
+					  PyObject *py_credentials,
+					  struct loadparm_context *lp_ctx,
+					  struct dcerpc_pipe **pp);
+
 bool py_check_dcerpc_type(PyObject *obj, const char *module, const char *type_name);
 bool PyInterface_AddNdrRpcMethods(PyTypeObject *object, const struct PyNdrRpcMethodDef *mds);
 PyObject *py_dcerpc_interface_init_helper(PyTypeObject *type, PyObject *args, PyObject *kwargs, const struct ndr_interface_table *table);
-- 
1.8.5.2




More information about the samba-technical mailing list