From 6e5bff80a0a0b5e999a9327640f3aa01b9f18777 Mon Sep 17 00:00:00 2001 From: Shyamsunder Rathi Date: Fri, 17 May 2019 18:34:04 -0700 Subject: [PATCH] s3:notifyd: Handle sigup in notifyd to reparse smb.conf At present, SIGHUP is blocked on notifyd. So, if parent smbd is started with "log level" 10 in smb.conf, and later changed to 0, the SIGHUP will not change the log level to 0 in notify smbd process and it will keep printing verbose logs in the corresponding log files. Proposed fix is to write a SIGHUP handler for notifyd and set it to reload services. Reviewed-by: Hemanth Thummala Signed-off-by: Shyamsunder Rathi Reviewed-by: Jeremy Allison Reviewed-by:Volker Lendecke Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Thu Jun 27 17:57:12 UTC 2019 on sn-devel-184 --- source3/smbd/server.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 8a5d8e5dc05..0da29f7bab6 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -385,6 +385,17 @@ static void notifyd_stopped(struct tevent_req *req) DEBUG(1, ("notifyd stopped: %s\n", strerror(ret))); } +static void notifyd_sig_hup_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *pvt) +{ + DBG_NOTICE("notifyd: Reloading services after SIGHUP\n"); + reload_services(NULL, NULL, false); +} + static bool smbd_notifyd_init(struct messaging_context *msg, bool interactive, struct server_id *ppid) { @@ -393,6 +404,7 @@ static bool smbd_notifyd_init(struct messaging_context *msg, bool interactive, pid_t pid; NTSTATUS status; bool ok; + struct tevent_signal *se; if (interactive) { req = notifyd_req(msg, ev); @@ -421,6 +433,17 @@ static bool smbd_notifyd_init(struct messaging_context *msg, bool interactive, exit(1); } + /* Set up sighup handler for notifyd */ + se = tevent_add_signal(ev, + ev, + SIGHUP, 0, + notifyd_sig_hup_handler, + NULL); + if (!se) { + DEBUG(0, ("failed to setup notifyd SIGHUP handler\n")); + exit(1); + } + req = notifyd_req(msg, ev); if (req == NULL) { exit(1); @@ -428,7 +451,6 @@ static bool smbd_notifyd_init(struct messaging_context *msg, bool interactive, tevent_req_set_callback(req, notifyd_stopped, msg); /* Block those signals that we are not handling */ - BlockSignals(True, SIGHUP); BlockSignals(True, SIGUSR1); messaging_send(msg, pid_to_procid(getppid()), MSG_SMB_NOTIFY_STARTED, -- 2.47.2