summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-05-05 13:37:13 +0200
committerSimo Sorce <ssorce@redhat.com>2009-05-26 08:48:53 -0400
commit9df9359312ebb29e0a9b5c6db0cb0a195194f49e (patch)
tree0ddb1afed4ccc0c9af029634973364102df4efb9
parent319aff764c9e04270d3c59257d8971f22bd341f0 (diff)
downloadsssd-9df9359312ebb29e0a9b5c6db0cb0a195194f49e.tar.gz
sssd-9df9359312ebb29e0a9b5c6db0cb0a195194f49e.tar.xz
sssd-9df9359312ebb29e0a9b5c6db0cb0a195194f49e.zip
Read the config before startup, fail if cannot be read
-rw-r--r--server/monitor/monitor.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c
index 910154106..2db233d8a 100644
--- a/server/monitor/monitor.c
+++ b/server/monitor/monitor.c
@@ -39,6 +39,8 @@
#include "tevent.h"
#include "confdb/confdb.h"
#include "confdb/confdb_setup.h"
+#include "collection.h"
+#include "ini_config.h"
#include "db/sysdb.h"
#include "monitor/monitor.h"
#include "dbus/dbus.h"
@@ -1078,6 +1080,26 @@ static void monitor_quit(struct tevent_context *ev,
exit(0);
}
+int read_config_file(const char *config_file)
+{
+ int ret;
+ struct collection_item *sssd_config = NULL;
+ struct collection_item *error_list = NULL;
+
+ /* Read the configuration into a collection */
+ ret = config_from_file("sssd", config_file, &sssd_config,
+ INI_STOP_ON_ANY, &error_list);
+ if (ret != EOK) {
+ DEBUG(0, ("Parse error reading configuration file [%s]\n",
+ config_file));
+ print_file_parsing_errors(stderr, error_list);
+ }
+
+ destroy_collection(error_list);
+ destroy_collection(sssd_config);
+ return ret;
+}
+
#ifdef HAVE_SYS_INOTIFY_H
static void config_file_changed(struct tevent_context *ev,
struct tevent_fd *fde,
@@ -2013,6 +2035,10 @@ int main(int argc, const char *argv[])
/* we want a pid file check */
flags |= FLAGS_PID_FILE;
+ /* Parse config file, fail if cannot be done */
+ ret = read_config_file(config_file);
+ if (ret != EOK) return 4;
+
/* set up things like debug , signals, daemonization, etc... */
ret = server_setup("sssd", flags, MONITOR_CONF_ENTRY, &main_ctx);
if (ret != EOK) return 2;