There were two duplicate implementations of packet dumping just for the s4 RPC server!
This unifies them and makes them easier to find because they are not triggered
from the generated server stub any more.
The behaviour have unified on setting "dcesrv:stubs directory" and
being compiled with --enable-developer.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Nov 20 02:14:56 UTC 2019 on sn-devel-184
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
+ this triggers if "dcesrv:stubs directory" is set and present
+ for all packets that fail to parse
*/
-void dcerpc_log_packet(const char *lockdir,
- const struct ndr_interface_table *ndr,
+void dcerpc_log_packet(const char *packet_log_dir,
+ const char *interface_name,
uint32_t opnum, uint32_t flags,
- const DATA_BLOB *pkt)
+ const DATA_BLOB *pkt,
+ const char *why)
{
const int num_examples = 20;
int i;
- if (lockdir == NULL) return;
+ if (packet_log_dir == NULL) {
+ return;
+ }
for (i=0;i<num_examples;i++) {
char *name=NULL;
int ret;
bool saved;
- ret = asprintf(&name, "%s/rpclog/%s-%u.%d.%s",
- lockdir, ndr->name, opnum, i,
- (flags&NDR_IN)?"in":"out");
+ ret = asprintf(&name, "%s/%s-%u.%d.%s.%s",
+ packet_log_dir, interface_name, opnum, i,
+ (flags&NDR_IN)?"in":"out",
+ why);
if (ret == -1) {
return;
}
p->dce_ctx = dce_ctx;
p->endpoint = ep;
- p->packet_log_dir = lpcfg_lock_directory(dce_ctx->lp_ctx);
+ p->packet_log_dir = lpcfg_parm_string(dce_ctx->lp_ctx,
+ NULL,
+ "dcesrv",
+ "stubs directory");
p->event_ctx = event_ctx;
p->state_flags = state_flags;
p->allow_bind = true;
static void dcesrv_save_call(struct dcesrv_call_state *call, const char *why)
{
#ifdef DEVELOPER
- char *fname;
- const char *dump_dir;
- dump_dir = lpcfg_parm_string(call->conn->dce_ctx->lp_ctx, NULL, "dcesrv", "stubs directory");
- if (!dump_dir) {
- return;
- }
- fname = talloc_asprintf(call, "%s/RPC-%s-%u-%s.dat",
- dump_dir,
- call->context->iface->name,
- call->pkt.u.request.opnum,
- why);
- if (file_save(fname, call->pkt.u.request.stub_and_verifier.data, call->pkt.u.request.stub_and_verifier.length)) {
- DEBUG(0,("RPC SAVED %s\n", fname));
- }
- talloc_free(fname);
+ dcerpc_log_packet(call->conn->packet_log_dir,
+ call->context->iface->name,
+ call->pkt.u.request.opnum,
+ NDR_IN,
+ &call->pkt.u.request.stub_and_verifier,
+ why);
#endif
}
struct ncacn_packet *pkt,
struct dcerpc_auth *auth_info);
-void dcerpc_log_packet(const char *lockdir,
- const struct ndr_interface_table *ndr,
+void dcerpc_log_packet(const char *packet_log_dir,
+ const char *interface_name,
uint32_t opnum, uint32_t flags,
- const DATA_BLOB *pkt);
+ const DATA_BLOB *pkt,
+ const char *why);
#endif /* __DEFAULT_LIBRPC_RPCCOMMON_H__ */
/* unravel the NDR for the packet */
status = dcerpc_table_$name.calls[opnum].ndr_pull(pull, NDR_IN, *r);
if (!NT_STATUS_IS_OK(status)) {
- dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
dce_call->fault_code = DCERPC_FAULT_NDR;
return NT_STATUS_NET_WRITE_FAULT;
}
}
if (dce_call->fault_code != 0) {
- dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
return NT_STATUS_NET_WRITE_FAULT;
}
}
if (dce_call->fault_code != 0) {
- dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
return NT_STATUS_NET_WRITE_FAULT;
}
/* unravel the NDR for the packet */
ndr_err = ndr_table_$name.calls[opnum].ndr_pull(pull, NDR_IN, *r);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- dcerpc_log_packet(dce_call->conn->packet_log_dir,
- &ndr_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
dce_call->fault_code = DCERPC_FAULT_NDR;
return NT_STATUS_NET_WRITE_FAULT;
}
}
if (dce_call->fault_code != 0) {
- dcerpc_log_packet(dce_call->conn->packet_log_dir,
- &ndr_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
return NT_STATUS_NET_WRITE_FAULT;
}
}
if (dce_call->fault_code != 0) {
- dcerpc_log_packet(dce_call->conn->packet_log_dir,
- &ndr_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
return NT_STATUS_NET_WRITE_FAULT;
}
struct composite_context* dcerpc_secondary_connection_send(struct dcerpc_pipe *p,
const struct dcerpc_binding *b);
-void dcerpc_log_packet(const char *lockdir,
- const struct ndr_interface_table *ndr,
- uint32_t opnum, uint32_t flags,
- const DATA_BLOB *pkt);
#endif /* __S4_DCERPC_H__ */
/* unravel the NDR for the packet */
ndr_err = table->calls[opnum].ndr_pull(pull, NDR_IN, *r);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- dcerpc_log_packet(dce_call->conn->packet_log_dir,
- table, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
dce_call->fault_code = DCERPC_FAULT_NDR;
return NT_STATUS_NET_WRITE_FAULT;
}
/* unravel the NDR for the packet */
ndr_err = ndr_table_spoolss.calls[opnum].ndr_pull(pull, NDR_IN, *r);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- dcerpc_log_packet(dce_call->conn->packet_log_dir,
- &ndr_table_spoolss, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
dce_call->fault_code = DCERPC_FAULT_NDR;
return NT_STATUS_NET_WRITE_FAULT;
}
}
if (dce_call->fault_code != 0) {
- dcerpc_log_packet(dce_call->conn->packet_log_dir,
- &ndr_table_spoolss, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
return NT_STATUS_NET_WRITE_FAULT;
}
return NT_STATUS_OK;