From 4b0019c3eff591eef744eed9ccf785a0357c71db Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: May 20 2020 22:22:16 +0000 Subject: Backport support for STARTTLS support for SMTP servers --- diff --git a/0001-Add-support-for-smtp-server-requiring-starttls-to-wo.patch b/0001-Add-support-for-smtp-server-requiring-starttls-to-wo.patch new file mode 100644 index 0000000..091c3c0 --- /dev/null +++ b/0001-Add-support-for-smtp-server-requiring-starttls-to-wo.patch @@ -0,0 +1,77 @@ +From 4196a3772693a79f1e5db12fa937bcee8280e248 Mon Sep 17 00:00:00 2001 +From: Pierre-Yves Chibon +Date: Mon, 18 May 2020 15:57:05 +0200 +Subject: [PATCH] Add support for smtp server requiring starttls to work + +Signed-off-by: Pierre-Yves Chibon +--- + doc/configuration.rst | 27 +++++++++++++++++++++++++++ + pagure/lib/notify.py | 14 ++++++++++++++ + 2 files changed, 41 insertions(+) + +diff --git a/doc/configuration.rst b/doc/configuration.rst +index 41f29b96..25dee387 100644 +--- a/doc/configuration.rst ++++ b/doc/configuration.rst +@@ -961,6 +961,33 @@ should be secured over SSL. + Defaults to: ``False`` + + ++SMTP_STARTTLS ++^^^^^^^^^^^^^ ++ ++This configuration key specifies instructs pagure to starts connecting to ++the SMTP server via a `starttls` command. ++ ++Defaults to: ``False`` ++ ++ ++SMTP_KEYFILE ++^^^^^^^^^^^^ ++ ++This configuration key allows to specify a key file to be used in the ++`starttls` command when connecting to the smtp server. ++ ++Defaults to: ``None`` ++ ++ ++SMTP_CERTFILE ++^^^^^^^^^^^^ ++ ++This configuration key allows to specify a certificate file to be used in ++the `starttls` command when connecting to the smtp server. ++ ++Defaults to: ``None`` ++ ++ + SMTP_USERNAME + ^^^^^^^^^^^^^ + +diff --git a/pagure/lib/notify.py b/pagure/lib/notify.py +index 7670ad15..2c4ee30f 100644 +--- a/pagure/lib/notify.py ++++ b/pagure/lib/notify.py +@@ -505,6 +505,20 @@ def send_email( + pagure_config["SMTP_SERVER"], + pagure_config["SMTP_PORT"], + ) ++ ++ if pagure_config["SMTP_STARTTLS"]: ++ context = ssl.create_default_context() ++ keyfile = pagure_config.get("SMTP_KEYFILE") or None ++ certfile = pagure_config.get("SMTP_CERTFILE") or None ++ respcode, _ = smtp.starttls( ++ keyfile=keyfile, certfile=certfile, context=context, ++ ) ++ if respcode != 220: ++ _log.warning( ++ "The starttls command did not return the 220 " ++ "response code expected." ++ ) ++ + if ( + pagure_config["SMTP_USERNAME"] + and pagure_config["SMTP_PASSWORD"] +-- +2.26.1 + diff --git a/pagure.spec b/pagure.spec index 72d8698..0954ab0 100644 --- a/pagure.spec +++ b/pagure.spec @@ -13,7 +13,7 @@ Name: pagure Version: 5.10.0 -Release: 6%{?dist} +Release: 7%{?dist} Summary: A git-centered forge License: GPLv2+ @@ -25,6 +25,8 @@ Source10: pagure-README.Fedora # Backports from upstream ## Backport fix to make stats page work Patch0001: 0001-Make-the-stats-page-use-the-new-stats-API-endpoint.patch +## Backport support for STARTTLS support for SMTP servers +Patch0002: 0001-Add-support-for-smtp-server-requiring-starttls-to-wo.patch BuildArch: noarch @@ -605,6 +607,9 @@ done %changelog +* Wed May 20 2020 Neal Gompa - 5.10.0-7 +- Backport support for STARTTLS support for SMTP servers + * Sat May 16 2020 Neal Gompa - 5.10.0-6 - Backport fix for stats - Add missing step to start pagure web services for nginx setup in quickstart