]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Ensure CTDB_BASE is set, don't fetch it
authorMartin Schwenke <mschwenke@ddn.com>
Fri, 9 Aug 2024 00:53:46 +0000 (10:53 +1000)
committerAnoop C S <anoopcs@samba.org>
Tue, 8 Oct 2024 05:34:30 +0000 (05:34 +0000)
Uses of CTDB_BASE in the subsequent code are now handled by the path
module, so there is no point getting the value of CTDB_BASE.  Instead,
check that the attempt to set it worked, noting that:

  [...] if overwrite is zero, then the value of name is not
  changed (and setenv() returns a success status).

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
ctdb/server/ctdbd.c

index 23abb393e74caf51010b22b2e35af05a7705969a..0c55ef50b0eb4f006e149307eb45a90408d341ee 100644 (file)
@@ -165,7 +165,6 @@ int main(int argc, const char *argv[])
        const char **extra_argv;
        poptContext pc;
        struct tevent_context *ev;
-       const char *ctdb_base;
        struct conf_context *conf;
        const char *logging_location;
        const char *test_mode;
@@ -195,10 +194,9 @@ int main(int argc, const char *argv[])
        }
 
        /* Default value for CTDB_BASE - don't override */
-       setenv("CTDB_BASE", CTDB_ETCDIR, 0);
-       ctdb_base = getenv("CTDB_BASE");
-       if (ctdb_base == NULL) {
-               D_ERR("CTDB_BASE not set\n");
+       ret = setenv("CTDB_BASE", CTDB_ETCDIR, 0);
+       if (ret != 0) {
+               D_ERR("Unable to set CTDB_BASE (errno=%d)\n", errno);
                exit(1);
        }