rebus / rpms / samba

Forked from rpms/samba 3 years ago
Clone
92693f6
From 9dd1a4809b1b6d65bfb2258b443b0fe36e0a32f7 Mon Sep 17 00:00:00 2001
92693f6
From: Alexander Bokovoy <ab@samba.org>
92693f6
Date: Sat, 24 Oct 2020 16:52:43 +0300
92693f6
Subject: [PATCH] daemons: report status to systemd even when running in
92693f6
 foreground
92693f6
92693f6
When systemd launches samba services, the configuration we have in
92693f6
systemd service files expects that the main process (/usr/sbin/*)
92693f6
would use sd_notify() to report back its status. However, we only use
92693f6
sd_notify() when running become_daemon().
92693f6
92693f6
As a result, samba/smbd/winbindd/nmbd processes never report back its
92693f6
status and the status updates from other childs (smbd, winbindd, etc)
92693f6
are not accepted as we now have implied NotifyAccess=main since commit
92693f6
d1740fb3d5a72cb49e30b330bb0b01e7ef3e09cc
92693f6
92693f6
This leads to a timeout and killing samba process by systemd. Situation
92693f6
is reproducible in Fedora 33, for example.
92693f6
92693f6
Make sure that we have required status updates for all daemons in case
92693f6
we aren't runnning in interactive mode.
92693f6
92693f6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14552
92693f6
92693f6
Signed-off-by: Alexander Bokovoy <ab@samba.org>
92693f6
---
92693f6
 source3/nmbd/nmbd.c         | 4 +++-
92693f6
 source3/smbd/server.c       | 4 +++-
92693f6
 source3/winbindd/winbindd.c | 5 ++++-
92693f6
 source4/smbd/server.c       | 4 +++-
92693f6
 4 files changed, 13 insertions(+), 4 deletions(-)
92693f6
92693f6
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
92693f6
index 0b881d13f7b..f6aeba1f714 100644
92693f6
--- a/source3/nmbd/nmbd.c
92693f6
+++ b/source3/nmbd/nmbd.c
92693f6
@@ -1009,6 +1009,8 @@ static bool open_sockets(bool isdaemon, int port)
92693f6
 	if (is_daemon && !opt_interactive) {
92693f6
 		DEBUG(3, ("Becoming a daemon.\n"));
92693f6
 		become_daemon(Fork, no_process_group, log_stdout);
92693f6
+	} else if (!opt_interactive) {
92693f6
+		daemon_status("nmbd", "Starting process...");
92693f6
 	}
92693f6
 
92693f6
 #ifdef HAVE_SETPGID
92693f6
@@ -1135,7 +1137,7 @@ static bool open_sockets(bool isdaemon, int port)
92693f6
 		exit_daemon( "NMBD failed to setup packet server.", EACCES);
92693f6
 	}
92693f6
 
92693f6
-	if (is_daemon && !opt_interactive) {
92693f6
+	if (!opt_interactive) {
92693f6
 		daemon_ready("nmbd");
92693f6
 	}
92693f6
 
92693f6
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
92693f6
index 153dd3c9323..3d9db5d8407 100644
92693f6
--- a/source3/smbd/server.c
92693f6
+++ b/source3/smbd/server.c
92693f6
@@ -1893,6 +1893,8 @@ extern void build_options(bool screen);
92693f6
 	if (is_daemon && !interactive) {
92693f6
 		DEBUG(3, ("Becoming a daemon.\n"));
92693f6
 		become_daemon(Fork, no_process_group, log_stdout);
92693f6
+	} else {
92693f6
+		daemon_status("smbd", "Starting process ...");
92693f6
 	}
92693f6
 
92693f6
 #ifdef HAVE_SETPGID
92693f6
@@ -2100,7 +2102,7 @@ extern void build_options(bool screen);
92693f6
 		exit_daemon("Samba cannot setup ep pipe", EACCES);
92693f6
 	}
92693f6
 
92693f6
-	if (is_daemon && !interactive) {
92693f6
+	if (!interactive) {
92693f6
 		daemon_ready("smbd");
92693f6
 	}
92693f6
 
92693f6
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
92693f6
index 4397a1bc0d1..1e08237905a 100644
92693f6
--- a/source3/winbindd/winbindd.c
92693f6
+++ b/source3/winbindd/winbindd.c
92693f6
@@ -1880,8 +1880,11 @@ int main(int argc, const char **argv)
92693f6
 	BlockSignals(False, SIGHUP);
92693f6
 	BlockSignals(False, SIGCHLD);
92693f6
 
92693f6
-	if (!interactive)
92693f6
+	if (!interactive) {
92693f6
 		become_daemon(Fork, no_process_group, log_stdout);
92693f6
+	} else {
92693f6
+		daemon_status("winbindd", "Starting process ...");
92693f6
+	}
92693f6
 
92693f6
 	pidfile_create(lp_pid_directory(), "winbindd");
92693f6
 
92693f6
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
92693f6
index 95acb99b86c..ee2e7508bb3 100644
92693f6
--- a/source4/smbd/server.c
92693f6
+++ b/source4/smbd/server.c
92693f6
@@ -648,6 +648,8 @@ static int binary_smbd_main(const char *binary_name,
92693f6
 	if (opt_daemon) {
92693f6
 		DBG_NOTICE("Becoming a daemon.\n");
92693f6
 		become_daemon(opt_fork, opt_no_process_group, false);
92693f6
+	} else if (!opt_interactive) {
92693f6
+		daemon_status("samba", "Starting process...");
92693f6
 	}
92693f6
 
92693f6
 	/* Create the memory context to hang everything off. */
92693f6
@@ -931,7 +933,7 @@ static int binary_smbd_main(const char *binary_name,
92693f6
 		}
92693f6
 	}
92693f6
 
92693f6
-	if (opt_daemon) {
92693f6
+	if (!opt_interactive) {
92693f6
 		daemon_ready("samba");
92693f6
 	}
92693f6
 
92693f6
-- 
92693f6
2.28.0
92693f6