[PATCH] Patch for bug 12016

Ralph Boehme slow at samba.org
Sun Jul 10 18:24:25 UTC 2016


Hi!

Attached is a patch for bug
<https://bugzilla.samba.org/show_bug.cgi?id=12016>

cleanupd (and notifyd and mdssd) call reinit_after_fork() which leaves
am_parent intact. As a result when exitting installed atexit handler
killkids() will be called doing signal(0,SIGTERM), sending SIGTERM to
all processes in its process group, main smbd being one of them.

Simple fix: call smbd_ reinit_after_fork() instead.

Patch attached, please review and push if ok.

Cheerio!
-slow
-------------- next part --------------
From 26c4ea7d3a22f9953dd29879ae2820d734a3bd25 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 5 Jul 2016 15:20:53 +0200
Subject: [PATCH 1/3] smbd/cleanupd: use smbd_reinit_after_fork()

Using smbd_reinit_after_fork() rather then reinit_after_fork() ensures
am_parent is reset to NULL. Otherwise, when exiting for some reason, the
inherited atexit handler killkids() calls kill(0,SIGTERM) terminating
our whole process group including the main smbd.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12016

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source3/smbd/server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index cdcdcc2..e68e035 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -478,7 +478,7 @@ static bool cleanupd_init(struct messaging_context *msg, bool interactive,
 
 	close(up_pipe[0]);
 
-	status = reinit_after_fork(msg, ev, true, "cleanupd");
+	status = smbd_reinit_after_fork(msg, ev, true, "cleanupd");
 	if (!NT_STATUS_IS_OK(status)) {
 		DBG_WARNING("reinit_after_fork failed: %s\n",
 			    nt_errstr(status));
-- 
2.5.0


From bf6de4af50200585c8aeb8d2d0719a6a1afeea3d Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 5 Jul 2016 15:37:53 +0200
Subject: [PATCH 2/3] smbd/notifyd: use smbd_reinit_after_fork()

Using smbd_reinit_after_fork() rather then reinit_after_fork() ensures
am_parent is reset to NULL. Otherwise, when exiting for some reason, the
inherited atexit handler killkids() calls kill(0,SIGTERM) terminating
our whole process group including the main smbd.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12016

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source3/smbd/server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index e68e035..6e70edc 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -396,7 +396,7 @@ static bool smbd_notifyd_init(struct messaging_context *msg, bool interactive)
 		return true;
 	}
 
-	status = reinit_after_fork(msg, ev, true, "smbd-notifyd");
+	status = smbd_reinit_after_fork(msg, ev, true, "smbd-notifyd");
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(1, ("%s: reinit_after_fork failed: %s\n",
 			  __func__, nt_errstr(status)));
-- 
2.5.0


From 5477c0907c76e8f949e51cc37d00d210afec6d6e Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 5 Jul 2016 15:38:31 +0200
Subject: [PATCH 3/3] s3-rpc_server/mdssd: use smbd_reinit_after_fork()

Using smbd_reinit_after_fork() rather then reinit_after_fork() ensures
am_parent is reset to NULL. Otherwise, when exiting for some reason, the
inherited atexit handler killkids() calls kill(0,SIGTERM) terminating
our whole process group including the main smbd.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12016

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source3/rpc_server/mdssd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/rpc_server/mdssd.c b/source3/rpc_server/mdssd.c
index e4c12cd..daff5f0 100644
--- a/source3/rpc_server/mdssd.c
+++ b/source3/rpc_server/mdssd.c
@@ -645,7 +645,7 @@ void start_mdssd(struct tevent_context *ev_ctx,
 		return;
 	}
 
-	status = reinit_after_fork(msg_ctx, ev_ctx, true, "mdssd-master");
+	status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true, "mdssd-master");
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0,("reinit_after_fork() failed\n"));
 		smb_panic("reinit_after_fork() failed");
-- 
2.5.0



More information about the samba-technical mailing list