From e5386b52cf6a7c209974ecf25bab949e6a700ee0 Mon Sep 17 00:00:00 2001
From: Ariel Barria <arielb@fedoraproject.org>
Date: Sun, 15 Jul 2012 23:24:35 -0500
Subject: [PATCH] Improve syslog message when configuration cannot be loaded

---
 src/confdb/confdb.c   |    7 ++++---
 src/monitor/monitor.c |   29 ++++++++++++++++++++---------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/src/confdb/confdb.c b/src/confdb/confdb.c
index ab0d00480d7a06234e21df30e7c74fb5b7000209..eda879f26937fe9b597922b0062880b5c57a8d2a 100644
--- a/src/confdb/confdb.c
+++ b/src/confdb/confdb.c
@@ -643,7 +643,7 @@ int confdb_init(TALLOC_CTX *mem_ctx,
 
     ret = ldb_set_debug(cdb->ldb, ldb_debug_messages, NULL);
     if (ret != LDB_SUCCESS) {
-        DEBUG(0,("Could not set up debug fn.\n"));
+        DEBUG(SSSDBG_FATAL_FAILURE, ("Could not set up debug fn.\n"));
         talloc_free(cdb);
         return EIO;
     }
@@ -653,8 +653,9 @@ int confdb_init(TALLOC_CTX *mem_ctx,
     ret = ldb_connect(cdb->ldb, confdb_location, 0, NULL);
     umask(old_umask);
     if (ret != LDB_SUCCESS) {
-        DEBUG(0, ("Unable to open config database [%s]\n",
-                  confdb_location));
+        DEBUG(SSSDBG_FATAL_FAILURE,
+             ("Unable to open config database [%s], [%d] [%s].\n",
+              confdb_location, ret, strerror(ret)));
         talloc_free(cdb);
         return EIO;
     }
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 201d9fa8dd01977ff5455da053fff4c2bd4fcec5..79b7c3f8050a3a1c99ac65d27abae7f93ba7f1c2 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1381,14 +1381,16 @@ static errno_t load_configuration(TALLOC_CTX *mem_ctx,
 
     cdb_file = talloc_asprintf(ctx, "%s/%s", DB_PATH, CONFDB_FILE);
     if (cdb_file == NULL) {
-        DEBUG(0,("Out of memory, aborting!\n"));
+        DEBUG(SSSDBG_FATAL_FAILURE, ("Out of memory, aborting!.\n"));
         ret = ENOMEM;
         goto done;
     }
 
     ret = confdb_init(ctx, &ctx->cdb, cdb_file);
     if (ret != EOK) {
-        DEBUG(0,("The confdb initialization failed\n"));
+        DEBUG(SSSDBG_FATAL_FAILURE,
+             ("The confdb initialization failed, [%d] [%s].\n",
+             ret, strerror(ret)));
         goto done;
     }
 
@@ -1405,25 +1407,31 @@ static errno_t load_configuration(TALLOC_CTX *mem_ctx,
 
         ret = confdb_init(ctx, &ctx->cdb, cdb_file);
         if (ret != EOK) {
-            DEBUG(0,("The confdb initialization failed\n"));
+            DEBUG(SSSDBG_FATAL_FAILURE,
+                 ("The confdb initialization failed, [%d] [%s].\n",
+                 ret, strerror(ret)));
             goto done;
         }
 
         /* Load special entries */
         ret = confdb_create_base(ctx->cdb);
         if (ret != EOK) {
-            DEBUG(0, ("Unable to load special entries into confdb\n"));
+            DEBUG(SSSDBG_FATAL_FAILURE,
+                 ("Unable to load special entries into confdb.\n"));
             goto done;
         }
     } else if (ret != EOK) {
-        DEBUG(0, ("Fatal error initializing confdb\n"));
+        DEBUG(SSSDBG_FATAL_FAILURE,
+             ("Fatal error initializing confdb, [%d] [%s].\n",
+             ret, strerror(ret)));
         goto done;
     }
     talloc_zfree(cdb_file);
 
     ret = confdb_init_db(config_file, ctx->cdb);
     if (ret != EOK) {
-        DEBUG(0, ("ConfDB initialization has failed [%s]\n",
+        DEBUG(SSSDBG_FATAL_FAILURE,
+             ("ConfDB initialization has failed [%s].\n",
               strerror(ret)));
         goto done;
     }
@@ -2522,9 +2530,12 @@ int main(int argc, const char *argv[])
                     "Cannot read config file %s, please check if permissions "
                     "are 0600 and the file is owned by root.root", config_file);
         } else {
-            DEBUG(1, ("Error loading configuration database: [%d]: %s",
-                      ret, strerror(ret)));
-            sss_log(SSS_LOG_ALERT, "Cannot load configuration database");
+            DEBUG(SSSDBG_FATAL_FAILURE,
+                 ("Error loading configuration database: [%d]: %s",
+                 ret, strerror(ret)));
+            sss_log(SSS_LOG_ALERT,
+                   "Cannot load configuration database: [%d]: %s",
+                   ret, strerror(ret));
         }
         return 4;
     }
-- 
1.7.7.6

