all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH v2 pmg-api 0/1] Select the correct domain for the DKIM
@ 2020-10-28 10:20 Daniel Berteaud
  2020-10-28 10:20 ` [pmg-devel] [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first Daniel Berteaud
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Berteaud @ 2020-10-28 10:20 UTC (permalink / raw)
  To: pmg-devel

This v2 implement the logic proposed by Stoiko Ivanov, which is to sort
domains by length first. Instead of looping twice in the domain list
(once for exact match, a second time for parent/child)

Daniel Berteaud (1):
  [pmg-api] fix #3098 sort domains by length first

 src/PMG/DKIMSign.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.26.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pmg-devel] [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first
  2020-10-28 10:20 [pmg-devel] [PATCH v2 pmg-api 0/1] Select the correct domain for the DKIM Daniel Berteaud
@ 2020-10-28 10:20 ` Daniel Berteaud
  2020-10-29 10:05   ` Stoiko Ivanov
  2020-11-18  7:11   ` [pmg-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Berteaud @ 2020-10-28 10:20 UTC (permalink / raw)
  To: pmg-devel

So if we have a sub domain and its parent in the list, the correct one will be returned

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

diff --git a/src/PMG/DKIMSign.pm b/src/PMG/DKIMSign.pm
index 7cb06a6..08197f8 100644
--- a/src/PMG/DKIMSign.pm
+++ b/src/PMG/DKIMSign.pm
@@ -69,7 +69,9 @@ sub signing_domain {
     my $dkimdomains = PVE::INotify::read_file('dkimdomains');
     $dkimdomains = PVE::INotify::read_file('domains') if !scalar(%$dkimdomains);
 
-    foreach my $domain (sort keys %$dkimdomains) {
+    # Sort domains by length first, so if we have both a sub domain and its parent
+    # the correct one will be returned
+    foreach my $domain (sort { length($b) <=> length($a) || $a cmp $b} keys %$dkimdomains) {
 	if ( $input_domain =~ /\Q$domain\E$/i ) {
 	    $self->domain($domain);
 	    return 1;
-- 
2.26.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pmg-devel] [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first
  2020-10-28 10:20 ` [pmg-devel] [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first Daniel Berteaud
@ 2020-10-29 10:05   ` Stoiko Ivanov
  2020-11-18  7:11   ` [pmg-devel] applied: " Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2020-10-29 10:05 UTC (permalink / raw)
  To: Daniel Berteaud; +Cc: pmg-devel

Thanks for adapting your patch and trying it out!

LGTM - I quickly tested it on my test-system with some syntetic
test-domains - it works as I'd expect it to:

Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>




On Wed, 28 Oct 2020 11:20:15 +0100
Daniel Berteaud <daniel@firewall-services.com> wrote:

> So if we have a sub domain and its parent in the list, the correct one will be returned
> 
> Signed-off-by: Daniel Berteaud <daniel@firewall-services.com>
> ---
>  src/PMG/DKIMSign.pm | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/PMG/DKIMSign.pm b/src/PMG/DKIMSign.pm
> index 7cb06a6..08197f8 100644
> --- a/src/PMG/DKIMSign.pm
> +++ b/src/PMG/DKIMSign.pm
> @@ -69,7 +69,9 @@ sub signing_domain {
>      my $dkimdomains = PVE::INotify::read_file('dkimdomains');
>      $dkimdomains = PVE::INotify::read_file('domains') if !scalar(%$dkimdomains);
>  
> -    foreach my $domain (sort keys %$dkimdomains) {
> +    # Sort domains by length first, so if we have both a sub domain and its parent
> +    # the correct one will be returned
> +    foreach my $domain (sort { length($b) <=> length($a) || $a cmp $b} keys %$dkimdomains) {
>  	if ( $input_domain =~ /\Q$domain\E$/i ) {
>  	    $self->domain($domain);
>  	    return 1;





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pmg-devel] applied: [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first
  2020-10-28 10:20 ` [pmg-devel] [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first Daniel Berteaud
  2020-10-29 10:05   ` Stoiko Ivanov
@ 2020-11-18  7:11   ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2020-11-18  7:11 UTC (permalink / raw)
  To: Daniel Berteaud, pmg-devel

On 28.10.20 11:20, Daniel Berteaud wrote:
> So if we have a sub domain and its parent in the list, the correct one will be returned
> 
> Signed-off-by: Daniel Berteaud <daniel@firewall-services.com>
> ---
>  src/PMG/DKIMSign.pm | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-18  7:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 10:20 [pmg-devel] [PATCH v2 pmg-api 0/1] Select the correct domain for the DKIM Daniel Berteaud
2020-10-28 10:20 ` [pmg-devel] [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first Daniel Berteaud
2020-10-29 10:05   ` Stoiko Ivanov
2020-11-18  7:11   ` [pmg-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal