smbd: reopen logs on SIGHUP for notifyd and cleanupd
authorVolker Lendecke <vl@samba.org>
Tue, 7 Jul 2020 09:32:46 +0000 (11:32 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 11 Nov 2021 15:34:28 +0000 (15:34 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Nov 11 15:34:28 UTC 2021 on sn-devel-184

source3/smbd/server.c

index d02ff1bd883464a601c6dfe361c60fb12e63aa5b..05592d0ef41d24faf039f826677fb8da5f0fbe5a 100644 (file)
@@ -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");