diff options
author | Ralph Boehme <slow@samba.org> | 2020-11-20 15:21:03 +0100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2020-12-09 07:57:19 +0000 |
commit | fa2ea13ec04c09d1748aad41b27bbcb0c8e056f8 (patch) | |
tree | 68716e72107026e7741b07b94c09ebb80761129e /source4 | |
parent | 504c6e03018038aef0fa4753b9e0f315307f4ad1 (diff) | |
download | samba-fa2ea13ec04c09d1748aad41b27bbcb0c8e056f8.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)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/smbd/server.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source4/smbd/server.c b/source4/smbd/server.c index cf3102e305a..1e255b1500d 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 */ @@ -834,6 +847,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) |