From: Stefan Metzmacher Date: Tue, 3 Feb 2004 14:56:07 +0000 (+0000) Subject: - add 'print' to the DCERPC binding strings X-Git-Tag: samba-4.0.0alpha6~801^3~14783 X-Git-Url: http://git.samba.org/samba.git/?p=bbaumbach%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=0b4da9d7e069a5e32d9706ee12cde7fe7625270d - add 'print' to the DCERPC binding strings e.g. ncacn_np:myserver:[samr,sign,print] will now enable the packet debugging and the debugging is not bound anymore to the debuglevel >= 2 in the torture tests - also the dcesrv_remote module now supports debugging of the packets use the 'dcerpc_remote:binding' smb.conf parameter. metze (This used to be commit 40abf3c584efed7f977ddd688ea064540e5a5b13) --- diff --git a/prog_guide.txt b/prog_guide.txt index b604b8ee5ff..9bf94195360 100644 --- a/prog_guide.txt +++ b/prog_guide.txt @@ -573,6 +573,7 @@ other recognised flags are: sign : enable ntlmssp signing seal : enable ntlmssp sealing validate: enable the NDR validator + print: enable debugging of the packets bigendian: use bigendian RPC @@ -586,9 +587,9 @@ For example, these all connect to the samr pipe: ncacn_np:myserver[samr] ncacn_np:myserver[\pipe\samr] ncacn_np:myserver[/pipe/samr] - ncacn_np:myserver:[samr,sign] + ncacn_np:myserver:[samr,sign,print] ncacn_np:myserver:[\pipe\samr,sign,seal,bigendian] - ncacn_np:myserver:[/pipe/samr,seal] + ncacn_np:myserver:[/pipe/samr,seal,validate] ncacn_ip_tcp:myserver ncacn_ip_tcp:myserver:1024 diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 2af63c76769..b44bf11c153 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -347,10 +347,6 @@ void ndr_print_function_debug(void (*fn)(struct ndr_print *, const char *, int , { struct ndr_print ndr; - if (!DEBUGLVL(2)) { - return; - } - ndr.mem_ctx = talloc_init("ndr_print_function"); if (!ndr.mem_ctx) return; ndr.print = ndr_print_debug_helper; diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index 1ef776125f3..96f0b959e74 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -276,6 +276,7 @@ static const struct { {"sign", DCERPC_SIGN}, {"seal", DCERPC_SEAL}, {"validate", DCERPC_DEBUG_VALIDATE_BOTH}, + {"print", DCERPC_DEBUG_PRINT_BOTH}, {"bigendian", DCERPC_PUSH_BIGENDIAN} }; diff --git a/source4/rpc_server/remote/dcesrv_remote.c b/source4/rpc_server/remote/dcesrv_remote.c index 2ca7fe326f5..710c2f514a0 100644 --- a/source4/rpc_server/remote/dcesrv_remote.c +++ b/source4/rpc_server/remote/dcesrv_remote.c @@ -31,7 +31,6 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct NTSTATUS status; struct dcesrv_remote_private *private; const char *binding = lp_parm_string(-1, "dcerpc_remote", "binding"); - const char *print_debug = lp_parm_string(-1, "dcerpc_remote", "print_debug"); if (!binding) { printf("You must specify a ncacn binding string\n"); @@ -48,10 +47,6 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct lp_parm_string(-1, "dcerpc_remote", "username"), lp_parm_string(-1, "dcerpc_remote", "password")); - if (print_debug && strcasecmp("yes",print_debug) == 0) { - private->c_pipe->flags |= DCERPC_DEBUG_PRINT_BOTH; - } - dce_call->conn->private = private; return NT_STATUS_OK; @@ -71,15 +66,30 @@ static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CT struct dcesrv_remote_private *private = dce_call->conn->private; NTSTATUS status; uint16 opnum = dce_call->pkt.u.request.opnum; + const char *name = dce_call->conn->iface->ndr->calls[opnum].name; ndr_push_flags_fn_t ndr_push_fn = dce_call->conn->iface->ndr->calls[opnum].ndr_push; ndr_pull_flags_fn_t ndr_pull_fn = dce_call->conn->iface->ndr->calls[opnum].ndr_pull; + ndr_print_function_t ndr_print_fn = dce_call->conn->iface->ndr->calls[opnum].ndr_print; size_t struct_size = dce_call->conn->iface->ndr->calls[opnum].struct_size; + if (private->c_pipe->flags & DCERPC_DEBUG_PRINT_IN) { + ndr_print_function_debug(ndr_print_fn, name, NDR_IN | NDR_SET_VALUES, r); + } + status = dcerpc_ndr_request(private->c_pipe, opnum, mem_ctx, (ndr_push_flags_fn_t) ndr_push_fn, (ndr_pull_flags_fn_t) ndr_pull_fn, r, struct_size); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("dcesrv_remote: call[%s] failed with: %s!\n",name, nt_errstr(status))); + return status; + } + + if (NT_STATUS_IS_OK(status) && (private->c_pipe->flags & DCERPC_DEBUG_PRINT_OUT)) { + ndr_print_function_debug(ndr_print_fn, name, NDR_OUT, r); + } + return status; } diff --git a/source4/torture/rpc/atsvc.c b/source4/torture/rpc/atsvc.c index 7d0ac42fa41..bd605d7c4f9 100644 --- a/source4/torture/rpc/atsvc.c +++ b/source4/torture/rpc/atsvc.c @@ -148,8 +148,6 @@ BOOL torture_rpc_atsvc(int dummy) if (!NT_STATUS_IS_OK(status)) { return False; } - - p->flags |= DCERPC_DEBUG_PRINT_BOTH; if (!test_JobEnum(p, mem_ctx)) { return False; diff --git a/source4/torture/rpc/dfs.c b/source4/torture/rpc/dfs.c index 7b20e044bb3..940a42a9474 100644 --- a/source4/torture/rpc/dfs.c +++ b/source4/torture/rpc/dfs.c @@ -180,8 +180,6 @@ BOOL torture_rpc_dfs(int dummy) return False; } - p->flags |= DCERPC_DEBUG_PRINT_BOTH; - if (!test_Exist(p, mem_ctx)) { ret = False; } diff --git a/source4/torture/rpc/echo.c b/source4/torture/rpc/echo.c index be70939de1c..cdae51393dc 100644 --- a/source4/torture/rpc/echo.c +++ b/source4/torture/rpc/echo.c @@ -242,8 +242,6 @@ BOOL torture_rpc_echo(int dummy) } #endif - p->flags |= DCERPC_DEBUG_PRINT_BOTH; - if (!test_testcall(p, mem_ctx)) { ret = False; } diff --git a/source4/torture/rpc/epmapper.c b/source4/torture/rpc/epmapper.c index 2b704659d6e..24395e064cb 100644 --- a/source4/torture/rpc/epmapper.c +++ b/source4/torture/rpc/epmapper.c @@ -242,8 +242,6 @@ BOOL torture_rpc_epmapper(int dummy) if (!NT_STATUS_IS_OK(status)) { return False; } - - p->flags |= DCERPC_DEBUG_PRINT_BOTH; if (!test_Lookup(p, mem_ctx)) { ret = False; diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c index 8ad14699196..1a3eb986ec7 100644 --- a/source4/torture/rpc/eventlog.c +++ b/source4/torture/rpc/eventlog.c @@ -95,8 +95,6 @@ BOOL torture_rpc_eventlog(int dummy) if (!NT_STATUS_IS_OK(status)) { return False; } - - p->flags |= DCERPC_DEBUG_PRINT_BOTH; if (!test_OpenEventLog(p, mem_ctx)) { return False; diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c index 84b29281e5e..feb7a321405 100644 --- a/source4/torture/rpc/lsa.c +++ b/source4/torture/rpc/lsa.c @@ -533,8 +533,6 @@ BOOL torture_rpc_lsa(int dummy) if (!NT_STATUS_IS_OK(status)) { return False; } - - p->flags |= DCERPC_DEBUG_PRINT_BOTH; if (!test_OpenPolicy(p, mem_ctx)) { ret = False; diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c index 682e28320df..12a8c8a023f 100644 --- a/source4/torture/rpc/netlogon.c +++ b/source4/torture/rpc/netlogon.c @@ -793,8 +793,6 @@ BOOL torture_rpc_netlogon(int dummy) if (!NT_STATUS_IS_OK(status)) { return False; } - - p->flags |= DCERPC_DEBUG_PRINT_BOTH; if (!test_LogonUasLogon(p, mem_ctx)) { ret = False; diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c index 2f72cfe7be5..fccae8412c4 100644 --- a/source4/torture/rpc/samr.c +++ b/source4/torture/rpc/samr.c @@ -1394,8 +1394,6 @@ BOOL torture_rpc_samr(int dummy) if (!NT_STATUS_IS_OK(status)) { return False; } - - p->flags |= DCERPC_DEBUG_PRINT_BOTH; if (!test_Connect(p, mem_ctx, &handle)) { ret = False; diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 08c486f45a5..e416c18f90a 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -972,8 +972,6 @@ BOOL torture_rpc_spoolss(int dummy) return False; } - p->flags |= DCERPC_DEBUG_PRINT_BOTH; - if (!test_EnumPrinters(p, mem_ctx)) { ret = False; } diff --git a/source4/torture/rpc/srvsvc.c b/source4/torture/rpc/srvsvc.c index 42a53f8567f..d7f9a7004b5 100644 --- a/source4/torture/rpc/srvsvc.c +++ b/source4/torture/rpc/srvsvc.c @@ -258,8 +258,6 @@ BOOL torture_rpc_srvsvc(int dummy) return False; } - p->flags |= DCERPC_DEBUG_PRINT_BOTH; - if (!test_NetConnEnum(p, mem_ctx)) { ret = False; } diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index 2660fce4265..e0742965311 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -441,8 +441,6 @@ BOOL torture_rpc_winreg(int dummy) if (!NT_STATUS_IS_OK(status)) { return False; } - - p->flags |= DCERPC_DEBUG_PRINT_BOTH; for (i = 0; i < ARRAY_SIZE(open_fns); i++) { if (!test_Open(p, mem_ctx, open_fns[i])) diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c index 92d1063f3b9..8362c02e3e0 100644 --- a/source4/torture/rpc/wkssvc.c +++ b/source4/torture/rpc/wkssvc.c @@ -100,8 +100,6 @@ BOOL torture_rpc_wkssvc(int dummy) return False; } - p->flags |= DCERPC_DEBUG_PRINT_BOTH; - if (!test_NetWkstaGetInfo(p, mem_ctx)) { ret = False; }