[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Sun Mar 13 04:20:02 MDT 2011


The branch, master has been updated
       via  4d4c631 s4:librpc/rpc: remove unused dcerpc_ndr_request* code
       via  7888f0e s4:torture/rpc/object_uuid: use dcerpc_binding_handle_call() instead of dcerpc_ndr_request()
       via  38be8c2 s4:rpc_server/remote: use dcerpc_binding_handle_call_*() instead of dcerpc_ndr_request_*()
      from  f84d439 Revert "s3: Fix bug 8009"

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4d4c6315fa65b9938d1b4222832d12055c46e681
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Mar 12 10:18:56 2011 +0100

    s4:librpc/rpc: remove unused dcerpc_ndr_request* code
    
    metze
    
    Autobuild-User: Stefan Metzmacher <metze at samba.org>
    Autobuild-Date: Sun Mar 13 11:19:59 CET 2011 on sn-devel-104

commit 7888f0e7f779e4d3180978ed7bccdb15e036996a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Mar 12 10:16:22 2011 +0100

    s4:torture/rpc/object_uuid: use dcerpc_binding_handle_call() instead of dcerpc_ndr_request()
    
    metze

commit 38be8c24fc25933cb5bccaedfd8320b1cdac73ab
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Mar 11 18:53:35 2011 +0100

    s4:rpc_server/remote: use dcerpc_binding_handle_call_*() instead of dcerpc_ndr_request_*()
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 source4/librpc/rpc/dcerpc.c               |  189 -----------------------------
 source4/librpc/rpc/dcerpc.h               |   15 ---
 source4/rpc_server/remote/dcesrv_remote.c |   24 ++--
 source4/torture/rpc/object_uuid.c         |    6 +-
 4 files changed, 18 insertions(+), 216 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c
index d467845..3e1aa6f 100644
--- a/source4/librpc/rpc/dcerpc.c
+++ b/source4/librpc/rpc/dcerpc.c
@@ -1747,195 +1747,6 @@ static NTSTATUS dcerpc_ndr_validate_out(struct dcecli_connection *c,
 	return NT_STATUS_OK;
 }
 
-
-/**
- send a rpc request given a dcerpc_call structure 
- */
-struct rpc_request *dcerpc_ndr_request_send(struct dcerpc_pipe *p,
-					    const struct GUID *object,
-					    const struct ndr_interface_table *table,
-					    uint32_t opnum,
-					    bool async,
-					    TALLOC_CTX *mem_ctx,
-					    void *r)
-{
-	const struct ndr_interface_call *call;
-	struct ndr_push *push;
-	NTSTATUS status;
-	DATA_BLOB request;
-	struct rpc_request *req;
-	enum ndr_err_code ndr_err;
-
-	call = &table->calls[opnum];
-
-	/* setup for a ndr_push_* call */
-	push = ndr_push_init_ctx(mem_ctx);
-	if (!push) {
-		return NULL;
-	}
-
-	if (p->conn->flags & DCERPC_PUSH_BIGENDIAN) {
-		push->flags |= LIBNDR_FLAG_BIGENDIAN;
-	}
-
-	if (p->conn->flags & DCERPC_NDR64) {
-		push->flags |= LIBNDR_FLAG_NDR64;
-	}
-
-	/* push the structure into a blob */
-	ndr_err = call->ndr_push(push, NDR_IN, r);
-	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-		status = ndr_map_error2ntstatus(ndr_err);
-		DEBUG(2,("Unable to ndr_push structure in dcerpc_ndr_request_send - %s\n",
-			 nt_errstr(status)));
-		talloc_free(push);
-		return NULL;
-	}
-
-	/* retrieve the blob */
-	request = ndr_push_blob(push);
-
-	if (p->conn->flags & DCERPC_DEBUG_VALIDATE_IN) {
-		status = dcerpc_ndr_validate_in(p->conn, push, request, call->struct_size, 
-						call->ndr_push, call->ndr_pull);
-		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(2,("Validation failed in dcerpc_ndr_request_send - %s\n",
-				 nt_errstr(status)));
-			talloc_free(push);
-			return NULL;
-		}
-	}
-
-	DEBUG(10,("rpc request data:\n"));
-	dump_data(10, request.data, request.length);
-
-	/* make the actual dcerpc request */
-	req = dcerpc_request_send(p, object, opnum, &request);
-
-	if (req != NULL) {
-		req->ndr.table = table;
-		req->ndr.opnum = opnum;
-		req->ndr.struct_ptr = r;
-		req->ndr.mem_ctx = mem_ctx;
-	}
-
-	talloc_free(push);
-
-	return req;
-}
-
-/*
-  receive the answer from a dcerpc_ndr_request_send()
-*/
-_PUBLIC_ NTSTATUS dcerpc_ndr_request_recv(struct rpc_request *req)
-{
-	struct dcerpc_pipe *p = req->p;
-	NTSTATUS status;
-	DATA_BLOB response;
-	struct ndr_pull *pull;
-	unsigned int flags;
-	TALLOC_CTX *mem_ctx = req->ndr.mem_ctx;
-	void *r = req->ndr.struct_ptr;
-	uint32_t opnum = req->ndr.opnum;
-	const struct ndr_interface_table *table = req->ndr.table;
-	const struct ndr_interface_call *call = &table->calls[opnum];
-	enum ndr_err_code ndr_err;
-
-	/* make sure the recv code doesn't free the request, as we
-	   need to grab the flags element before it is freed */
-	if (talloc_reference(p, req) == NULL) {
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	status = dcerpc_request_recv(req, mem_ctx, &response);
-	if (!NT_STATUS_IS_OK(status)) {
-		talloc_unlink(p, req);
-		return status;
-	}
-
-	flags = req->flags;
-
-	/* prepare for ndr_pull_* */
-	pull = ndr_pull_init_flags(p->conn, &response, mem_ctx);
-	if (!pull) {
-		talloc_unlink(p, req);
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	if (pull->data) {
-		pull->data = talloc_steal(pull, pull->data);
-	}
-	talloc_unlink(p, req);
-
-	if (flags & DCERPC_PULL_BIGENDIAN) {
-		pull->flags |= LIBNDR_FLAG_BIGENDIAN;
-	}
-
-	DEBUG(10,("rpc reply data:\n"));
-	dump_data(10, pull->data, pull->data_size);
-
-	/* pull the structure from the blob */
-	ndr_err = call->ndr_pull(pull, NDR_OUT, r);
-	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-		status = ndr_map_error2ntstatus(ndr_err);
-		dcerpc_log_packet(p->conn->packet_log_dir,
-						  table, opnum, NDR_OUT, 
-						  &response);
-		return status;
-	}
-
-	if (p->conn->flags & DCERPC_DEBUG_VALIDATE_OUT) {
-		status = dcerpc_ndr_validate_out(p->conn, pull, r, call->struct_size, 
-						 call->ndr_push, call->ndr_pull, 
-						 call->ndr_print);
-		if (!NT_STATUS_IS_OK(status)) {
-			dcerpc_log_packet(p->conn->packet_log_dir, 
-							  table, opnum, NDR_OUT, 
-				  &response);
-			return status;
-		}
-	}
-
-	if (pull->offset != pull->data_size) {
-		DEBUG(0,("Warning! ignoring %d unread bytes in rpc packet!\n", 
-			 pull->data_size - pull->offset));
-		/* we used to return NT_STATUS_INFO_LENGTH_MISMATCH here,
-		   but it turns out that early versions of NT
-		   (specifically NT3.1) add junk onto the end of rpc
-		   packets, so if we want to interoperate at all with
-		   those versions then we need to ignore this error */
-	}
-
-	/* TODO: make pull context independent from the output mem_ctx and free the pull context */
-
-	return NT_STATUS_OK;
-}
-
-
-/*
-  a useful helper function for synchronous rpc requests 
-
-  this can be used when you have ndr push/pull functions in the
-  standard format
-*/
-_PUBLIC_ NTSTATUS dcerpc_ndr_request(struct dcerpc_pipe *p,
-			    const struct GUID *object,
-			    const struct ndr_interface_table *table,
-			    uint32_t opnum, 
-			    TALLOC_CTX *mem_ctx, 
-			    void *r)
-{
-	struct rpc_request *req;
-
-	req = dcerpc_ndr_request_send(p, object, table, opnum, false, mem_ctx, r);
-	if (req == NULL) {
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	return dcerpc_ndr_request_recv(req);
-}
-
-
 /*
   a useful function for retrieving the server name we connected to
 */
diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h
index bff7f6e..fab1236 100644
--- a/source4/librpc/rpc/dcerpc.h
+++ b/source4/librpc/rpc/dcerpc.h
@@ -266,14 +266,6 @@ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
 			     struct cli_credentials *credentials,
 			     struct tevent_context *ev,
 			     struct loadparm_context *lp_ctx);
-NTSTATUS dcerpc_ndr_request_recv(struct rpc_request *req);
-struct rpc_request *dcerpc_ndr_request_send(struct dcerpc_pipe *p,
-						const struct GUID *object,
-						const struct ndr_interface_table *table,
-						uint32_t opnum, 
-						bool async,
-						TALLOC_CTX *mem_ctx, 
-						void *r);
 const char *dcerpc_server_name(struct dcerpc_pipe *p);
 struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev);
 NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe *p,
