- add 'print' to the DCERPC binding strings
authorStefan Metzmacher <metze@samba.org>
Tue, 3 Feb 2004 14:56:07 +0000 (14:56 +0000)
committerStefan Metzmacher <metze@samba.org>
Tue, 3 Feb 2004 14:56:07 +0000 (14:56 +0000)
  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

16 files changed:
prog_guide.txt
source/librpc/ndr/ndr.c
source/librpc/rpc/dcerpc_util.c
source/rpc_server/remote/dcesrv_remote.c
source/torture/rpc/atsvc.c
source/torture/rpc/dfs.c
source/torture/rpc/echo.c
source/torture/rpc/epmapper.c
source/torture/rpc/eventlog.c
source/torture/rpc/lsa.c
source/torture/rpc/netlogon.c
source/torture/rpc/samr.c
source/torture/rpc/spoolss.c
source/torture/rpc/srvsvc.c
source/torture/rpc/winreg.c
source/torture/rpc/wkssvc.c

index b604b8ee5ff8d7157876370ec21f577fb811bad3..9bf9419536057e89c5e300e220320c66814cc3fa 100644 (file)
@@ -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
index 2af63c76769a7b3d2465c4dbb669d37ae58f426f..b44bf11c153b36f600195e5aa36342222eeb55e3 100644 (file)
@@ -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;
index 1ef776125f3cded0f331c3a0b9ec890fbce54f9f..96f0b959e74fb253874652ef51cc3773a3affb97 100644 (file)
@@ -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}
 };
 
index 2ca7fe326f5e19f176e67fb2e862f2247a5804e7..710c2f514a087afe7a8a25b08ee674c251ee731c 100644 (file)
@@ -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;
 }
 
index 7d0ac42fa41aef69970a3b5537ca97cd27c15084..bd605d7c4f9e52ca447de43ab6859f9c3392041b 100644 (file)
@@ -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;
index 7b20e044bb3b3e5cc7b6aa89b13f454ccacecc7e..940a42a9474a9a72744f1a30f6e9d7048da986fb 100644 (file)
@@ -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;
        }
index be70939de1c2fbd3e1838b7ac31f9d752b1dba3f..cdae51393dcd66e4aa5b5f9c0af69d0ee8ee6fb7 100644 (file)
@@ -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;
        }
index 2b704659d6e245564b8a0a85a4114feca2fdb11f..24395e064cb405b456cdf0f0959a3abb27be667f 100644 (file)
@@ -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;
index 8ad14699196b8c3b0de47257c8038ef09d3ac519..1a3eb986ec717ab3342c82113c3f208d7c07b31a 100644 (file)
@@ -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;
index 84b29281e5ee468e9d5534fb6304d148cc082f51..feb7a3214052345b7ef922736145efb88cfe5b2b 100644 (file)
@@ -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;
index 682e28320df4cfa787bb711f99e375982e59d38b..12a8c8a023fc907645e0eda101adc000957f550e 100644 (file)
@@ -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;
index 2f72cfe7be56029dcd8000f64edf0d1d62c42db2..fccae8412c4d74242ccf0c94f771509051cc6444 100644 (file)
@@ -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;
index 08c486f45a55c88f33224f32ab6e1fcd2ffabc9b..e416c18f90aa3c7e40997fe0a8325701c08a4493 100644 (file)
@@ -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;
        }
index 42a53f8567f48ee7f61b0cfb0b69df039d2caca9..d7f9a7004b5b5fbb6d4248a248ebab69758a9ab8 100644 (file)
@@ -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;
        }
index 2660fce4265ec3834daa11d7b11f8f243a409afc..e07429653114bbd791c22574df3c2390c7588f8c 100644 (file)
@@ -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]))
index 92d1063f3b95595faaec57a2b98c57346ee1d02c..8362c02e3e0674656e0ad8cf8b42e67aef51656b 100644 (file)
@@ -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;
        }