]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4: install tevent tracing hooks to trigger logfile rotation
authorRalph Boehme <slow@samba.org>
Thu, 26 Nov 2020 13:21:58 +0000 (14:21 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 7 Dec 2020 17:54:10 +0000 (17:54 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14248

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/samba/process_prefork.c
source4/samba/server.c
source4/samba/wscript_build

index f3387d87e615eba4dbd1a8fc61a896c3074016c5..a0b47d3268d4322f7f6700d17c879d47309cc95f 100644 (file)
@@ -45,6 +45,7 @@
 #include "lib/util/tfork.h"
 #include "lib/messaging/irpc.h"
 #include "lib/util/util_process.h"
+#include "server_util.h"
 
 #define min(a, b) (((a) < (b)) ? (a) : (b))
 
@@ -244,6 +245,7 @@ static void prefork_fork_master(
        struct tevent_context *ev2;
        struct task_server *task = NULL;
        struct process_details pd = initial_process_details;
+       struct samba_tevent_trace_state *samba_tevent_trace_state = NULL;
        int control_pipe[2];
 
        t = tfork_create();
@@ -327,6 +329,17 @@ static void prefork_fork_master(
         */
        ev2 = s4_event_context_init(NULL);
 
+       samba_tevent_trace_state = create_samba_tevent_trace_state(ev2);
+       if (samba_tevent_trace_state == NULL) {
+               TALLOC_FREE(ev);
+               TALLOC_FREE(ev2);
+               exit(127);
+       }
+
+       tevent_set_trace_callback(ev2,
+                                 samba_tevent_trace_callback,
+                                 samba_tevent_trace_state);
+
        /* setup this new connection: process will bind to it's sockets etc
         *
         * While we can use ev for the child, which has been re-initialised
index d3cbd654d76312461ea5d15f31179a09150d5667..a304f5e8efb2b5ec02422f52fdb24469b62d30ae 100644 (file)
@@ -46,6 +46,7 @@
 #include "lib/util/tfork.h"
 #include "dsdb/samdb/ldb_modules/util.h"
 #include "lib/util/server_id.h"
+#include "server_util.h"
 
 #ifdef HAVE_PTHREAD
 #include <pthread.h>
@@ -572,6 +573,7 @@ static int binary_smbd_main(const char *binary_name,
        };
        struct server_state *state = NULL;
        struct tevent_signal *se = NULL;
+       struct samba_tevent_trace_state *samba_tevent_trace_state = NULL;
 
        setproctitle("root process");
 
@@ -729,6 +731,21 @@ static int binary_smbd_main(const char *binary_name,
 
        talloc_set_destructor(state->event_ctx, event_ctx_destructor);
 
+       samba_tevent_trace_state = create_samba_tevent_trace_state(state);
+       if (samba_tevent_trace_state == NULL) {
+               exit_daemon("Samba failed to setup tevent tracing state",
+                           ENOTTY);
+               /*
+                * return is never reached but is here to satisfy static
+                * checkers
+                */
+               return 1;
+       }
+
+       tevent_set_trace_callback(state->event_ctx,
+                                 samba_tevent_trace_callback,
+                                 samba_tevent_trace_state);
+
        if (opt_interactive) {
                /* terminate when stdin goes away */
                stdin_event_flags = TEVENT_FD_READ;
index 146098ec8e4ed0a9492d0ac268f33c2e5719ca52..14267c1c9a51972b425f73bc58acb4c173774ec1 100644 (file)
@@ -25,7 +25,8 @@ bld.SAMBA_BINARY('samba',
        source='server.c',
        subsystem_name='service',
        deps='''events process_model service samba-hostconfig samba-util POPT_SAMBA
-                popt gensec registry ntvfs share cluster COMMON_SCHANNEL SECRETS''',
+                popt gensec registry ntvfs share cluster COMMON_SCHANNEL SECRETS
+                samba_server_util''',
        pyembed=True,
        install_path='${SBINDIR}',
        enabled=bld.AD_DC_BUILD_IS_ENABLED()
@@ -52,6 +53,6 @@ bld.SAMBA_MODULE('process_model_prefork',
                  source='process_prefork.c',
                  subsystem='process_model',
                  init_function='process_model_prefork_init',
-                 deps='MESSAGING events ldbsamba cluster samba-sockets process_model messages_dgm',
+                 deps='MESSAGING events ldbsamba cluster samba-sockets process_model messages_dgm samba_server_util',
                  internal_module=False
                  )