ctdb-daemon: Exit with error if a database directory does not exist
authorMartin Schwenke <martin@meltin.net>
Fri, 30 Nov 2018 01:44:26 +0000 (12:44 +1100)
committerAmitay Isaacs <amitay@samba.org>
Mon, 3 Dec 2018 05:56:41 +0000 (06:56 +0100)
Since 4.9.0, the log messages can be confusing if a required database
directory does not exist.  Explicitly check for database directories,
logging a clear error and exiting if one is missing.

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Dec  3 06:56:41 CET 2018 on sn-devel-144

ctdb/server/ctdbd.c

index a2870d0..7e71d6e 100644 (file)
@@ -311,8 +311,28 @@ int main(int argc, const char *argv[])
         */
 
        ctdb->db_directory = ctdb_config.dbdir_volatile;
+       ok = directory_exist(ctdb->db_directory);
+       if (! ok) {
+               D_ERR("Volatile database directory %s does not exist\n",
+                     ctdb->db_directory);
+               goto fail;
+       }
+
        ctdb->db_directory_persistent = ctdb_config.dbdir_persistent;
+       ok = directory_exist(ctdb->db_directory_persistent);
+       if (! ok) {
+               D_ERR("Persistent database directory %s does not exist\n",
+                     ctdb->db_directory_persistent);
+               goto fail;
+       }
+
        ctdb->db_directory_state = ctdb_config.dbdir_state;
+       ok = directory_exist(ctdb->db_directory_state);
+       if (! ok) {
+               D_ERR("State database directory %s does not exist\n",
+                     ctdb->db_directory_state);
+               goto fail;
+       }
 
        if (ctdb_config.lock_debug_script != NULL) {
                ret = setenv("CTDB_DEBUG_LOCKS",