Blame SOURCES/0068-ureport-attach-contact-email-if-configured.patch

06486d
From 715a047ada1ca9f9420e194306c5b0fe01b5c9f1 Mon Sep 17 00:00:00 2001
06486d
From: Jakub Filak <jfilak@redhat.com>
06486d
Date: Thu, 9 Oct 2014 10:24:42 +0200
06486d
Subject: [ABRT PATCH 68/68] ureport: attach contact email if configured
06486d
06486d
Resolves #1150389
06486d
06486d
Signed-off-by: Jakub Filak <jfilak@redhat.com>
06486d
---
06486d
 src/plugins/abrt-action-ureport | 37 ++++++++++++++++++++++++++++++++++---
06486d
 1 file changed, 34 insertions(+), 3 deletions(-)
06486d
06486d
diff --git a/src/plugins/abrt-action-ureport b/src/plugins/abrt-action-ureport
06486d
index e38a92c..48bebef 100755
06486d
--- a/src/plugins/abrt-action-ureport
06486d
+++ b/src/plugins/abrt-action-ureport
06486d
@@ -8,6 +8,7 @@
06486d
 import sys
06486d
 import os
06486d
 import getopt
06486d
+import augeas
06486d
 
06486d
 from report import dd_opendir, DD_FAIL_QUIETLY_ENOENT
06486d
 from reportclient import set_verbosity, error_msg_and_die, error_msg, log1, log
06486d
@@ -32,12 +33,31 @@ def init_gettext():
06486d
     gettext.bindtextdomain(GETTEXT_PROGNAME, '/usr/share/locale')
06486d
     gettext.textdomain(GETTEXT_PROGNAME)
06486d
 
06486d
-def spawn_and_wait(prog):
06486d
+
06486d
+def get_augeas(module, file_path):
06486d
+    """
06486d
+    A function for efficient configuration of Augeas.
06486d
+    Augeas modules are placed in /usr/share/augeas/lenses/dist
06486d
+    """
06486d
+
06486d
+    aug_obj = augeas.Augeas(flags=augeas.Augeas.NO_MODL_AUTOLOAD)
06486d
+    aug_obj.set("/augeas/load/{0}/lens".format(module), "{0}.lns".format(module))
06486d
+    aug_obj.set("/augeas/load/{0}/incl".format(module), file_path)
06486d
+    aug_obj.load()
06486d
+    return aug_obj
06486d
+
06486d
+
06486d
+def spawn_and_wait(prog, args=None):
06486d
+    if args is None:
06486d
+        args = [prog]
06486d
+    else:
06486d
+        args.insert(0, prog)
06486d
+
06486d
     try:
06486d
-        return os.spawnlp(os.P_WAIT, prog, prog)
06486d
+         return os.spawnvpe(os.P_WAIT, prog, args, os.environ)
06486d
     except OSError as err:
06486d
         error_msg(_("Unable to start '%s', error message was: '%s'"),
06486d
-                    prog, err)
06486d
+                    " ".join(args), err)
06486d
         return -1
06486d
 
06486d
 def try_parse_number(dd, filename):
06486d
@@ -78,6 +98,7 @@ if __name__ == "__main__":
06486d
             verbose += 1
06486d
 
06486d
     set_verbosity(verbose)
06486d
+    os.environ["ABRT_VERBOSE"] = str(verbose)
06486d
 
06486d
     # getcwd might fail if cwd was deleted
06486d
     try:
06486d
@@ -140,6 +161,16 @@ if __name__ == "__main__":
06486d
             sys.exit(1)
06486d
         dd.save_text("ureports_counter", str(ureports_counter + 1))
06486d
         dd.close()
06486d
+
06486d
+        email = os.getenv("uReport_ContactEmail")
06486d
+        if not email:
06486d
+            augeas = get_augeas("libreport", "/etc/libreport/plugins/ureport.conf")
06486d
+            email = augeas.get("/files/etc/libreport/plugins/ureport.conf/ContactEmail")
06486d
+
06486d
+        if email:
06486d
+            log1("Attaching ContactEmail: " + email)
06486d
+            spawn_and_wait("reporter-ureport", ["-A", "-E"])
06486d
+
06486d
         sys.exit(exitcode)
06486d
     else:
06486d
         error_msg_and_die(_("reporter-ureport failed with exit code %d" % exitcode))
06486d
-- 
06486d
1.8.3.1
06486d