ctdb-scripts: Drop internal file-level variables referencing $CTDB_VARDIR
authorMartin Schwenke <martin@meltin.net>
Mon, 10 Aug 2015 06:11:18 +0000 (16:11 +1000)
committerMichael Adam <obnox@samba.org>
Tue, 15 Sep 2015 06:56:20 +0000 (08:56 +0200)
Using $CTDB_VARDIR at file scope is dangerous because it doesn't
respect the configuration.  Uses of these variables are simple so just
drop the variables and use $CTDB_VARDIR inside functions where it is
safe.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
ctdb/config/functions

index 0fc1fbe5fb30f20414bcf6156f13d1b4babc69d2..66140dc1aa00bb15e7fd9eabd6bbb776e9310e3e 100755 (executable)
@@ -307,7 +307,8 @@ ctdb_check_directories()
 _ctdb_check_tcp_common ()
 {
     assert_service_name
-    _ctdb_service_started_file="$ctdb_fail_dir/$service_name.started"
+    _d="${CTDB_VARDIR}/state/failcount"
+    _ctdb_service_started_file="${_d}/${service_name}.started"
 }
 
 ctdb_check_tcp_init ()
@@ -610,7 +611,7 @@ flush_route_cache ()
 # Simple counters
 _ctdb_counter_common () {
     _service_name="${1:-${service_name:-${script_name}}}"
-    _counter_file="$ctdb_fail_dir/$_service_name"
+    _counter_file="${CTDB_VARDIR}/state/failcount/${_service_name}"
     mkdir -p "${_counter_file%/*}" # dirname
 }
 ctdb_counter_init () {
@@ -659,9 +660,6 @@ ctdb_check_counter () {
 
 ########################################################
 
-ctdb_status_dir="$CTDB_VARDIR/state/service_status"
-ctdb_fail_dir="$CTDB_VARDIR/state/failcount"
-
 ctdb_setup_service_state_dir ()
 {
     service_state_dir="$CTDB_VARDIR/state/service_state/${1:-${service_name}}"
@@ -674,17 +672,15 @@ ctdb_setup_service_state_dir ()
 ########################################################
 # Managed status history, for auto-start/stop
 
-ctdb_managed_dir="$CTDB_VARDIR/state/managed_history"
-
 _ctdb_managed_common ()
 {
-    _ctdb_managed_file="$ctdb_managed_dir/$service_name"
+    _ctdb_managed_file="${CTDB_VARDIR}/state/managed_history/${service_name}"
 }
 
 ctdb_service_managed ()
 {
     _ctdb_managed_common
-    mkdir -p "$ctdb_managed_dir"
+    mkdir -p "${_ctdb_managed_file%/*}" # dirname
     touch "$_ctdb_managed_file"
 }
 
@@ -705,7 +701,7 @@ is_ctdb_previously_managed_service ()
 
 _ctdb_service_reconfigure_common ()
 {
-    _d="$ctdb_status_dir/${service_name}"
+    _d="${CTDB_VARDIR}/state/service_status/${service_name}"
     mkdir -p "$_d"
     _ctdb_service_reconfigure_flag="$_d/reconfigure"
 }