]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:notifyd: Handle sigup in notifyd to reparse smb.conf
authorShyamsunder Rathi <shyam.rathi@nutanix.com>
Sat, 18 May 2019 01:34:04 +0000 (18:34 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 27 Jun 2019 17:57:12 +0000 (17:57 +0000)
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 <hemanth.thummala@nutanix.com>
Signed-off-by: Shyamsunder Rathi <shyam.rathi@nutanix.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by:Volker Lendecke <vl@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jun 27 17:57:12 UTC 2019 on sn-devel-184

source3/smbd/server.c

index 8a5d8e5dc052ebd79927cb1bc4e722242019939c..0da29f7bab6b52d1009b734c2d621b2d5759d9c7 100644 (file)
@@ -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,