Blob Blame Raw
From 80f063738ec40e2f6354e4f58b2d59a53d33eeb4 Mon Sep 17 00:00:00 2001
From: Julius Milan <jmilan@redhat.com>
Date: Tue, 5 Dec 2017 17:16:54 +0100
Subject: [PATCH 05/22] reporter-mantisbt: read configuration from user's home

mantisbt.conf can be placed also in $HOME/.config/libreport/mantisbt.conf
for security reasons
---
 src/plugins/centos_report_event.conf | 4 ----
 src/plugins/mantisbt.conf            | 4 ++++
 src/plugins/reporter-mantisbt.c      | 7 +++++++
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/plugins/centos_report_event.conf b/src/plugins/centos_report_event.conf
index 8cf2a502..eb634b91 100644
--- a/src/plugins/centos_report_event.conf
+++ b/src/plugins/centos_report_event.conf
@@ -10,14 +10,12 @@ EVENT=report_CentOSBugTracker type=vmcore
 EVENT=report_CentOSBugTracker type=Python component!=anaconda
         test -f component || abrt-action-save-package-data
         reporter-mantisbt \
-                -c /etc/libreport/plugins/mantisbt.conf \
                 -F /etc/libreport/plugins/mantisbt_format.conf \
                 -A /etc/libreport/plugins/mantisbt_formatdup.conf
 
 EVENT=report_CentOSBugTracker type=Python3 component!=anaconda
         test -f component || abrt-action-save-package-data
         reporter-mantisbt \
-                -c /etc/libreport/plugins/mantisbt.conf \
                 -F /etc/libreport/plugins/mantisbt_format.conf \
                 -A /etc/libreport/plugins/mantisbt_formatdup.conf
 
@@ -31,12 +29,10 @@ EVENT=report_CentOSBugTracker type=CCpp duphash!=
         test -f "/etc/libreport/plugins/mantisbt_formatdup_$component.conf" \
                 && formatdup="mantisbt_formatdup_$component.conf"
         reporter-mantisbt \
-                -c /etc/libreport/plugins/mantisbt.conf \
                 -F "/etc/libreport/plugins/$format" \
                 -A "/etc/libreport/plugins/$formatdup"
 
 EVENT=report_CentOSBugTracker analyzer=libreport
     reporter-mantisbt \
-        -c /etc/libreport/plugins/mantisbt.conf \
         -F /etc/libreport/plugins/mantisbt_format_analyzer_libreport.conf \
         -A /etc/libreport/plugins/mantisbt_formatdup_analyzer_libreport.conf
diff --git a/src/plugins/mantisbt.conf b/src/plugins/mantisbt.conf
index 025b9101..24f7f48e 100644
--- a/src/plugins/mantisbt.conf
+++ b/src/plugins/mantisbt.conf
@@ -1,3 +1,7 @@
+# NOTE this file is readable by everyone, do NOT store here sensitive data,
+# for such cases should be used config file in user's home,
+# i.e.: $HOME/.config/libreport/mantisbt.conf
+
 # MantisBT URL
 MantisbtURL = http://localhost/mantisbt/
 # yes means that ssl certificates will be checked
diff --git a/src/plugins/reporter-mantisbt.c b/src/plugins/reporter-mantisbt.c
index e8afa7db..bef7a45e 100644
--- a/src/plugins/reporter-mantisbt.c
+++ b/src/plugins/reporter-mantisbt.c
@@ -244,9 +244,11 @@ int main(int argc, char **argv)
         "\nfiled. The default value is 'ABRT Server'"
         "\n"
         "\nIf not specified, CONFFILE defaults to "CONF_DIR"/plugins/mantisbt.conf"
+        "\nand user's local ~"USER_HOME_CONFIG_PATH"/mantisbt.conf."
         "\nIts lines should have 'PARAM = VALUE' format."
         "\nRecognized string parameters: MantisbtURL, Login, Password, Project, ProjectVersion."
         "\nRecognized boolean parameter (VALUE should be 1/0, yes/no): SSLVerify, CreatePrivate."
+        "\nUser's local configuration overrides the system wide configuration."
         "\nParameters can be overridden via $Mantisbt_PARAM environment variables."
         "\n"
         "\nFMTFILE default to "CONF_DIR"/plugins/mantisbt_format.conf."
@@ -300,7 +302,12 @@ int main(int argc, char **argv)
 
     {
         if (!conf_file)
+        {
             conf_file = g_list_append(conf_file, (char*) CONF_DIR"/plugins/mantisbt.conf");
+            char *local_conf = xasprintf("%s"USER_HOME_CONFIG_PATH"/mantisbt.conf", getenv("HOME"));
+            conf_file = g_list_append(conf_file, local_conf);
+            free(local_conf);
+        }
         while (conf_file)
         {
             char *fn = (char *)conf_file->data;
-- 
2.14.3