[PATCHES] Forward smbcontrol messages only from parent

Christof Schmitt cs at samba.org
Wed May 14 06:12:08 MDT 2014


Here are a few fixes to forward smbcontrol messages from the parent to
the child processes, and ensure that child processes don't forward them
again.

Christof
-------------- next part --------------
>From 9dda4af19cdb5245e65ab9175f6a47425a6cea89 Mon Sep 17 00:00:00 2001
From: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Date: Mon, 25 Feb 2013 15:38:09 +0100
Subject: [PATCH 1/4] s3: Fix "smbcontrol smbd reload-config"

Signed-off-by: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Reviewed-by: Christof Schmitt <cs at samba.org>
---
 source3/smbd/server.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 298afb9..37d93af 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -107,6 +107,9 @@ static void smbd_parent_conf_updated(struct messaging_context *msg,
 	change_to_root_user();
 	reload_services(NULL, NULL, false);
 	printing_subsystem_update(ev_ctx, msg, false);
+	if (am_parent) {
+		messaging_send_to_children(msg, msg_type, data);
+	}
 }
 
 /*******************************************************************
-- 
1.7.1


>From 32048b4e1709ef2633a3978e6809d7cb1038abfa Mon Sep 17 00:00:00 2001
From: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Date: Mon, 25 Feb 2013 15:38:09 +0100
Subject: [PATCH 2/4] s3:smbcontrol: Forward MSG_DEBUG only if we are the parent process

When smbd receives a MSG_DEBUG message the message is forwarded to all
child processes listed in the 'children' linked list. When forking a new smbd
child process 'children' still contains the list of all up to now forked
child processes which causes a message storm between the smbd child processes.

Fixed by notifying child processes only if we are the smbd parent process.

Signed-off-by: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Reviewed-by: Christof Schmitt <cs at samba.org>
---
 source3/smbd/server.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 37d93af..66c6b9e 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -233,7 +233,9 @@ static void smbd_msg_debug(struct messaging_context *msg_ctx,
 {
 	debug_message(msg_ctx, private_data, MSG_DEBUG, server_id, data);
 
-	messaging_send_to_children(msg_ctx, MSG_DEBUG, data);
+	if (am_parent) {
+		messaging_send_to_children(msg_ctx, MSG_DEBUG, data);
+	}
 }
 
 static void smbd_parent_id_cache_kill(struct messaging_context *msg_ctx,
-- 
1.7.1


>From 1243314e015235eec5321fe8bf8a17894b2b71d5 Mon Sep 17 00:00:00 2001
From: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Date: Mon, 25 Feb 2013 15:38:09 +0100
Subject: [PATCH 3/4] s3:smbcontrol: Forward MSG_FORCE_TDIS only if we are the parent process

When smbd receives a MSG_FORCE_TDIS message the message is forwarded to all
child processes listed in the 'children' linked list. When forking a new smbd
child process 'children' still contains the list of all up to now forked
child processes which causes a message storm between the smbd child processes.

Fixed by notifying child processes only if we are the smbd parent process.

Signed-off-by: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Reviewed-by: Christof Schmitt <cs at samba.org>
---
 source3/smbd/server.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 66c6b9e..537ab9e 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -372,7 +372,9 @@ static void smb_parent_force_tdis(struct messaging_context *ctx,
 				  struct server_id srv_id,
 				  DATA_BLOB* msg_data)
 {
-	messaging_send_to_children(ctx, msg_type, msg_data);
+	if (am_parent) {
+		messaging_send_to_children(ctx, msg_type, msg_data);
+	}
 }
 
 static void smb_parent_kill_client_by_ip(struct messaging_context *ctx,
-- 
1.7.1


>From 917a24b0a91745f06ab04cc3260a82365d62451f Mon Sep 17 00:00:00 2001
From: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Date: Tue, 26 Feb 2013 16:50:19 +0100
Subject: [PATCH 4/4] s3:smbcontrol: Forward MSG_IDMAP_* only if we are the parent process

When smbd receives a MSG_IDMAP_FLUSH, MSG_IDMAP_DELETE, or MSG_IDMAP_KILL
message the message is forwarded to all child processes listed in the
'children' linked list. When forking a new smbd child process 'children'
still contains the list of all up to now forked child processes which causes
a message storm between the smbd child processes.

Fixed by notifying child processes only if we are the smbd parent process.

Signed-off-by: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Reviewed-by: Christof Schmitt <cs at samba.org>
---
 source3/smbd/server.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 537ab9e..8e57d2c 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -255,7 +255,9 @@ static void smbd_parent_id_cache_kill(struct messaging_context *msg_ctx,
 
 	id_cache_delete_from_cache(&id);
 
-	messaging_send_to_children(msg_ctx, msg_type, data);
+	if (am_parent) {
+		messaging_send_to_children(msg_ctx, msg_type, data);
+	}
 }
 
 static void smbd_parent_id_cache_delete(struct messaging_context *ctx,
@@ -266,7 +268,9 @@ static void smbd_parent_id_cache_delete(struct messaging_context *ctx,
 {
 	id_cache_delete_message(ctx, data, msg_type, srv_id, msg_data);
 
-	messaging_send_to_children(ctx, msg_type, msg_data);
+	if (am_parent) {
+		messaging_send_to_children(ctx, msg_type, msg_data);
+	}
 }
 
 struct smbd_parent_notify_state {
-- 
1.7.1



More information about the samba-technical mailing list