From 9df9359312ebb29e0a9b5c6db0cb0a195194f49e Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 5 May 2009 13:37:13 +0200 Subject: Read the config before startup, fail if cannot be read --- server/monitor/monitor.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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; -- cgit