Bug 1279773 - /etc/dnf/automatic.conf emit email assumes smtp service
Summary: /etc/dnf/automatic.conf emit email assumes smtp service
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 24
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ---
Assignee: Jaroslav Rohel
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-11-10 09:29 UTC by Kai Hendry
Modified: 2019-01-03 20:58 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-07-12 12:31:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Kai Hendry 2015-11-10 09:29:21 UTC
Description of problem: I have configured sendmail to send email from my VPS. I don't run a SMTP daemon on my host or on the private network.


Version-Release number of selected component (if applicable):
Version     : 1.1.3
Release     : 1.fc23


How reproducible: Everytime


Steps to Reproduce:
1. emit_via = email
2. fails to send since it cannot open a socket
3.

Actual results: Fails to send email


Expected results: Sends email via sendmail


Additional info:

Comment 1 Jaroslav Mracek 2015-11-18 13:39:19 UTC
You have to setup SMTP server, otherwise the program itself cannot detect IP address of machine that provides mail services that mean to listen on certain port for emails and redistribute them.

Comment 2 Kai Hendry 2015-11-19 00:33:25 UTC
Why don't you just use the system's /usr/bin/sendmail? You've made dnf-automatic really hard to setup if you want email copies of upgrades. :(

Comment 3 Michael Mráka 2015-11-19 09:36:13 UTC
I agree emails should be sent by invoking sendmail locally rather than via connecting to local SMTP daemon (i.e. depending on running sendmail/postfix in daemon mode).

Example of using local sendmail is
http://stackoverflow.com/questions/73781/sending-mail-via-sendmail-from-python

Comment 4 GuL 2016-06-15 09:17:21 UTC
Hi all,
Here is some complementary information :

With the following configuration in /etc/dnf/automatic.conf

emit_via = email,stdio
[email]
email_from = root
email_to = root
email_host = localhost

dnf-automatic is failing with the following result  :

# dnf-automatic
Les paquets téléchargés ont été enregistrés dans le cache jusqu'à la prochaine transaction réussie.
Vous pouvez supprimer les paquets en cache en exécutant « dnf clean packages ».
Traceback (most recent call last):
  File "/usr/bin/dnf-automatic", line 32, in <module>
    sys.exit(dnf.automatic.main.main(sys.argv[1:]))
  File "/usr/lib/python3.4/site-packages/dnf/automatic/main.py", line 163, in main
    emitters.commit()
  File "/usr/lib/python3.4/site-packages/dnf/util.py", line 331, in fn
    return list(map(call_what, self))
  File "/usr/lib/python3.4/site-packages/dnf/util.py", line 330, in call_what
    return method(*args, **kwargs)
  File "/usr/lib/python3.4/site-packages/dnf/automatic/emitter.py", line 99, in commit
    smtp = smtplib.SMTP(self._conf.email_host)
  File "/usr/lib64/python3.4/smtplib.py", line 242, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib64/python3.4/smtplib.py", line 321, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib64/python3.4/smtplib.py", line 292, in _get_socket
    self.source_address)
  File "/usr/lib64/python3.4/socket.py", line 512, in create_connection
    raise err
  File "/usr/lib64/python3.4/socket.py", line 503, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

I am using ssmtp as mta and it is working fine for instance with fail2ban.

Jaroslav Mracek said "You have to setup SMTP server, otherwise the program itself cannot detect IP address of machine that provides mail services that mean to listen on certain port for emails and redistribute them."

However ssmtp has no running service, so IT IS A BUG, as dnf-automatic should be using /usr/bin/sendmail and not trying to connect to a smtp server.

Nevertheless, it should be noted that emails can be sent with the following configuration, bypassing ssmtp, and connecting directly to an external smtp server :

emit_via = email,stdio
[email]
email_from = xxx
email_to = xxx
email_host = smtp.yyy.fr

However, in this case, it is not possible to configure smtp server using starttls, or at least it is not explained in the documentation. That means that encrypted updates sensible data are sent, which is definitely a security issue.

Many thanks for your help.

Comment 5 Fedora Admin XMLRPC Client 2016-07-08 09:39:45 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 6 Gerald Cox 2016-10-08 14:30:46 UTC
I thought I would try out the automatic functionality and was also hit by this issue.  I use esmtp to send mail to gmail for email notifications of services - which as mentioned in comment 4 works that methodology works fine with fail2ban.  So +1 this is a bug and should be fixed.  That said, I continue to be impressed and grateful for the work the DNF team is doing.  Changing the version of this to F24.

Comment 7 Jaroslav Rohel 2017-07-12 12:31:46 UTC
> emit email assumes smtp service
Yes exactly. This is how "emit_via = email" works. 
"emit_via = email" use only if you want to sent message throught SMTP

If you want to sent email by command then use "emit_via = command_email".

I found problems during testig "emit_via = command_email". 
https://bugzilla.redhat.com/show_bug.cgi?id=1470116
But this is another story.

Comment 8 basilicum 2018-10-27 10:23:14 UTC
(In reply to Jaroslav Rohel from comment #7)
> > emit email assumes smtp service
> Yes exactly. This is how "emit_via = email" works. 
> "emit_via = email" use only if you want to sent message throught SMTP
> 
> If you want to sent email by command then use "emit_via = command_email".
> 
> I found problems during testig "emit_via = command_email". 
> https://bugzilla.redhat.com/show_bug.cgi?id=1470116
> But this is another story.

HI Jaroslav,
Could you please explain how to configure the command_email ?
What other parameters should be valued by what ?
On my box (fedore 29) I have set up "linux mail" to work, i.e. the command "mail"on the command line works, is that sufficient ?

Thanks,

Comment 9 Steven Miano 2019-01-03 20:58:19 UTC
Came across this via searching for mail emit dnf automatic.

The configuration file comments, and man page for dnf-automatic only lists three options for the emit:

       emit_via
              list, default: email, stdio, motd

              List of emitters to report the results through. Available emitters are stdio to print the result to standard  output,
              command to send the result to a custom command, command_email to send an email using a command, and email to send the
              report via email and motd sends the result to /etc/motd file.

The options for emit_via are buried in there, and at a cursory glance folks are going to think: email, stdio, motd are the options (not reading and seeing command, command_email are also valid options).

Not sure if this needs to be fixed/corrected or clarified, but the ambiguity is real.


Note You need to log in before you can comment on or make changes to this bug.