From 57c1e115ecef41ef18599e5233079ccd83d13bfc Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 7 Jul 2020 11:32:46 +0200 Subject: [PATCH] smbd: reopen logs on SIGHUP for notifyd and cleanupd Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Thu Nov 11 15:34:28 UTC 2021 on sn-devel-184 --- source3/smbd/server.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index d02ff1bd883..05592d0ef41 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -403,6 +403,7 @@ static void notifyd_sig_hup_handler(struct tevent_context *ev, { DBG_NOTICE("notifyd: Reloading services after SIGHUP\n"); reload_services(NULL, NULL, false); + reopen_logs(); } static bool smbd_notifyd_init(struct messaging_context *msg, bool interactive, @@ -410,10 +411,10 @@ static bool smbd_notifyd_init(struct messaging_context *msg, bool interactive, { struct tevent_context *ev = messaging_tevent_context(msg); struct tevent_req *req; + struct tevent_signal *se = NULL; pid_t pid; NTSTATUS status; bool ok; - struct tevent_signal *se; if (interactive) { req = notifyd_req(msg, ev); @@ -570,6 +571,17 @@ static void notifyd_started(struct tevent_req *req) } } +static void cleanupd_sig_hup_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *pvt) +{ + DBG_NOTICE("cleanupd: Reloading services after SIGHUP\n"); + reopen_logs(); +} + static void cleanupd_stopped(struct tevent_req *req); static bool cleanupd_init(struct messaging_context *msg, bool interactive, @@ -577,6 +589,7 @@ static bool cleanupd_init(struct messaging_context *msg, bool interactive, { struct tevent_context *ev = messaging_tevent_context(msg); struct server_id parent_id = messaging_server_id(msg); + struct tevent_signal *se = NULL; struct tevent_req *req; pid_t pid; NTSTATUS status; @@ -647,6 +660,17 @@ static bool cleanupd_init(struct messaging_context *msg, bool interactive, exit(1); } + se = tevent_add_signal(ev, + ev, + SIGHUP, + 0, + cleanupd_sig_hup_handler, + NULL); + if (se == NULL) { + DBG_ERR("Could not add SIGHUP handler\n"); + exit(1); + } + req = smbd_cleanupd_send(msg, ev, msg, parent_id.pid); if (req == NULL) { DBG_WARNING("smbd_cleanupd_send failed\n"); -- 2.47.2