Bug 1862739

Summary: dnf-automatic command_email example will not work
Product: [Fedora] Fedora Reporter: Jason Montleon <jmontleo>
Component: dnfAssignee: amatej
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 32CC: amatej, dmach, ernelson, jmracek, jrohel, mblaha, mhatina, packaging-team-maint, pkratoch, rhel, rpm-software-management, vmukhame
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-4.4.2-1.fc33 dnf-4.4.2-1.fc32 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-29 01:25:47 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:

Description Jason Montleon 2020-08-02 00:51:56 UTC
Description of problem:
/etc/dnf/automatic.conf has a command_email command_format example as follows:
# command_format = "mail -s {subject} -r {email_from} {email_to}"

This will not ever work with systemd. All you'll see is ". . . message not sent" in the dnf-automatic service status and no email will be delivered. The reason for this is that mailx will fork, dnf-automatic will exit, and systemd will kill the mail process. 

Version-Release number of selected component (if applicable):
dnf-automatic-4.2.23-1.fc32.noarch

How reproducible:
Always. I helped someone debug this and for both of us it failed to send an email every single time. I added -v to mailx and suddenly it worked. What I learned is that -v prevents mailx from forking. To do this without verbose output you can use the `-Ssendwait` option.

Steps to Reproduce:
1. Install dnf-automatic
2. Configure it to use the command_email emitter
3. Enable dnf-automatic-install.timer


Actual results:
Email never comes. If you look at the dnf-automatic-install.service logs you'll see '... message not sent'

Expected results:
Email is delivered as expected.

Additional info:
The default command and example in automatic.conf should be
command_format = "mail -Ssendwait -s {subject} -r {email_from} {email_to}"

Comment 1 Jason Montleon 2020-08-02 00:55:17 UTC
Arch wiki describes this problem as well here: https://wiki.archlinux.org/index.php/Systemd/Timers#MAILTO

Comment 2 Jason Montleon 2020-08-02 14:06:33 UTC
PR: https://github.com/rpm-software-management/dnf/pull/1646

Comment 3 amatej 2020-08-04 08:52:37 UTC
The PR was merged, thanks again for the report and fix.

Comment 4 Fedora Update System 2020-11-27 15:45:45 UTC
FEDORA-2020-210ee4a384 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-210ee4a384

Comment 5 Fedora Update System 2020-11-27 15:47:26 UTC
FEDORA-2020-e49210967b has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-e49210967b

Comment 6 Fedora Update System 2020-11-28 02:55:57 UTC
FEDORA-2020-210ee4a384 has been pushed to the Fedora 33 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-210ee4a384`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-210ee4a384

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 7 Fedora Update System 2020-11-28 03:04:31 UTC
FEDORA-2020-e49210967b has been pushed to the Fedora 32 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-e49210967b`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-e49210967b

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 8 Fedora Update System 2020-11-29 01:25:47 UTC
FEDORA-2020-210ee4a384 has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 9 Fedora Update System 2021-01-11 01:49:57 UTC
FEDORA-2020-e49210967b has been pushed to the Fedora 32 stable repository.
If problem still persists, please make note of it in this bug report.