[PATCH] smbstatus: always initialize a messaing context

Ralph Boehme rb at sernet.de
Tue Nov 10 17:09:16 UTC 2015


Hi!

Just came across that smbstatus wasn't working anymore in that it
didn't list any sessions or shares.

Turns out due to recent serverid changes we always need a messaging
context in smbstatus.

Please review & push if ok. Thanks!

-slow

-- 
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@sernet.de
-------------- next part --------------
From bf06c4cda30ef1ae2f63388d539f52275b35a4dd Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 10 Nov 2015 17:59:09 +0100
Subject: [PATCH] smbstatus: always initialize a messaing context

Recent changes (b542ce7db394de3023b95288b0c40c4533c02cb1) to serverid
code made serverid_exists() call messaging_dgm_get_unique() which means
we depend on a valid messaging context that initializes
global_dgm_context.

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source3/utils/status.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/source3/utils/status.c b/source3/utils/status.c
index f81ab5f..8d84537 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -456,18 +456,15 @@ int main(int argc, const char *argv[])
 	}
 
 
-	if (lp_clustering()) {
-		/*
-		 * This implicitly initializes the global ctdbd
-		 * connection, usable by the db_open() calls further
-		 * down.
-		 */
-		msg_ctx = messaging_init(NULL, samba_tevent_context_init(NULL));
-		if (msg_ctx == NULL) {
-			fprintf(stderr, "messaging_init failed\n");
-			ret = -1;
-			goto done;
-		}
+	/*
+	 * This implicitly initializes the global ctdbd connection,
+	 * usable by the db_open() calls further down.
+	 */
+	msg_ctx = messaging_init(NULL, samba_tevent_context_init(NULL));
+	if (msg_ctx == NULL) {
+		fprintf(stderr, "messaging_init failed\n");
+		ret = -1;
+		goto done;
 	}
 
 	if (!lp_load_global(get_dyn_CONFIGFILE())) {
@@ -582,16 +579,6 @@ int main(int argc, const char *argv[])
 	if (show_notify) {
 		struct notify_context *n;
 
-		if (msg_ctx == NULL) {
-			msg_ctx = messaging_init(
-				NULL, samba_tevent_context_init(NULL));
-			if (msg_ctx == NULL) {
-				fprintf(stderr, "messaging_init failed\n");
-				ret = -1;
-				goto done;
-			}
-		}
-
 		n = notify_init(talloc_tos(), msg_ctx,
 				messaging_tevent_context(msg_ctx));
 		if (n == NULL) {
-- 
2.5.0



More information about the samba-technical mailing list