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

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