[PATCH] Two small winbind cleanups

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Feb 15 15:28:43 UTC 2018


Hi!

Review appreciated!

Thanks, Volker

-- 
Besuchen Sie die verinice.XP 2018 in Berlin,
Anwenderkonferenz für Informationssicherheit
vom 21.-23.03.2018 im Sofitel Kurfürstendamm
Info & Anmeldung hier: http://veriniceXP.org

SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 7f9c895eb074e5b9a0e05fb6c1443cfa5d322c7d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 13 Feb 2018 14:05:15 +0100
Subject: [PATCH 1/2] winbind: Don't explicitly send "server_id" for
 ONLINESTATUS

Messaging already provides the sender id

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/utils/smbcontrol.c       | 8 ++------
 source3/winbindd/winbindd_dual.c | 9 +--------
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 0f6dacce20d..4b47d3bed57 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -1160,10 +1160,6 @@ static bool do_winbind_onlinestatus(struct tevent_context *ev_ctx,
 				    const struct server_id pid,
 				    const int argc, const char **argv)
 {
-	struct server_id myid;
-
-	myid = messaging_server_id(msg_ctx);
-
 	if (argc != 1) {
 		fprintf(stderr, "Usage: smbcontrol winbindd onlinestatus\n");
 		return False;
@@ -1172,9 +1168,9 @@ static bool do_winbind_onlinestatus(struct tevent_context *ev_ctx,
 	messaging_register(msg_ctx, NULL, MSG_WINBIND_ONLINESTATUS,
 			   print_pid_string_cb);
 
-	if (!send_message(msg_ctx, pid, MSG_WINBIND_ONLINESTATUS, &myid,
-			  sizeof(myid)))
+	if (!send_message(msg_ctx, pid, MSG_WINBIND_ONLINESTATUS, NULL, 0)) {
 		return False;
+	}
 
 	wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0);
 
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 993166d82d9..7b1527c38f3 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -796,16 +796,9 @@ void winbind_msg_onlinestatus(struct messaging_context *msg_ctx,
 {
 	TALLOC_CTX *mem_ctx;
 	const char *message;
-	struct server_id *sender;
 
 	DEBUG(5,("winbind_msg_onlinestatus received.\n"));
 
-	if (!data->data) {
-		return;
-	}
-
-	sender = (struct server_id *)data->data;
-
 	mem_ctx = talloc_init("winbind_msg_onlinestatus");
 	if (mem_ctx == NULL) {
 		return;
@@ -817,7 +810,7 @@ void winbind_msg_onlinestatus(struct messaging_context *msg_ctx,
 		return;
 	}
 
-	messaging_send_buf(msg_ctx, *sender, MSG_WINBIND_ONLINESTATUS, 
+	messaging_send_buf(msg_ctx, server_id, MSG_WINBIND_ONLINESTATUS,
 			   (const uint8_t *)message, strlen(message) + 1);
 
 	talloc_destroy(mem_ctx);
-- 
2.11.0


From 159c93560bd304ec0dc9ac9819d503014bb4e695 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 13 Feb 2018 14:05:43 +0100
Subject: [PATCH 2/2] winbind: Don't send "server_id" explicitly for
 DUMP_DOMAIN_LIST

messaging already provides the sender id

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/utils/smbcontrol.c       | 18 +-----------------
 source3/winbindd/winbindd_dual.c | 18 ++++--------------
 2 files changed, 5 insertions(+), 31 deletions(-)

diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 4b47d3bed57..c4b56305217 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -1204,11 +1204,6 @@ static bool do_winbind_dump_domain_list(struct tevent_context *ev_ctx,
 {
 	const char *domain = NULL;
 	int domain_len = 0;
-	struct server_id myid;
-	uint8_t *buf = NULL;
-	int buf_len = 0;
-
-	myid = messaging_server_id(msg_ctx);
 
 	if (argc < 1 || argc > 2) {
 		fprintf(stderr, "Usage: smbcontrol <dest> dump-domain-list "
@@ -1224,19 +1219,9 @@ static bool do_winbind_dump_domain_list(struct tevent_context *ev_ctx,
 	messaging_register(msg_ctx, NULL, MSG_WINBIND_DUMP_DOMAIN_LIST,
 			   print_pid_string_cb);
 
-	buf_len = sizeof(myid)+domain_len;
-	buf = SMB_MALLOC_ARRAY(uint8_t, buf_len);
-	if (!buf) {
-		return false;
-	}
-
-	memcpy(buf, &myid, sizeof(myid));
-	memcpy(&buf[sizeof(myid)], domain, domain_len);
-
 	if (!send_message(msg_ctx, pid, MSG_WINBIND_DUMP_DOMAIN_LIST,
-			  buf, buf_len))
+			  domain, domain_len))
 	{
-		SAFE_FREE(buf);
 		return false;
 	}
 
@@ -1244,7 +1229,6 @@ static bool do_winbind_dump_domain_list(struct tevent_context *ev_ctx,
 
 	/* No replies were received within the timeout period */
 
-	SAFE_FREE(buf);
 	if (num_replies == 0) {
 		printf("No replies received\n");
 	}
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 7b1527c38f3..7fb5aa899e4 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -848,7 +848,6 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
 {
 	TALLOC_CTX *mem_ctx;
 	const char *message = NULL;
-	struct server_id *sender = NULL;
 	const char *domain = NULL;
 	char *s = NULL;
 	NTSTATUS status;
@@ -856,22 +855,13 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
 
 	DEBUG(5,("winbind_msg_dump_domain_list received.\n"));
 
-	if (!data || !data->data) {
-		return;
-	}
-
-	if (data->length < sizeof(struct server_id)) {
-		return;
-	}
-
 	mem_ctx = talloc_init("winbind_msg_dump_domain_list");
 	if (!mem_ctx) {
 		return;
 	}
 
-	sender = (struct server_id *)data->data;
-	if (data->length > sizeof(struct server_id)) {
-		domain = (const char *)data->data+sizeof(struct server_id);
+	if (data->length > 0) {
+		domain = (const char *)data->data;
 	}
 
 	if (domain) {
@@ -886,7 +876,7 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
 			return;
 		}
 
-		messaging_send_buf(msg_ctx, *sender,
+		messaging_send_buf(msg_ctx, server_id,
 				   MSG_WINBIND_DUMP_DOMAIN_LIST,
 				   (const uint8_t *)message, strlen(message) + 1);
 
@@ -911,7 +901,7 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
 		}
 	}
 
-	status = messaging_send_buf(msg_ctx, *sender,
+	status = messaging_send_buf(msg_ctx, server_id,
 				    MSG_WINBIND_DUMP_DOMAIN_LIST,
 				    (uint8_t *)s, strlen(s) + 1);
 	if (!NT_STATUS_IS_OK(status)) {
-- 
2.11.0



More information about the samba-technical mailing list