Bug#412914: reportbug: please add support for SSL protected SMTP communication
Package: reportbug
Version: 7.6.0
Followup-For: Bug #412914
Hello. I also missing to ability to communicate with my server, so I
made a small patch to clarify (TLS vs STARTTLS) and add option to use
TLS on port 465. I didn't tested it yet, since in my code I just
replaced SMTP to SMTP_SSL, but should work. Feel free to test with gmail
or different 465 only provider.
-- Package-specific info:
** Environment settings:
EDITOR="/usr/bin/nvim"
PAGER="/usr/bin/less"
INTERFACE="text"
** /root/.reportbugrc:
reportbug_version "7.6.0"
mode advanced
ui text
no-check-uid
-- System Information:
Debian Release: 10.2
APT prefers testing
APT policy: (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect
Versions of packages reportbug depends on:
ii apt 1.8.2
ii python3 3.7.3-1
ii python3-reportbug 7.6.0
ii sensible-utils 0.0.12
reportbug recommends no packages.
Versions of packages reportbug suggests:
pn claws-mail <none>
pn debconf-utils <none>
pn debsums <none>
pn dlocate <none>
pn emacs-bin-common <none>
ii exim4-daemon-light [mail-transport-agent] 4.92-8+deb10u3
ii file 1:5.35-4+deb10u1
ii gnupg 2.2.12-1+deb10u1
pn python3-urwid <none>
pn reportbug-gtk <none>
pn xdg-utils <none>
Versions of packages python3-reportbug depends on:
ii apt 1.8.2
ii file 1:5.35-4+deb10u1
ii python3 3.7.3-1
ii python3-apt 1.8.4
ii python3-debian 0.1.35
ii python3-debianbts 3.0.2
ii python3-requests 2.21.0-1
ii sensible-utils 0.0.12
python3-reportbug suggests no packages.
-- no debconf information
*** /root/0001-RFC-Implement-support-for-TLS-over-465.patch
>From 83c18b5f5cc3d4fe20a27b6fae633af901b00c75 Mon Sep 17 00:00:00 2001
From: David Heidelberg <david@ixit.cz>
Date: Tue, 11 Feb 2020 12:03:34 +0100
Subject: [PATCH] [RFC] Implement support for TLS over 465
Introducing smtptls465 which gives user SMTP over TLS.
This setup is mostly used on port 465.
Signed-off-by: David Heidelberg <david@ixit.cz>
---
bin/reportbug | 31 ++++++++++++++++++++++---------
reportbug/submit.py | 6 ++++--
2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/bin/reportbug b/bin/reportbug
index 12e3299..afbdd6d 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -644,7 +644,12 @@ def offer_configuration(options):
if smtphost:
smtptls = ui.yes_no(
- 'Do you want to encrypt the SMTP connection with TLS (only '
+ 'Do you want to encrypt the SMTP connection with STARTTLS (only '
+ 'available if the SMTP host supports it)?', 'Yes', 'No',
+ default=False)
+
+ smtptls465 = ui.yes_no(
+ 'Do you want to use TLS encryption for the SMTP connection (only '
'available if the SMTP host supports it)?', 'Yes', 'No',
default=False)
@@ -718,11 +723,17 @@ def offer_configuration(options):
print('# If you need to enter a user name and password:', file=fp)
print('#smtpuser "my username here"', file=fp)
print('#smtppasswd "my password here"', file=fp)
+ if smtptls465:
+ print('# Enable TLS on port 465 for the SMTP host', file=fp)
+ print('smtptls465', file=fp)
+ else:
+ print('# Enable this option if you need SMTP over TLS for the SMTP host', file=fp)
+ print('#smtptls465', file=fp)
if smtptls:
- print('# Enable TLS for the SMTP host', file=fp)
+ print('# Enable STARTTLS for the SMTP host', file=fp)
print('smtptls', file=fp)
else:
- print('# Enable this option if you need TLS for the SMTP host', file=fp)
+ print('# Enable this option if you need STARTTLS for the SMTP host', file=fp)
print('#smtptls', file=fp)
if http_proxy:
@@ -799,7 +810,7 @@ def main():
check_available=True, query_src=True, debconf=True,
editor='', offline=False, verify=True, check_uid=True,
testmode=False, attachments=[], keyid='', body=None,
- bodyfile=None, smtptls=False, smtpuser='', smtppasswd='',
+ bodyfile=None, smtptls=False, smtptls465=False, smtpuser='', smtppasswd='',
paranoid=False, mbox_reader_cmd=None)
# Convention: consider `option.foo' names read-only; they always contain
@@ -909,8 +920,10 @@ def main():
parser.add_option('--email', help='specify originating email address')
parser.add_option('--realname', help='specify real name for your report')
parser.add_option('--smtphost', help='specify SMTP server for mailing')
- parser.add_option('--tls', help='use TLS to talk to SMTP servers',
+ parser.add_option('--tls', help='use STARTTLS to talk to SMTP servers',
dest="smtptls", action='store_true')
+ parser.add_option('--tls465', help='talk to SMTP servers over TLS',
+ dest="smtptls465", action='store_true')
parser.add_option('--source', '--src', dest='source', default=False,
help='report the bug against the source package ',
action='store_true')
@@ -2281,10 +2294,10 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
headers, package, charset, mailing, sysinfo, rtype, exinfo,
self.options.replyto, self.options.printonly,
self.options.template, self.options.outfile, self.options.mta,
- self.options.kudos, self.options.smtptls, smtphost,
- self.options.smtpuser, self.options.smtppasswd,
- self.options.paranoid, self.options.draftpath,
- self.options.envelopefrom)
+ self.options.kudos, self.options.smtptls,
+ self.option.smtptls465, smtphost, self.options.smtpuser,
+ self.options.smtppasswd, self.options.paranoid,
+ self.options.draftpath, self.options.envelopefrom)
if self.options.exitprompt:
ui.get_string('Please press ENTER to exit reportbug: ')
diff --git a/reportbug/submit.py b/reportbug/submit.py
index 839ea1d..a0bd02f 100644
--- a/reportbug/submit.py
+++ b/reportbug/submit.py
@@ -204,7 +204,7 @@ def send_report(body, attachments, mua, fromaddr, sendto, ccaddr, bccaddr,
sysinfo=None,
rtype='debbugs', exinfo=None, replyto=None, printonly=False,
template=False, outfile=None, mta='', kudos=False,
- smtptls=False, smtphost='localhost',
+ smtptls=False, smtptls465=False, smtphost='localhost',
smtpuser=None, smtppasswd=None, paranoid=False, draftpath=None,
envelopefrom=None):
'''Send a report.'''
@@ -357,12 +357,14 @@ def send_report(body, attachments, mua, fromaddr, sendto, ccaddr, bccaddr,
# submit
if smtphost.lower() == 'reportbug.debian.org':
conn = smtplib.SMTP(smtphost, 587)
+ elif smtptls465:
+ conn = smtplib.SMTP_SSL(smtphost)
else:
conn = smtplib.SMTP(smtphost)
response = conn.ehlo()
if not (200 <= response[0] <= 299):
conn.helo()
- if smtptls:
+ if smtptls and !smtptls465:
conn.starttls()
response = conn.ehlo()
if not (200 <= response[0] <= 299):
--
2.25.0
Reply to: