]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-pmda: Do not directly support CTDB_SOCKET environment variable
authorMartin Schwenke <mschwenke@ddn.com>
Fri, 15 Aug 2025 02:08:47 +0000 (12:08 +1000)
committerJule Anger <janger@samba.org>
Fri, 26 Sep 2025 12:31:12 +0000 (12:31 +0000)
Always use whatever CTDB uses in the current environment.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15921

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit c4794e40529c63c696ecc3f8f27c810c22dd63a5)

ctdb/utils/pmda/pmda_ctdb.c

index 5c09aca7b84a1a4bfbbb6f835593c93e2d06201c..edf6ffc136b6746e06f7d69be95b70936078533d 100644 (file)
@@ -28,6 +28,8 @@
 #include "lib/util/time.h"
 #include "lib/util/blocking.h"
 
+#include "common/path.h"
+
 #include "client/client.h"
 #include "client/client_sync.h"
 
@@ -58,9 +60,7 @@
  * CTDB PMDA
  *
  * This PMDA connects to the locally running ctdbd daemon and pulls
- * statistics for export via PCP. The ctdbd Unix domain socket path can be
- * specified with the CTDB_SOCKET environment variable, otherwise the default
- * path is used.
+ * statistics for export via PCP.
  */
 
 /*
@@ -200,7 +200,7 @@ pmda_ctdb_disconnected(void *args)
 static int
 pmda_ctdb_daemon_connect(void)
 {
-       const char *socket_name;
+       char *socket_name = NULL;
        int ret;
 
        ev = tevent_context_init(NULL);
@@ -209,9 +209,9 @@ pmda_ctdb_daemon_connect(void)
                return -1;
        }
 
-       socket_name = getenv("CTDB_SOCKET");
+       socket_name = path_socket(ev, "ctdbd");
        if (socket_name == NULL) {
-               socket_name = CTDB_SOCKET;
+               goto err_ev;
        }
 
        ret = ctdb_client_init(ev, ev, socket_name, &client);
@@ -224,6 +224,7 @@ pmda_ctdb_daemon_connect(void)
        ctdb_client_set_disconnect_callback(client, pmda_ctdb_disconnected,
                                            NULL);
 
+       talloc_free(socket_name);
        return 0;
 
 err_ev: