arrfab / rpms / abrt

Forked from rpms/abrt 5 years ago
Clone

Blame SOURCES/abrt-2.1.7-Load-conf-from-usr-share-abrt-conf.d-and-etc-abrt.patch

f6eb96
From aa86e1a4ba6a472b6eb2af6cad07672322eafded Mon Sep 17 00:00:00 2001
f6eb96
From: Jakub Filak <jfilak@redhat.com>
f6eb96
Date: Sun, 10 Nov 2013 10:19:57 +0100
f6eb96
Subject: [ABRT PATCH 69/76] Load conf from /usr/share/abrt/conf.d and
f6eb96
 /etc/abrt
f6eb96
f6eb96
Related to #752
f6eb96
f6eb96
Signed-off-by: Jakub Filak <jfilak@redhat.com>
f6eb96
---
f6eb96
 configure.ac                                 |  4 ++
f6eb96
 src/daemon/Makefile.am                       |  2 +
f6eb96
 src/daemon/abrt-action-save-package-data.c   | 22 ++++++++---
f6eb96
 src/hooks/Makefile.am                        |  3 ++
f6eb96
 src/hooks/abrt-hook-ccpp.c                   |  2 +-
f6eb96
 src/hooks/abrt_exception_handler.py.in       | 18 ++-------
f6eb96
 src/hooks/abrt_harvest_vmcore.py.in          | 30 +++++++-------
f6eb96
 src/include/libabrt.h                        |  6 +++
f6eb96
 src/lib/Makefile.am                          |  3 ++
f6eb96
 src/lib/abrt_conf.c                          | 22 +++++++++--
f6eb96
 src/plugins/Makefile.am                      |  4 +-
f6eb96
 src/plugins/abrt-action-analyze-xorg.c       |  8 ++--
f6eb96
 src/plugins/abrt-action-generate-backtrace.c |  5 ++-
f6eb96
 src/plugins/abrt-action-install-debuginfo.in | 20 +++-------
f6eb96
 src/python-problem/problem/common.h          |  2 +
f6eb96
 src/python-problem/problem/pyabrt.c          | 59 ++++++++++++++++++++++++++++
f6eb96
 src/python-problem/problem/pyabrtmodule.c    |  2 +
f6eb96
 17 files changed, 151 insertions(+), 61 deletions(-)
