summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2020-11-20 15:21:03 +0100
committerKarolin Seeger <kseeger@samba.org>2020-12-09 10:44:15 +0000
commit1a6f2871036f5271aefa63f745e691a38684b40e (patch)
tree0bcb3e28e6147a859f71d6bd81644830dab75b30
parent7299ebb1215776b19f5094e861a21c7df06220f2 (diff)
downloadsamba-1a6f2871036f5271aefa63f745e691a38684b40e.tar.gz
s4: replace low-level SIGUP handler with a tevent handler
Replace the low-level signal handler for SIGHUP with a nice tevent signal handler. The low-level handler sig_hup() installed by setup_signals() remains being used during early startup before a tevent context is available. 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> (cherry picked from commit 9f71e6173ab43a04804ba8061cb0e8ae6c0165bf)
-rw-r--r--source4/smbd/server.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index c92988352f2..9068bfcaeb8 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -155,6 +155,19 @@ static void sigterm_signal_handler(struct tevent_context *ev,
sig_term(SIGTERM);
}
+static void sighup_signal_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum, int count, void *siginfo,
+ void *private_data)
+{
+ struct server_state *state = talloc_get_type_abort(
+ private_data, struct server_state);
+
+ DBG_DEBUG("Process %s got SIGHUP\n", state->binary_name);
+
+ reopen_logs_internal();
+}
+
/*
setup signal masks
*/
@@ -832,6 +845,22 @@ static int binary_smbd_main(const char *binary_name,
return 1;
}
+ se = tevent_add_signal(state->event_ctx,
+ state->event_ctx,
+ SIGHUP,
+ 0,
+ sighup_signal_handler,
+ state);
+ if (se == NULL) {
+ TALLOC_FREE(state);
+ exit_daemon("Initialize SIGHUP handler failed", ENOMEM);
+ /*
+ * return is never reached but is here to satisfy static
+ * checkers
+ */
+ return 1;
+ }
+
if (lpcfg_server_role(cmdline_lp_ctx) != ROLE_ACTIVE_DIRECTORY_DC
&& !lpcfg_parm_bool(cmdline_lp_ctx, NULL,
"server role check", "inhibit", false)