Bug 1303422

Summary: satellite sync hard coded email FROM does not allow customization for email addresses
Product: Red Hat Satellite 5 Reporter: Shannon Hughes <shughes>
Component: Satellite SynchronizationAssignee: Grant Gainey <ggainey>
Status: CLOSED CURRENTRELEASE QA Contact: Martin Korbel <mkorbel>
Severity: medium Docs Contact:
Priority: medium    
Version: 580CC: dyordano, ggainey, mkorbel, mmello, pghadge, shughes, tlestach, xdmoon
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-06-21 12:17:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1358815    
Attachments:
Description Flags
patch to add default_mail_from support to satsync
none
sat sync patch for default mail none

Description Shannon Hughes 2016-01-31 16:04:43 UTC
Description of problem:

satellite-sync currently does not support a default_mail_from address similar to the webui. rather the address is hard coded to root@host which can produce issues for customers when the server uses a short name and mail relays require fqdn. A patch will be included for review to use a config variable, default_mail_from, in the satellite.server CFG namespace to overcome this issue.

Comment 1 Shannon Hughes 2016-01-31 16:32:07 UTC
Created attachment 1119915 [details]
patch to add default_mail_from support to satsync

Comment 2 Grant Gainey 2016-02-02 12:55:17 UTC
In the attached patch, if parseaddr fails, then sndr ends up as ''. Can we instead notice this, log an error, and default back to root@host_label? Otherwise, the emails arrive with no From line, and it makes it much harder for the customer to figure out what machine has a cfg-problem.

Comment 3 Shannon Hughes 2016-02-02 15:36:37 UTC
Grant, I'll take a look when I am back in the office but good catch. Will fix it up.

Comment 4 Shannon Hughes 2016-02-03 19:13:40 UTC
Created attachment 1120892 [details]
sat sync patch for default mail

this patch removes the need for the parse address lib

Comment 5 Shannon Hughes 2016-02-03 19:17:12 UTC
test plan: 

1) modify rhn.conf and break the sat sync by modifying parent with a bogus name
server.satellite.rhn_parent = ssatellite.rhn.redhat.com

2) Add a new config var for the default email address for satellite.server namespace in rhn.conf

server.satellite.default_mail_from = user@fqdn

3) run satsync with email option, tail the /var/log/maillog file

satellite-sync -l --email

4) confirm mail from address shows up in /var/log/maillog

5) now comment out the server.satellite.default_mail_from config var. rerun sat sync. Confirm the mail from address is now root@hostname in /var/log/maillog

Comment 6 Grant Gainey 2016-02-19 19:38:18 UTC
spacewalk.github c6369d1f57b352e49b116e677f5d2fbc5831d703

NOTE: use the included patch when applying to Satellite, the pune-to-puny namechange will get in the way of cherry-picking the SW commit

Comment 13 Tomas Lestach 2016-04-06 08:18:11 UTC
The patch can be found here - 
https://github.com/spacewalkproject/spacewalk/commit/c6369d1f57b352e49b116e677f5d2fbc5831d703
But according to Comment 6, there may be more changes needed.

Comment 15 Martin Korbel 2017-06-01 11:34:28 UTC
VERIFIED on spacewalk-backend-2.5.3-137  (SAT5.8_20170529)

Reproducer:
1. Add "default_mail_from" into rhn.conf
 > echo "server.satellite.default_mail_from = tester" >> /etc/rhn/rhn.conf
2. Sync some channel
 >  cdn-sync -c rhn-tools-rhel-x86_64-server-5  --email
3. Check mailbox
 > mail
  ...
  N 11 tester    Thu Jun  1 07:28 661/46162 "CDN sync. report from host-8-179-109.host.centralc"