]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
daemons: report status to systemd even when running in foreground
authorAlexander Bokovoy <ab@samba.org>
Sat, 24 Oct 2020 13:52:43 +0000 (16:52 +0300)
committerJeremy Allison <jra@samba.org>
Mon, 26 Oct 2020 19:58:17 +0000 (19:58 +0000)
When systemd launches samba services, the configuration we have in
systemd service files expects that the main process (/usr/sbin/*)
would use sd_notify() to report back its status. However, we only use
sd_notify() when running become_daemon().

As a result, samba/smbd/winbindd/nmbd processes never report back its
status and the status updates from other childs (smbd, winbindd, etc)
are not accepted as we now have implied NotifyAccess=main since commit
d1740fb3d5a72cb49e30b330bb0b01e7ef3e09cc

This leads to a timeout and killing samba process by systemd. Situation
is reproducible in Fedora 33, for example.

Make sure that we have required status updates for all daemons in case
we aren't runnning in interactive mode.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14552

Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Oct 26 19:58:18 UTC 2020 on sn-devel-184

source3/nmbd/nmbd.c
source3/smbd/server.c
source3/winbindd/winbindd.c
source4/smbd/server.c

index 0b881d13f7b2180d872a92ff87c734954a80484f..f6aeba1f7142a97be0dab30c87338debb0e45b9c 100644 (file)
@@ -1009,6 +1009,8 @@ static bool open_sockets(bool isdaemon, int port)
        if (is_daemon && !opt_interactive) {
                DEBUG(3, ("Becoming a daemon.\n"));
                become_daemon(Fork, no_process_group, log_stdout);
+       } else if (!opt_interactive) {
+               daemon_status("nmbd", "Starting process...");
        }
 
 #ifdef HAVE_SETPGID
@@ -1135,7 +1137,7 @@ static bool open_sockets(bool isdaemon, int port)
                exit_daemon( "NMBD failed to setup packet server.", EACCES);
        }
 
-       if (is_daemon && !opt_interactive) {
+       if (!opt_interactive) {
                daemon_ready("nmbd");
        }
 
index 153dd3c9323bbdc4766da78f138b1dec9d31c531..3d9db5d84078d7624cd1c07d4f0d14e91a810850 100644 (file)
@@ -1893,6 +1893,8 @@ extern void build_options(bool screen);
        if (is_daemon && !interactive) {
                DEBUG(3, ("Becoming a daemon.\n"));
                become_daemon(Fork, no_process_group, log_stdout);
+       } else {
+               daemon_status("smbd", "Starting process ...");
        }
 
 #ifdef HAVE_SETPGID
@@ -2100,7 +2102,7 @@ extern void build_options(bool screen);
                exit_daemon("Samba cannot setup ep pipe", EACCES);
        }
 
-       if (is_daemon && !interactive) {
+       if (!interactive) {
                daemon_ready("smbd");
        }
 
index 4397a1bc0d12699e006ba62b0d79b791a30f34f2..1e08237905a811f9726e0238ca2b68289730bf96 100644 (file)
@@ -1880,8 +1880,11 @@ int main(int argc, const char **argv)
        BlockSignals(False, SIGHUP);
        BlockSignals(False, SIGCHLD);
 
-       if (!interactive)
+       if (!interactive) {
                become_daemon(Fork, no_process_group, log_stdout);
+       } else {
+               daemon_status("winbindd", "Starting process ...");
+       }
 
        pidfile_create(lp_pid_directory(), "winbindd");
 
index 95acb99b86c96faf3b47ccf53c0dbf1a476a4ba3..ee2e7508bb3ab532d76b718470975c3e78a080dc 100644 (file)
@@ -648,6 +648,8 @@ static int binary_smbd_main(const char *binary_name,
        if (opt_daemon) {
                DBG_NOTICE("Becoming a daemon.\n");
                become_daemon(opt_fork, opt_no_process_group, false);
+       } else if (!opt_interactive) {
+               daemon_status("samba", "Starting process...");
        }
 
        /* Create the memory context to hang everything off. */
@@ -931,7 +933,7 @@ static int binary_smbd_main(const char *binary_name,
                }
        }
 
-       if (opt_daemon) {
+       if (!opt_interactive) {
                daemon_ready("samba");
        }