@@ -376,13 +368,6 @@ NTSTATUS dcerpc_floor_get_lhs_data(const struct epm_floor *epm_floor, struct ndr
 enum dcerpc_transport_t dcerpc_transport_by_tower(const struct epm_tower *tower);
 const char *derpc_transport_string_by_transport(enum dcerpc_transport_t t);
 
-NTSTATUS dcerpc_ndr_request(struct dcerpc_pipe *p,
-			    const struct GUID *object,
-			    const struct ndr_interface_table *table,
-			    uint32_t opnum, 
-			    TALLOC_CTX *mem_ctx, 
-			    void *r);
-
 NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, 
 				   struct epm_tower *tower, 
 				   struct dcerpc_binding **b_out);
diff --git a/source4/rpc_server/remote/dcesrv_remote.c b/source4/rpc_server/remote/dcesrv_remote.c
index bdb3693..4aa1a95 100644
--- a/source4/rpc_server/remote/dcesrv_remote.c
+++ b/source4/rpc_server/remote/dcesrv_remote.c
@@ -21,6 +21,7 @@
 */
 
 #include "includes.h"
+#include <tevent.h>
 #include "rpc_server/dcerpc_server.h"
 #include "auth/auth.h"
 #include "auth/credentials/credentials.h"
@@ -177,7 +178,7 @@ static NTSTATUS remote_op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CT
 	return NT_STATUS_OK;
 }
 
