public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Daniel Berteaud <daniel@firewall-services.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api 1/1] [pmg-api]: fix #3098 : first check for exact domain match
Date: Mon, 26 Oct 2020 11:50:46 +0100	[thread overview]
Message-ID: <20201026105046.424454-2-daniel@firewall-services.com> (raw)
In-Reply-To: <20201026105046.424454-1-daniel@firewall-services.com>

When selecting the sending domain for the DKIM signature, we should first check for an exact match. If none is found, look for parent domains. This fixes the case where wrong signing domain can be added if sign_all is disabled and we sign both a parent and a child domain.

Signed-off-by: Daniel Berteaud <daniel@firewall-services.com>
---
 src/PMG/DKIMSign.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/PMG/DKIMSign.pm b/src/PMG/DKIMSign.pm
index 7cb06a6..8fd9eed 100644
--- a/src/PMG/DKIMSign.pm
+++ b/src/PMG/DKIMSign.pm
@@ -69,6 +69,14 @@ sub signing_domain {
     my $dkimdomains = PVE::INotify::read_file('dkimdomains');
     $dkimdomains = PVE::INotify::read_file('domains') if !scalar(%$dkimdomains);
 
+    # First check for an exact match in the domain list
+    foreach my $domain (sort keys %$dkimdomains) {
+	if ( $input_domain eq $domain ) {
+	    $self->domain($domain);
+	    return 1;
+	}
+    }
+    # If no exact match is found, check for parent/child domains
     foreach my $domain (sort keys %$dkimdomains) {
 	if ( $input_domain =~ /\Q$domain\E$/i ) {
 	    $self->domain($domain);
-- 
2.26.2





  reply	other threads:[~2020-10-26 10:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 10:50 [pmg-devel] [PATCH pmg-api 0/1] DKIM, " Daniel Berteaud
2020-10-26 10:50 ` Daniel Berteaud [this message]
2020-10-27 11:39   ` [pmg-devel] [PATCH pmg-api 1/1] [pmg-api]: fix #3098 : " Stoiko Ivanov
2020-10-27 11:46     ` Daniel Berteaud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201026105046.424454-2-daniel@firewall-services.com \
    --to=daniel@firewall-services.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal