Blame SOURCES/BZ-1330670-system-name-email-from-cron.patch

5e9bef
commit 8bc82519a96a26025afcfdb05e5624739440b21c
5e9bef
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
5e9bef
Date:   Thu Jun 30 17:13:47 2016 +0200
5e9bef
5e9bef
    yum-cron: replace 'localhost' with system_name value in email_from. BZ 1330670
5e9bef
5e9bef
diff --git a/etc/yum-cron-hourly.conf b/etc/yum-cron-hourly.conf
5e9bef
index 63c0bb6..5265d03 100644
5e9bef
--- a/etc/yum-cron-hourly.conf
5e9bef
+++ b/etc/yum-cron-hourly.conf
5e9bef
@@ -47,6 +47,7 @@ output_width = 80
5e9bef
 
5e9bef
 [email]
5e9bef
 # The address to send email messages from.
5e9bef
+# NOTE: 'localhost' will be replaced with the value of system_name.
5e9bef
 email_from = root
5e9bef
 
5e9bef
 # List of addresses to send messages to.
5e9bef
diff --git a/etc/yum-cron.conf b/etc/yum-cron.conf
5e9bef
index 7ab4d04..6a3d5ca 100644
5e9bef
--- a/etc/yum-cron.conf
5e9bef
+++ b/etc/yum-cron.conf
5e9bef
@@ -49,6 +49,7 @@ output_width = 80
5e9bef
 
5e9bef
 [email]
5e9bef
 # The address to send email messages from.
5e9bef
+# NOTE: 'localhost' will be replaced with the value of system_name.
5e9bef
 email_from = root@localhost
5e9bef
 
5e9bef
 # List of addresses to send messages to.
5e9bef
diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
5e9bef
index 12c7720..23f36d3 100755
5e9bef
--- a/yum-cron/yum-cron.py
5e9bef
+++ b/yum-cron/yum-cron.py
5e9bef
@@ -236,7 +236,10 @@ class EmailEmitter(UpdateEmitter):
5e9bef
             charset = 'us-ascii'
5e9bef
         msg = MIMEText(output, 'plain', charset)
5e9bef
         msg['Subject'] = self.subject
5e9bef
-        msg['From'] = self.opts.email_from
5e9bef
+        username, at, domain = self.opts.email_from.rpartition('@')
5e9bef
+        if domain == 'localhost':
5e9bef
+            domain = self.opts.system_name
5e9bef
+        msg['From'] = '%s@%s' % (username, domain)
5e9bef
         msg['To'] = ",".join(self.opts.email_to)
5e9bef
 
5e9bef
         # Send the email