From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8497B62C2C for ; Wed, 28 Oct 2020 11:20:26 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 739131DDE7 for ; Wed, 28 Oct 2020 11:20:26 +0100 (CET) Received: from pmg.fws.fr (pmg.fws.fr [51.91.175.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id ABE921DDD5 for ; Wed, 28 Oct 2020 11:20:25 +0100 (CET) Received: from pmg.fws.fr (localhost [127.0.0.1]) by pmg.fws.fr (Proxmox) with ESMTP id 57AEEC025D for ; Wed, 28 Oct 2020 11:20:25 +0100 (CET) Received: from zmproxy.fws.fr (zmproxy.fws.fr [10.29.1.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pmg.fws.fr (Proxmox) with ESMTPS id 747F3C090E for ; Wed, 28 Oct 2020 11:20:24 +0100 (CET) Received: from zmproxy.fws.fr (localhost [127.0.0.1]) by zmproxy.fws.fr (Postfix) with ESMTPS id 6D42E8B79C2; Wed, 28 Oct 2020 11:20:24 +0100 (CET) Received: from zmproxy.fws.fr (localhost [127.0.0.1]) by zmproxy.fws.fr (Postfix) with ESMTPS id 544D38B79C1; Wed, 28 Oct 2020 11:20:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 zmproxy.fws.fr 544D38B79C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=firewall-services.com; s=7DAD15A2-D84A-11E9-8F77-BEC4FAA34EBC; t=1603880424; bh=vHtMCvnKAholfOejUA1HOPco+2WCS3rXsEOjpKTH+Iw=; h=From:To:Date:Message-Id:MIME-Version; b=ULRea8HSvAEvxrtRFDG/5gcVNTZgXiAu62yTyz2HA14HA5RvU21Y1z8nRs4d1HBwn UmfoUzusyIlw6HMiVte8qoLGflkEEI5y536ASQX3sCchnQrIgeIMtsiy1+e6MTkKD8 46bYoqiZXjodD21vptp5eEK1AeCCooGDJKQUsoEwmLKTpmLwv7yVuB/vELkxXyci9o 6XOqPr9mOq0aTNaWXUfvrKeBpH6cDGWHlkwTXNVmcFqy6By7UTluF5NQfQjZnVkHmU HmDIz6hE6K2Ex94BPUxqJC2VBLni50ZOigdOVT0FFpg9RFOSW4m6dj3O6cxzHwkC5A 8zXbrzlUjiyFw== Received: from germaine.lapiole.org (unknown [192.168.7.101]) by zmproxy.fws.fr (Postfix) with ESMTPSA id 30DEA8B79C2; Wed, 28 Oct 2020 11:20:24 +0100 (CET) From: Daniel Berteaud To: pmg-devel@lists.proxmox.com Date: Wed, 28 Oct 2020 11:20:15 +0100 Message-Id: <20201028102015.628005-2-daniel@firewall-services.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201028102015.628005-1-daniel@firewall-services.com> References: <20201028102015.628005-1-daniel@firewall-services.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.010 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [firewall-services.com, dkimsign.pm] Subject: [pmg-devel] [PATCH v2 pmg-api 1/1] [pmg-api] fix #3098 sort domains by length first X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2020 10:20:26 -0000 So if we have a sub domain and its parent in the list, the correct one will be returned Signed-off-by: Daniel Berteaud --- 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