f6eb96
f6eb96
diff --git a/configure.ac b/configure.ac
f6eb96
index 113b315..f6ae82e 100644
f6eb96
--- a/configure.ac
f6eb96
+++ b/configure.ac
f6eb96
@@ -132,8 +132,10 @@ AC_CHECK_HEADER([sys/inotify.h], [],
f6eb96
 AC_CHECK_HEADERS([locale.h])
f6eb96
 
f6eb96
 CONF_DIR='${sysconfdir}/${PACKAGE_NAME}'
f6eb96
+DEFAULT_CONF_DIR='${datadir}/${PACKAGE_NAME}/conf.d'
f6eb96
 VAR_RUN='${localstatedir}/run'
f6eb96
 PLUGINS_CONF_DIR='${sysconfdir}/${PACKAGE_NAME}/plugins'
f6eb96
+DEFAULT_PLUGINS_CONF_DIR='${datadir}/${PACKAGE_NAME}/conf.d/plugins'
f6eb96
 EVENTS_DIR='${datadir}/libreport/events'
f6eb96
 EVENTS_CONF_DIR='${sysconfdir}/libreport/events.d'
f6eb96
 ENABLE_SOCKET_OR_DBUS='-DENABLE_DBUS=1'
f6eb96
@@ -191,8 +193,10 @@ AC_ARG_ENABLE([native-unwinder],
f6eb96
 
f6eb96
 
f6eb96
 AC_SUBST(CONF_DIR)
f6eb96
+AC_SUBST(DEFAULT_CONF_DIR)
f6eb96
 AC_SUBST(VAR_RUN)
f6eb96
 AC_SUBST(PLUGINS_CONF_DIR)
f6eb96
+AC_SUBST(DEFAULT_PLUGINS_CONF_DIR)
f6eb96
 AC_SUBST(EVENTS_CONF_DIR)
f6eb96
 AC_SUBST(EVENTS_DIR)
f6eb96
 AC_SUBST(DEFAULT_DUMP_LOCATION)
f6eb96
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
f6eb96
index fba6b83..158f3e5 100644
f6eb96
--- a/src/daemon/Makefile.am
f6eb96
+++ b/src/daemon/Makefile.am
f6eb96
@@ -104,6 +104,8 @@ dist_daemonconf_DATA = \
f6eb96
     abrt.conf \
f6eb96
     abrt-action-save-package-data.conf \
f6eb96
     gpg_keys.conf
f6eb96
+defaultdaemonconfdir = $(DEFAULT_CONF_DIR)
f6eb96
+dist_defaultdaemonconf_DATA = $(dist_daemonconf_DATA)
f6eb96
 
f6eb96
 EXTRA_DIST = abrt-handle-upload.in
f6eb96
 
f6eb96
diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c
f6eb96
index 5da6905..6dbcfc2 100644
f6eb96
--- a/src/daemon/abrt-action-save-package-data.c
f6eb96
+++ b/src/daemon/abrt-action-save-package-data.c
f6eb96
@@ -20,6 +20,8 @@
f6eb96
 #include "libabrt.h"
f6eb96
 #include "rpm.h"
f6eb96
 
f6eb96
+#define GPG_CONF "gpg_keys.conf"
f6eb96
+
f6eb96
 static bool   settings_bOpenGPGCheck = false;
f6eb96
 static GList *settings_setOpenGPGPublicKeys = NULL;
f6eb96
 static GList *settings_setBlackListedPkgs = NULL;
f6eb96
@@ -79,10 +81,9 @@ static void ParseCommon(map_string_t *settings, const char *conf_filename)
f6eb96
 static void load_gpg_keys(void)
f6eb96
 {
f6eb96
     map_string_t *settings = new_map_string();
f6eb96
-    const char *conf_filename = CONF_DIR"/gpg_keys.conf";
f6eb96
-    if (!load_conf_file(conf_filename, settings, /*skip key w/o values:*/ false))
f6eb96
+    if (!load_abrt_conf_file(GPG_CONF, settings))
f6eb96
     {
f6eb96
-        error_msg("Can't open '%s'", conf_filename);
f6eb96
+        error_msg("Can't load '%s'", GPG_CONF);
f6eb96
         return;
f6eb96
     }
f6eb96
 
f6eb96
@@ -106,8 +107,17 @@ static void load_gpg_keys(void)
f6eb96
 static int load_conf(const char *conf_filename)
f6eb96
 {
f6eb96
     map_string_t *settings = new_map_string();
f6eb96
-    if (!load_conf_file(conf_filename, settings, /*skip key w/o values:*/ false))
f6eb96
-        error_msg("Can't open '%s'", conf_filename);
f6eb96
+    if (conf_filename != NULL)
f6eb96
+    {
f6eb96
+        if (!load_conf_file(conf_filename, settings, false))
f6eb96
+            error_msg("Can't open '%s'", conf_filename);
f6eb96
+    }
f6eb96
+    else
f6eb96
+    {
f6eb96
+        conf_filename = "abrt-action-save-package-data.conf";
f6eb96
+        if (!load_abrt_conf_file(conf_filename, settings))
f6eb96
+            error_msg("Can't load '%s'", conf_filename);
f6eb96
+    }
f6eb96
 
f6eb96
     ParseCommon(settings, conf_filename);
f6eb96
     free_map_string(settings);
f6eb96
@@ -365,7 +375,7 @@ int main(int argc, char **argv)
f6eb96
     abrt_init(argv);
f6eb96
 
f6eb96
     const char *dump_dir_name = ".";
f6eb96
-    const char *conf_filename = CONF_DIR"/abrt-action-save-package-data.conf";
f6eb96
+    const char *conf_filename = NULL;
f6eb96
 
f6eb96
     /* Can't keep these strings/structs static: _() doesn't support that */
f6eb96
     const char *program_usage_string = _(
f6eb96
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
f6eb96
index 567da6a..45ecba4 100644
f6eb96
--- a/src/hooks/Makefile.am
f6eb96
+++ b/src/hooks/Makefile.am
f6eb96
@@ -10,6 +10,9 @@ dist_pluginsconf_DATA = \
f6eb96
     CCpp.conf \
f6eb96
     python.conf
f6eb96
 
f6eb96
+defaultpluginsconfdir = $(DEFAULT_PLUGINS_CONF_DIR)
f6eb96
+dist_defaultpluginsconf_DATA = $(dist_pluginsconf_DATA)
f6eb96
+
f6eb96
 sbin_SCRIPTS = \
f6eb96
     abrt-install-ccpp-hook \
f6eb96
     abrt-harvest-vmcore \
f6eb96
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
f6eb96
index a3f72a7..8e141d4 100644
f6eb96
--- a/src/hooks/abrt-hook-ccpp.c
f6eb96
+++ b/src/hooks/abrt-hook-ccpp.c
f6eb96
@@ -499,7 +499,7 @@ int main(int argc, char** argv)
f6eb96
     bool setting_SaveBinaryImage;
f6eb96
     {
f6eb96
         map_string_t *settings = new_map_string();
f6eb96
-        load_conf_file(PLUGINS_CONF_DIR"/CCpp.conf", settings, /*skip key w/o values:*/ false);
f6eb96
+        load_abrt_plugin_conf_file("CCpp.conf", settings);
f6eb96
         const char *value;
f6eb96
         value = get_map_string_item_or_NULL(settings, "MakeCompatCore");
f6eb96
         setting_MakeCompatCore = value && string_to_bool(value);
f6eb96
diff --git a/src/hooks/abrt_exception_handler.py.in b/src/hooks/abrt_exception_handler.py.in
f6eb96
index 4396178..96a63ff 100644
f6eb96
--- a/src/hooks/abrt_exception_handler.py.in
f6eb96
+++ b/src/hooks/abrt_exception_handler.py.in
f6eb96
@@ -167,23 +167,11 @@ def get_dso_list(tb):
f6eb96
 
f6eb96
 def conf_enabled(var_name):
f6eb96
     try:
f6eb96
-        file = open(@CONF_DIR@ + "/plugins/python.conf", "r")
f6eb96
+        conf = problem.load_plugin_conf_file("python.conf")
f6eb96
     except:
f6eb96
         return -1
f6eb96
-    for line in file:
f6eb96
-        w = line.split("=", 1)  # split on '=' to 2 parts max
f6eb96
-        if len(w) < 2:
f6eb96
-            continue
f6eb96
-        var = w[0].strip()  # remove whitespace
f6eb96
-        if var != var_name:
f6eb96
-            continue
f6eb96
-        val = w[1].strip()  # remove whitespace
f6eb96
-        if val == "yes":
f6eb96
-            return 1
f6eb96
-        if val == "no":
f6eb96
-            return 0
f6eb96
-    file.close()
f6eb96
-    return -1
f6eb96
+    else:
f6eb96
+        conf.get(var_name, -1)
f6eb96
 
f6eb96
 def handleMyException((etype, value, tb)):
f6eb96
     """
f6eb96
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
f6eb96
index 894dd47..25eddb0 100644
f6eb96
--- a/src/hooks/abrt_harvest_vmcore.py.in
f6eb96
+++ b/src/hooks/abrt_harvest_vmcore.py.in
f6eb96
@@ -203,23 +203,21 @@ def harvest_vmcore():
f6eb96
     os.umask(077)
f6eb96
 
f6eb96
     # Check abrt config files for copy/move settings and
f6eb96
-    config = ConfigParser.ConfigParser()
f6eb96
-    # We need to add a root section as ConfigParser doesn't know how to work
f6eb96
-    # with config files without any sections
f6eb96
-    with open('@CONF_DIR@/abrt-harvest-vmcore.conf') as conf_file:
f6eb96
-        conf_str = '[section]\n' + conf_file.read()
f6eb96
-    conf_fp = StringIO.StringIO(conf_str)
f6eb96
-    config.readfp(conf_fp)
f6eb96
-    copyvmcore = config.get('section', 'CopyVMcore')
f6eb96
-    with open('@CONF_DIR@/abrt.conf') as conf_file:
f6eb96
-        conf_str = '[section]\n' + conf_file.read()
f6eb96
-    conf_fp = StringIO.StringIO(conf_str)
f6eb96
-    config = ConfigParser.ConfigParser()
f6eb96
-    config.readfp(conf_fp)
f6eb96
     try:
f6eb96
-        abrtdumpdir = config.get('section', 'DumpLocation')
f6eb96
-    except ConfigParser.NoOptionError:
f6eb96
-        abrtdumpdir = '@DEFAULT_DUMP_LOCATION@'
f6eb96
+        conf = problem.load_conf_file("abrt-harvest-vmcore.conf")
f6eb96
+    except OSError as ex:
f6eb96
+        sys.stderr.write(str(ex))
f6eb96
+        sys.exit(1)
f6eb96
+    else:
f6eb96
+        copyvmcore = conf.get("CopyVMcore", "no")
f6eb96
+
f6eb96
+    try:
f6eb96
+        conf = problem.load_conf_file("abrt.conf")
f6eb96
+    except OSError as ex:
f6eb96
+        sys.stderr.write(str(ex))
f6eb96
+        sys.exit(1)
f6eb96
+    else:
f6eb96
+        abrtdumpdir = conf.get("DumpLocation", "@DEFAULT_DUMP_LOCATION@")
f6eb96
 
f6eb96
     try:
f6eb96
         filelist = os.listdir(dump_dir)
f6eb96
diff --git a/src/include/libabrt.h b/src/include/libabrt.h
f6eb96
index 30399b6..518e989 100644
f6eb96
--- a/src/include/libabrt.h
f6eb96
+++ b/src/include/libabrt.h
f6eb96
@@ -82,6 +82,12 @@ int load_abrt_conf(void);
f6eb96
 #define free_abrt_conf_data abrt_free_abrt_conf_data
f6eb96
 void free_abrt_conf_data(void);
f6eb96
 
f6eb96
+#define load_abrt_conf_file abrt_load_abrt_conf_file
f6eb96
+int load_abrt_conf_file(const char *file, map_string_t *settings);
f6eb96
+
f6eb96
+#define load_abrt_plugin_conf_file abrt_load_abrt_plugin_conf_file
f6eb96
+int load_abrt_plugin_conf_file(const char *file, map_string_t *settings);
f6eb96
+
f6eb96
 
f6eb96
 void migrate_to_xdg_dirs(void);
f6eb96
 
f6eb96
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
f6eb96
index c5a6e2f..8823f01 100644
f6eb96
--- a/src/lib/Makefile.am
f6eb96
+++ b/src/lib/Makefile.am
f6eb96
@@ -23,6 +23,9 @@ libabrt_la_CPPFLAGS = \
f6eb96
     -I$(srcdir)/../lib \
f6eb96
     -DVAR_RUN=\"$(VAR_RUN)\" \
f6eb96
     -DCONF_DIR=\"$(CONF_DIR)\" \
f6eb96
+    -DDEFAULT_CONF_DIR=\"$(DEFAULT_CONF_DIR)\" \
f6eb96
+    -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
f6eb96
+    -DDEFAULT_PLUGINS_CONF_DIR=\"$(DEFAULT_PLUGINS_CONF_DIR)\" \
f6eb96
     -DEVENTS_DIR=\"$(EVENTS_DIR)\" \
f6eb96
     -DDEFAULT_DUMP_LOCATION=\"$(DEFAULT_DUMP_LOCATION)\" \
f6eb96
     $(GLIB_CFLAGS) \
f6eb96
diff --git a/src/lib/abrt_conf.c b/src/lib/abrt_conf.c
f6eb96
index 7230b77..5bb11e9 100644
f6eb96
--- a/src/lib/abrt_conf.c
f6eb96
+++ b/src/lib/abrt_conf.c
f6eb96
@@ -18,6 +18,8 @@
f6eb96
 */
f6eb96
 #include "libabrt.h"
f6eb96
 
f6eb96
+#define ABRT_CONF "abrt.conf"
f6eb96
+
f6eb96
 char *        g_settings_sWatchCrashdumpArchiveDir = NULL;
f6eb96
 unsigned int  g_settings_nMaxCrashReportsSize = 1000;
f6eb96
 char *        g_settings_dump_location = NULL;
f6eb96
@@ -119,11 +121,25 @@ int load_abrt_conf()
f6eb96
     free_abrt_conf_data();
f6eb96
 
f6eb96
     map_string_t *settings = new_map_string();
f6eb96
-    if (!load_conf_file(CONF_DIR"/abrt.conf", settings, /*skip key w/o values:*/ false))
f6eb96
-        perror_msg("Can't open '%s'", CONF_DIR"/abrt.conf");
f6eb96
+    if (!load_abrt_conf_file(ABRT_CONF, settings))
f6eb96
+        perror_msg("Can't load '%s'", ABRT_CONF);
f6eb96
 
f6eb96
-    ParseCommon(settings, CONF_DIR"/abrt.conf");
f6eb96
+    ParseCommon(settings, ABRT_CONF);
f6eb96
     free_map_string(settings);
f6eb96
 
f6eb96
     return 0;
f6eb96
 }
f6eb96
+
f6eb96
+int load_abrt_conf_file(const char *file, map_string_t *settings)
f6eb96
+{
f6eb96
+    static const char *const base_directories[] = { DEFAULT_CONF_DIR, CONF_DIR, NULL };
f6eb96
+
f6eb96
+    return load_conf_file_from_dirs(file, base_directories, settings, /*skip key w/o values:*/ false);
f6eb96
+}
f6eb96
+
f6eb96
+int load_abrt_plugin_conf_file(const char *file, map_string_t *settings)
f6eb96
+{
f6eb96
+    static const char *const base_directories[] = { DEFAULT_PLUGINS_CONF_DIR, PLUGINS_CONF_DIR, NULL };
f6eb96
+
f6eb96
+    return load_conf_file_from_dirs(file, base_directories, settings, /*skip key w/o values:*/ false);
f6eb96
+}
f6eb96
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
f6eb96
index 370d5fd..60246f2 100644
f6eb96
--- a/src/plugins/Makefile.am
f6eb96
+++ b/src/plugins/Makefile.am
f6eb96
@@ -96,9 +96,11 @@ EXTRA_DIST = \
f6eb96
     post_report.xml.in \
f6eb96
     abrt-action-analyze-ccpp-local
f6eb96
 
f6eb96
-confdir = $(CONF_DIR)
f6eb96
+confdir = $(PLUGINS_CONF_DIR)
f6eb96
 dist_conf_DATA = \
f6eb96
     xorg.conf
f6eb96
+defaultconfdir = $(DEFAULT_PLUGINS_CONF_DIR)
f6eb96
+dist_defaultconf_DATA = $(dist_conf_DATA)
f6eb96
 
f6eb96
 abrt_watch_log_SOURCES = \
f6eb96
     abrt-watch-log.c
f6eb96
diff --git a/src/plugins/abrt-action-analyze-xorg.c b/src/plugins/abrt-action-analyze-xorg.c
f6eb96
index 5cf6d1e..5d11830 100644
f6eb96
--- a/src/plugins/abrt-action-analyze-xorg.c
f6eb96
+++ b/src/plugins/abrt-action-analyze-xorg.c
f6eb96
@@ -19,6 +19,8 @@
f6eb96
 #include <paths.h>
f6eb96
 #include "libabrt.h"
f6eb96
 
f6eb96
+#define XORG_CONF "xorg.conf"
f6eb96
+
f6eb96
 static
f6eb96
 void trim_spaces(char *str)
f6eb96
 {
f6eb96
@@ -87,9 +89,9 @@ int main(int argc, char **argv)
f6eb96
     export_abrt_envvars(0);
f6eb96
 
f6eb96
     map_string_t *settings = new_map_string();
f6eb96
-    VERB1 log("Loading settings from '%s'", "/etc/abrt/xorg.conf");
f6eb96
-    load_conf_file("/etc/abrt/xorg.conf", settings, /*skip key w/o values:*/ false);
f6eb96
-    VERB3 log("Loaded '%s'", "/etc/abrt/xorg.conf");
f6eb96
+    VERB1 log("Loading settings from '%s'", XORG_CONF);
f6eb96
+    load_abrt_plugin_conf_file(XORG_CONF, settings);
f6eb96
+    VERB3 log("Loaded '%s'", XORG_CONF);
f6eb96
     char *BlacklistedXorgModules = xstrdup(get_map_string_item_or_empty(settings, "BlacklistedXorgModules"));
f6eb96
     trim_spaces(BlacklistedXorgModules);
f6eb96
     free_map_string(settings);
f6eb96
diff --git a/src/plugins/abrt-action-generate-backtrace.c b/src/plugins/abrt-action-generate-backtrace.c
f6eb96
index 5612a1c..30ce446 100644
f6eb96
--- a/src/plugins/abrt-action-generate-backtrace.c
f6eb96
+++ b/src/plugins/abrt-action-generate-backtrace.c
f6eb96
@@ -18,6 +18,7 @@
f6eb96
 */
f6eb96
 #include "libabrt.h"
f6eb96
 
f6eb96
+#define CCPP_CONF "CCpp.conf"
f6eb96
 
f6eb96
 static const char *dump_dir_name = ".";
f6eb96
 /* 60 seconds was too limiting on slow machines */
f6eb96
@@ -61,8 +62,8 @@ int main(int argc, char **argv)
f6eb96
     export_abrt_envvars(0);
f6eb96
 
f6eb96
     map_string_t *settings = new_map_string();
f6eb96
-    if (!load_conf_file(PLUGINS_CONF_DIR"/CCpp.conf", settings, /*skip key w/o values:*/ false))
f6eb96
-        error_msg("Can't open '%s'", PLUGINS_CONF_DIR"/CCpp.conf");
f6eb96
+    if (!load_abrt_plugin_conf_file(CCPP_CONF, settings))
f6eb96
+        error_msg("Can't load '%s'", CCPP_CONF);
f6eb96
 
f6eb96
     const char *value = get_map_string_item_or_NULL(settings, "DebuginfoLocation");
f6eb96
     char *debuginfo_location;
f6eb96
diff --git a/src/plugins/abrt-action-install-debuginfo.in b/src/plugins/abrt-action-install-debuginfo.in
f6eb96
index b734796..5fd3110 100644
f6eb96
--- a/src/plugins/abrt-action-install-debuginfo.in
f6eb96
+++ b/src/plugins/abrt-action-install-debuginfo.in
f6eb96
@@ -14,6 +14,7 @@ from subprocess import Popen, PIPE
f6eb96
 from reportclient import _, verbose, log, log1, log2, set_verbosity, error_msg_and_die, error_msg
f6eb96
 import time
f6eb96
 from reportclient.debuginfo import DebugInfoDownload, filter_installed_debuginfos, build_ids_to_path, clean_up
f6eb96
+import problem
f6eb96
 
f6eb96
 # everything was ok
f6eb96
 RETURN_OK = 0
f6eb96
@@ -144,20 +145,11 @@ if __name__ == "__main__":
f6eb96
 
f6eb96
     if not cachedirs:
f6eb96
         try:
f6eb96
-            fp = open("@sysconfdir@/@PACKAGE_NAME@/plugins/CCpp.conf", "r")
f6eb96
-            for line in fp:
f6eb96
-                stripped = line.lstrip()
f6eb96
-                if len(stripped) == 0:
f6eb96
-                    continue
f6eb96
-                if stripped[0] == "#":
f6eb96
-                    continue
f6eb96
-                if stripped[:len("DebuginfoLocation")] != "DebuginfoLocation":
f6eb96
-                    continue
f6eb96
-
f6eb96
-                cachedirs =  stripped[len("DebuginfoLocation"):].strip(" =\n").split(":")
f6eb96
-            fp.close()
f6eb96
-        except IOError as (errno, strerror):
f6eb96
-            print "I/O error({0}): {1}".format(errno, strerror)
f6eb96
+            conf = problem.load_plugin_conf_file("CCpp.conf")
f6eb96
+        except OSError as ex:
f6eb96
+            print str(ex)
f6eb96
+        else:
f6eb96
+            cachedirs = conf.get("DebuginfoLocation", None)
f6eb96
 
f6eb96
         if not cachedirs:
f6eb96
             cachedirs = ["/var/cache/abrt-di"]
f6eb96
diff --git a/src/python-problem/problem/common.h b/src/python-problem/problem/common.h
f6eb96
index ef323a5..2dd06c7 100644
f6eb96
--- a/src/python-problem/problem/common.h
f6eb96
+++ b/src/python-problem/problem/common.h
f6eb96
@@ -20,3 +20,5 @@
f6eb96
 
f6eb96
 /* module-level functions */
f6eb96
 PyObject *p_notify_new_path(PyObject *pself, PyObject *args);
f6eb96
+PyObject *p_load_conf_file(PyObject *pself, PyObject *args);
f6eb96
+PyObject *p_load_plugin_conf_file(PyObject *pself, PyObject *args);
f6eb96
diff --git a/src/python-problem/problem/pyabrt.c b/src/python-problem/problem/pyabrt.c
f6eb96
index 16621d3..16d455f 100644
f6eb96
--- a/src/python-problem/problem/pyabrt.c
f6eb96
+++ b/src/python-problem/problem/pyabrt.c
f6eb96
@@ -32,3 +32,62 @@ PyObject *p_notify_new_path(PyObject *pself, PyObject *args)
f6eb96
     notify_new_path(path);
f6eb96
     Py_RETURN_NONE;
f6eb96
 }
f6eb96
+
f6eb96
+static PyObject *
f6eb96
+load_settings_to_dict(const char *file, int (*loader)(const char *, map_string_t *))
f6eb96
+{
f6eb96
+    PyObject *dict = NULL;
f6eb96
+    map_string_t *settings = new_map_string();
f6eb96
+    if (!loader(file, settings))
f6eb96
+    {
f6eb96
+        PyErr_SetString(PyExc_OSError, "Failed to load configuration file.");
f6eb96
+        goto lacf_error;
f6eb96
+    }
f6eb96
+
f6eb96
+    dict = PyDict_New();
f6eb96
+    if (dict == NULL)
f6eb96
+    {
f6eb96
+        goto lacf_error;
f6eb96
+    }
f6eb96
+
f6eb96
+    map_string_iter_t iter;
f6eb96
+    const char *key = NULL;
f6eb96
+    const char *value = NULL;
f6eb96
+    init_map_string_iter(&iter, settings);
f6eb96
+    while(next_map_string_iter(&iter, &key, &value))
f6eb96
+    {
f6eb96
+        if (0 != PyDict_SetItemString(dict, key, PyString_FromString(value)))
f6eb96
+        {
f6eb96
+            goto lacf_error;
f6eb96
+        }
f6eb96
+    }
f6eb96
+    free_map_string(settings);
f6eb96
+    return dict;
f6eb96
+
f6eb96
+lacf_error:
f6eb96
+    Py_XDECREF(dict);
f6eb96
+    free_map_string(settings);
f6eb96
+    return NULL;
f6eb96
+}
f6eb96
+
f6eb96
+/* C: void load_abrt_conf_file(const char *file, map_string_t *settings); */
f6eb96
+PyObject *p_load_conf_file(PyObject *pself, PyObject *args)
f6eb96
+{
f6eb96
+    const char *file;
f6eb96
+    if (!PyArg_ParseTuple(args, "s", &file))
f6eb96
+    {
f6eb96
+        return NULL;
f6eb96
+    }
f6eb96
+    return load_settings_to_dict(file, load_abrt_conf_file);
f6eb96
+}
f6eb96
+
f6eb96
+/* C: void load_abrt_plugin_conf_file(const char *file, map_string_t *settings); */
f6eb96
+PyObject *p_load_plugin_conf_file(PyObject *pself, PyObject *args)
f6eb96
+{
f6eb96
+    const char *file;
f6eb96
+    if (!PyArg_ParseTuple(args, "s", &file))
f6eb96
+    {
f6eb96
+        return NULL;
f6eb96
+    }
f6eb96
+    return load_settings_to_dict(file, load_abrt_plugin_conf_file);
f6eb96
+}
f6eb96
diff --git a/src/python-problem/problem/pyabrtmodule.c b/src/python-problem/problem/pyabrtmodule.c
f6eb96
index 7ff58b3..e31d8b4 100644
f6eb96
--- a/src/python-problem/problem/pyabrtmodule.c
f6eb96
+++ b/src/python-problem/problem/pyabrtmodule.c
f6eb96
@@ -24,6 +24,8 @@ static PyMethodDef module_methods[] = {
f6eb96
     /* method_name, func, flags, doc_string */
f6eb96
     /* for include/client.h */
f6eb96
     { "notify_new_path"           , p_notify_new_path         , METH_VARARGS },
f6eb96
+    { "load_conf_file"            , p_load_conf_file          , METH_VARARGS },
f6eb96
+    { "load_plugin_conf_file"     , p_load_plugin_conf_file   , METH_VARARGS },
f6eb96
     { NULL }
f6eb96
 };
f6eb96
 
f6eb96
-- 
f6eb96
1.8.3.1
f6eb96