From 08134dde5a6c8b23cf40ec8f0020cd553af2667e Mon Sep 17 00:00:00 2001
From: Pavel Reichl <pavel.reichl@redhat.com>
Date: Tue, 19 Nov 2013 11:24:31 +0000
Subject: [PATCH 2/6] monitor: Specific error message for missing sssd.conf
Specific error message is logged for missing sssd.conf file. New sssd specific
error value is introduced for this case.
Resolves:
https://fedorahosted.org/sssd/ticket/2156
---
src/confdb/confdb_setup.c | 9 +++++++--
src/monitor/monitor.c | 8 +++++++-
src/util/util_errors.c | 1 +
src/util/util_errors.h | 1 +
4 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/confdb/confdb_setup.c b/src/confdb/confdb_setup.c
index b13553eaa560bb83ecf7a53b32ab116f38f7f480..2a34e4f7a3e5f9aa37760036520f5274e9289b70 100644
--- a/src/confdb/confdb_setup.c
+++ b/src/confdb/confdb_setup.c
@@ -155,8 +155,13 @@ int confdb_init_db(const char *config_file, struct confdb_ctx *cdb)
/* Open config file */
ret = sss_ini_config_file_open(init_data, config_file);
if (ret != EOK) {
- DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to open configuration file.\n"));
- ret = EIO;
+ DEBUG(SSSDBG_TRACE_FUNC,
+ ("sss_ini_config_file_open failed: %s [%d]\n", strerror(ret),
+ ret));
+ if (ret == ENOENT) {
+ /* sss specific error denoting missing configuration file */
+ ret = ERR_MISSING_CONF;
+ }
goto done;
}
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 3d8ba26285b6a8fc60ccb695f8b10ae1714ac918..09f530d2643b45fc31fb4dbe3cb69f2abc5510af 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1614,7 +1614,7 @@ static errno_t load_configuration(TALLOC_CTX *mem_ctx,
ret = confdb_init_db(config_file, ctx->cdb);
if (ret != EOK) {
DEBUG(0, ("ConfDB initialization has failed [%s]\n",
- strerror(ret)));
+ sss_strerror(ret)));
goto done;
}
@@ -2789,6 +2789,12 @@ int main(int argc, const char *argv[])
ret = load_configuration(tmp_ctx, config_file, &monitor);
if (ret != EOK) {
switch (ret) {
+ case ERR_MISSING_CONF:
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Configuration file: %s does not exist.\n", config_file));
+ sss_log(SSS_LOG_ALERT,
+ "Configuration file: %s does not exist.\n", config_file);
+ break;
case EPERM:
case EACCES:
DEBUG(SSSDBG_CRIT_FAILURE,
diff --git a/src/util/util_errors.c b/src/util/util_errors.c
index b3d10f97b0567ca21ca08a3f2d326ea401c28aff..114c8b04fd354b166d14e526a3bab6a6c0c05951 100644
--- a/src/util/util_errors.c
+++ b/src/util/util_errors.c
@@ -50,6 +50,7 @@ struct err_string error_to_str[] = {
{ "Dynamic DNS update not possible while offline" }, /* ERR_DYNDNS_OFFLINE */
{ "Entry not found" }, /* ERR_NOT_FOUND */
{ "Domain not found" }, /* ERR_DOMAIN_NOT_FOUND */
+ { "Missing configuration file" }, /* ERR_MISSING_CONF */
};
diff --git a/src/util/util_errors.h b/src/util/util_errors.h
index 685607c5bb1b4e7c37152c876518a2b1c69c18d6..bca45f392b0357c3f1c848768358cb1d47514715 100644
--- a/src/util/util_errors.h
+++ b/src/util/util_errors.h
@@ -72,6 +72,7 @@ enum sssd_errors {
ERR_DYNDNS_OFFLINE,
ERR_NOT_FOUND,
ERR_DOMAIN_NOT_FOUND,
+ ERR_MISSING_CONF,
ERR_LAST /* ALWAYS LAST */
};
--
1.8.4.2