[pmg-devel] [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first

Stoiko Ivanov s.ivanov at proxmox.com
Thu Oct 29 11:05:46 CET 2020


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 at proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov at proxmox.com>




On Wed, 28 Oct 2020 11:20:15 +0100
Daniel Berteaud <daniel at 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 at 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;





More information about the pmg-devel mailing list