pagure/0001-Add-support-for-smtp-server-requiring-starttls-to-wo.patch
Neal Gompa 9c6e7fdf78 - Backport fixes for STARTTLS support
+ Patch: 0002-starttls-support-via-SMTP_STARTTLS-provide-additiona.patch
  + Patch: 0001-Do-not-assume-there-is-a-SMTP_STARTTLS-configuration.patch
- Backport fix for docs repo access grant
  + Patch: 0001-Fix-repotype-spelling.patch
- Backport fix for visual bug on API docs formatting
  + Patch: 0001-api-fix-apidoc-format-on-api_view_issues_history_det.patch
- Backport fix to changing pull mirror settings
  + Patch: 0001-Allow-editing-the-URL-a-project-is-mirrored-from.patch
- Backport fix to add descriptions to API scopes
  + Patch: 0001-Show-the-ACL-name-in-addition-to-the-description-whe.patch
- Backport fix to make heatmap UI functional again
  + Patch: 0001-Bring-back-JS-library-used-for-the-heatmap.patch
- Backport fix for handling headers
  + Patch: 0001-Ensure-the-title-name-of-the-headers-are-strings.patch
- Backport fix for burndown graph title
  + Patch: 0001-Fix-the-title-of-the-graph-showing-the-evolution-of-.patch
- Backport fix for permissions on authorized_keys file
  + Patch: 0001-Make-sure-authorized_keys-file-has-mode-600.patch
- Add patch to use whitenoise for rendering static assets
  + Patch: 0101-Use-WhiteNoise-to-serve-static-assets-for-the-Pagure.patch
- Refresh default configuration patch
  + Patch: pagure-5.0-default-example-cfg.patch

OBS-URL: https://build.opensuse.org/package/show/devel:tools:scm/pagure?expand=0&rev=39
2020-06-21 13:57:24 +00:00

78 lines
2.2 KiB
Diff

From 4196a3772693a79f1e5db12fa937bcee8280e248 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Mon, 18 May 2020 15:57:05 +0200
Subject: [PATCH 1/2] Add support for smtp server requiring starttls to work
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
---
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