-static void remote_op_dispatch_done(struct rpc_request *rreq);
+static void remote_op_dispatch_done(struct tevent_req *subreq);
 
 static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
 {
@@ -187,7 +188,7 @@ static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CT
 	const struct ndr_interface_table *table = dce_call->context->iface->private_data;
 	const struct ndr_interface_call *call;
 	const char *name;
-	struct rpc_request *rreq;
+	struct tevent_req *subreq;
 
 	name = table->calls[opnum].name;
 	call = &table->calls[opnum];
@@ -199,21 +200,23 @@ static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CT
 	priv->c_pipe->conn->flags |= DCERPC_NDR_REF_ALLOC;
 
 	/* we didn't use the return code of this function as we only check the last_fault_code */
-	rreq = dcerpc_ndr_request_send(priv->c_pipe, NULL, table, opnum, true, mem_ctx, r);
-	if (rreq == NULL) {
-		DEBUG(0,("dcesrv_remote: call[%s] dcerpc_ndr_request_send() failed!\n", name));
+	subreq = dcerpc_binding_handle_call_send(dce_call, dce_call->event_ctx,
+						 priv->c_pipe->binding_handle,
+						 NULL, table,
+						 opnum, mem_ctx, r);
+	if (subreq == NULL) {
+		DEBUG(0,("dcesrv_remote: call[%s] dcerpc_binding_handle_call_send() failed!\n", name));
 		return NT_STATUS_NO_MEMORY;
 	}
-	rreq->async.callback = remote_op_dispatch_done;
-	rreq->async.private_data = dce_call;
+	tevent_req_set_callback(subreq, remote_op_dispatch_done, dce_call);
 
 	dce_call->state_flags |= DCESRV_CALL_STATE_FLAG_ASYNC;
 	return NT_STATUS_OK;
 }
 
-static void remote_op_dispatch_done(struct rpc_request *rreq)
+static void remote_op_dispatch_done(struct tevent_req *subreq)
 {
-	struct dcesrv_call_state *dce_call = talloc_get_type_abort(rreq->async.private_data,
+	struct dcesrv_call_state *dce_call = tevent_req_callback_data(subreq,
 					     struct dcesrv_call_state);
 	struct dcesrv_remote_private *priv = talloc_get_type_abort(dce_call->context->private_data,
 								   struct dcesrv_remote_private);
@@ -227,7 +230,8 @@ static void remote_op_dispatch_done(struct rpc_request *rreq)
 	call = &table->calls[opnum];
 
 	/* we didn't use the return code of this function as we only check the last_fault_code */
-	status = dcerpc_ndr_request_recv(rreq);
+	status = dcerpc_binding_handle_call_recv(subreq);
+	TALLOC_FREE(subreq);
 
 	dce_call->fault_code = priv->c_pipe->last_fault_code;
 	if (dce_call->fault_code != 0) {
diff --git a/source4/torture/rpc/object_uuid.c b/source4/torture/rpc/object_uuid.c
index 8e7d6a7..2209954 100644
--- a/source4/torture/rpc/object_uuid.c
+++ b/source4/torture/rpc/object_uuid.c
@@ -49,7 +49,8 @@ static bool test_random_uuid(struct torture_context *torture)
 	uuid = GUID_random();
 
 	r1.in.level = DS_ROLE_BASIC_INFORMATION;
-	status = dcerpc_ndr_request(p1, &uuid,
+	status = dcerpc_binding_handle_call(p1->binding_handle,
+				    &uuid,
 				    &ndr_table_dssetup,
 				    NDR_DSSETUP_DSROLEGETPRIMARYDOMAININFORMATION,
 				    torture, &r1);
@@ -64,7 +65,8 @@ static bool test_random_uuid(struct torture_context *torture)
 	r2.out.account_name = &account_name_p;
 	r2.out.authority_name = &authority_name_p;
 
-	status = dcerpc_ndr_request(p2, &uuid,
+	status = dcerpc_binding_handle_call(p2->binding_handle,
+				    &uuid,
 				    &ndr_table_lsarpc,
 				    NDR_LSA_GETUSERNAME,
 				    torture, &r2);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list