From: Pavel Filipenský Date: Sun, 5 Sep 2021 18:37:55 +0000 (+0200) Subject: winbind: send "debug traceid" from winbindd parent to child X-Git-Tag: talloc-2.3.4~203 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4580fd10468e22ea39cc38921fb0d8ad6be46339;p=thirdparty%2Fsamba.git winbind: send "debug traceid" from winbindd parent to child Bumping WINBIND_INTERFACE_VERSION to 32 Pair-Programmed-With: Andreas Schneider Signed-off-by: Pavel Filipenský Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Tue May 10 18:25:01 UTC 2022 on sn-devel-184 --- diff --git a/nsswitch/winbind_struct_protocol.h b/nsswitch/winbind_struct_protocol.h index 87d10ae6e3e..ac0558c87c5 100644 --- a/nsswitch/winbind_struct_protocol.h +++ b/nsswitch/winbind_struct_protocol.h @@ -61,8 +61,9 @@ typedef char fstring[FSTRING_LEN]; * 29: added "authoritative" to response.data.auth * 30: added "validation_level" and "info6" to response.data.auth * 31: added "client_name" to the request + * 32: added "traceid" to the request */ -#define WINBIND_INTERFACE_VERSION 31 +#define WINBIND_INTERFACE_VERSION 32 /* Have to deal with time_t being 4 or 8 bytes due to structure alignment. On a 64bit Linux box, we have to support a constant structure size @@ -253,6 +254,7 @@ struct winbindd_request { uint32_t flags; /* flags relevant *only* to a given request */ fstring domain_name; /* name of domain for which the request applies */ char client_name[32]; /* The client process sending the request */ + uint64_t traceid; /* debug traceid is sent from parent to child */ union { fstring winsreq; /* WINS request */ diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index d517b83a3e2..b880feaac13 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -33,6 +33,7 @@ #include "nsswitch/wb_reqtrans.h" #include "secrets.h" #include "../lib/util/select.h" +#include "winbindd_traceid.h" #include "../libcli/security/security.h" #include "system/select.h" #include "messages.h" @@ -222,6 +223,8 @@ struct tevent_req *wb_child_request_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } + state->request->traceid = debug_traceid_get(); + if (request->extra_data.data != NULL) { state->request->extra_data.data = talloc_memdup( state->request, @@ -1625,6 +1628,7 @@ static void child_handler(struct tevent_context *ev, struct tevent_fd *fde, struct child_handler_state *state = (struct child_handler_state *)private_data; NTSTATUS status; + uint64_t parent_traceid; /* fetch a request from the main daemon */ status = child_read_request(state->cli.sock, state->cli.request); @@ -1634,6 +1638,10 @@ static void child_handler(struct tevent_context *ev, struct tevent_fd *fde, _exit(0); } + /* read traceid from request */ + parent_traceid = state->cli.request->traceid; + debug_traceid_set(parent_traceid); + DEBUG(4,("child daemon request %d\n", (int)state->cli.request->cmd)); @@ -1747,6 +1755,11 @@ static bool fork_domain_child(struct winbindd_child *child) status = winbindd_reinit_after_fork(child, child->logfilename); + /* setup callbacks again, one of them is removed in reinit_after_fork */ + if (lp_winbind_debug_traceid()) { + winbind_debug_traceid_setup(global_event_context()); + } + nwritten = sys_write(state.cli.sock, &status, sizeof(status)); if (nwritten != sizeof(status)) { DEBUG(1, ("fork_domain_child: Could not write status: "