]> 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)
committerKarolin Seeger <kseeger@samba.org>
Wed, 9 Dec 2020 10:44:15 +0000 (10:44 +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>
(backported from commit 516c2a04a242a539f9fbddb2822295fee233644c)
[slow@samba.org: process_prefork.c has additional include in master]

source4/smbd/process_prefork.c
source4/smbd/server.c
source4/smbd/wscript_build

index 5667fb5f1efc37d97c37d53ac0aacee57dad3aae..950db6a1c7da7dcbfa0ed33788c38a65deab7543 100644 (file)
@@ -44,6 +44,7 @@
 #include "ldb_wrap.h"
 #include "lib/util/tfork.h"
 #include "lib/messaging/irpc.h"
+#include "server_util.h"
 
 #define min(a, b) (((a) < (b)) ? (a) : (b))
 
@@ -243,6 +244,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();
@@ -321,6 +323,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 95acb99b86c96faf3b47ccf53c0dbf1a476a4ba3..c92988352f26237179cf02e4bc701774210749e8 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");
 
@@ -727,6 +729,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
                  )