summaryrefslogtreecommitdiffstats
path: root/ctdb/tools
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2013-10-21 19:43:47 +1100
committerMartin Schwenke <martin@meltin.net>2013-10-22 15:37:54 +1100
commit27a63433698604888a1c58becefa120b50eb8e14 (patch)
treeb1d626353eb2af91ec7430d936afdd1ed9fa2d3d /ctdb/tools
parent7c903951361ead016f357069422a57cf17668f78 (diff)
downloadsamba-27a63433698604888a1c58becefa120b50eb8e14.tar.gz
samba-27a63433698604888a1c58becefa120b50eb8e14.tar.xz
samba-27a63433698604888a1c58becefa120b50eb8e14.zip
tools/ctdb: CTDB_BASE is the default location of configuration files
Ensure that environment variable CTDB_BASE is set. Update defaults for nodes and natgw_nodes to use CTDB_BASE. Signed-off-by: Martin Schwenke <martin@meltin.net> Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 2b6dc0d2799f3563b767622b6f9246450aa4036b)
Diffstat (limited to 'ctdb/tools')
-rw-r--r--ctdb/tools/ctdb.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index bad09c9c42..49fb278b10 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -810,7 +810,12 @@ static struct pnn_node *read_nodes_file(TALLOC_CTX *mem_ctx)
/* read the nodes file */
nodes_list = getenv("CTDB_NODES");
if (nodes_list == NULL) {
- nodes_list = "/etc/ctdb/nodes";
+ nodes_list = talloc_asprintf(mem_ctx, "%s/nodes",
+ getenv("CTDB_BASE"));
+ if (nodes_list == NULL) {
+ DEBUG(DEBUG_ALERT,(__location__ " Out of memory\n"));
+ exit(1);
+ }
}
lines = file_lines_load(nodes_list, &nlines, mem_ctx);
if (lines == NULL) {
@@ -1162,7 +1167,12 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
/* read the natgw nodes file into a linked list */
natgw_list = getenv("CTDB_NATGW_NODES");
if (natgw_list == NULL) {
- natgw_list = "/etc/ctdb/natgw_nodes";
+ natgw_list = talloc_asprintf(tmp_ctx, "%s/natgw_nodes",
+ getenv("CTDB_BASE"));
+ if (natgw_list == NULL) {
+ DEBUG(DEBUG_ALERT,(__location__ " Out of memory\n"));
+ exit(1);
+ }
}
lines = file_lines_load(natgw_list, &nlines, ctdb);
if (lines == NULL) {
@@ -6201,6 +6211,9 @@ int main(int argc, const char *argv[])
control = extra_argv[0];
+ /* Default value for CTDB_BASE - don't override */
+ setenv("CTDB_BASE", ETCDIR "/ctdb", 0);
+
ev = event_context_init(NULL);
if (!ev) {
DEBUG(DEBUG_ERR, ("Failed to initialize event system\n"));