summaryrefslogtreecommitdiff
path: root/source4/rpc_server
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-06-07 03:13:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:56:35 -0500
commitf5108651ee95f16128be1b0cfb36c38fac8b5348 (patch)
treefb7a159dedb1fd96de6985ac863f44ceeed8977e /source4/rpc_server
parent0cb60c618adcb655e7e0c2ffc476d4ef83dc4007 (diff)
downloadsamba-f5108651ee95f16128be1b0cfb36c38fac8b5348.tar.gz
samba-f5108651ee95f16128be1b0cfb36c38fac8b5348.tar.bz2
samba-f5108651ee95f16128be1b0cfb36c38fac8b5348.zip
r1057: added rpc packet logging for packets that generate rpc faults. This
makes it much easier to develop the IDL for new requests, especially for sealed pipes, where ethereal cannot easily extract the data. (This used to be commit 0cde043592d2d2439cf0cd8bf113545e78be5dfd)
Diffstat (limited to 'source4/rpc_server')
-rw-r--r--source4/rpc_server/dcerpc_server.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
index 2c0db15081..a084477b36 100644
--- a/source4/rpc_server/dcerpc_server.c
+++ b/source4/rpc_server/dcerpc_server.c
@@ -553,6 +553,40 @@ static NTSTATUS dcesrv_auth3(struct dcesrv_call_state *call)
/*
+ log a rpc packet in a format suitable for ndrdump. This is especially useful
+ for sealed packets, where ethereal cannot easily see the contents
+
+ this triggers on a debug level of >= 10
+*/
+static void log_rpc_packet(const struct dcesrv_interface *iface,
+ uint32_t opnum, uint32_t flags, DATA_BLOB *pkt)
+{
+ const int num_examples = 20;
+ int i;
+
+ if (DEBUGLEVEL < 10) return;
+
+ for (i=0;i<num_examples;i++) {
+ char *name=NULL;
+ asprintf(&name, "%s/rpclog/%s-%u.%d.%s",
+ lp_lockdir(), iface->ndr->name, opnum, i,
+ (flags&NDR_IN)?"in":"out");
+ if (name == NULL) {
+ return;
+ }
+ if (!file_exist(name, NULL)) {
+ if (file_save(name, pkt->data, pkt->length)) {
+ DEBUG(10,("Logged rpc packet to %s\n", name));
+ }
+ free(name);
+ break;
+ }
+ free(name);
+ }
+}
+
+
+/*
handle a dcerpc request packet
*/
static NTSTATUS dcesrv_request(struct dcesrv_call_state *call)
@@ -593,6 +627,8 @@ static NTSTATUS dcesrv_request(struct dcesrv_call_state *call)
/* unravel the NDR for the packet */
status = call->conn->iface->ndr->calls[opnum].ndr_pull(pull, NDR_IN, r);
if (!NT_STATUS_IS_OK(status)) {
+ log_rpc_packet(call->conn->iface, opnum, NDR_IN,
+ &call->pkt.u.request.stub_and_verifier);
return dcesrv_fault(call, DCERPC_FAULT_NDR);
}
@@ -601,6 +637,8 @@ static NTSTATUS dcesrv_request(struct dcesrv_call_state *call)
/* call the dispatch function */
status = call->conn->iface->dispatch(call, call->mem_ctx, r);
if (!NT_STATUS_IS_OK(status)) {
+ log_rpc_packet(call->conn->iface, opnum, NDR_IN,
+ &call->pkt.u.request.stub_and_verifier);
return dcesrv_fault(call, call->fault_code);
}