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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D4B0769547 for ; Wed, 23 Mar 2022 13:10:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BEFAE26DF4 for ; Wed, 23 Mar 2022 13:09:55 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 firstgate.proxmox.com (Proxmox) with ESMTPS id 2EE9026DE8 for ; Wed, 23 Mar 2022 13:09:55 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 331BB46F7E for ; Wed, 23 Mar 2022 13:03:25 +0100 (CET) Message-ID: <78e6b927-9d4d-3e91-810c-fe50df5e4770@proxmox.com> Date: Wed, 23 Mar 2022 13:03:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Thunderbird/99.0 Content-Language: en-US To: Markus Frank , pmg-devel@lists.proxmox.com References: <20220318123706.6160-1-m.frank@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20220318123706.6160-1-m.frank@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.056 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pmg-devel] [PATCH pmg-api] fix #3924: ldap: skip non-smtp proxyAddresses 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, 23 Mar 2022 12:10:25 -0000 On 18.03.22 13:37, Markus Frank wrote: > When an entry in proxyAddresses starts with SIP (or everthing > that is not smtp) no e-mail gets listed on the webpage. > Therefore no quarantine notification messages are sent. > 1. that statement doesn't really tells me any rationale or the actual problem, also, which webpage? do you mean the web-interface (GUI)? 2. this loops not only over proxyAddresses but *all* mail attributes (user configurable, default: mail, userPrincipalName, proxyAddresses, othermailbox, mailAlternativeAddress) so unconditionally skipping all that doesn't starts with smtp seems odd 3. the bug report shows that there is a smtp address, it just isn't on the first line, should this rather cope with such multi-line stuff and better extract the (any?) mail addresses there? > To change this, every entry with another protocol than smtp, > should be skipped. > > removed "SMTP" because of lowercase function is called before. nit: could be a separate patch as its rather unrelated with the skipping. > > Signed-off-by: Markus Frank > --- > src/PMG/LDAPCache.pm | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/src/PMG/LDAPCache.pm b/src/PMG/LDAPCache.pm > index df61454..8172329 100755 > --- a/src/PMG/LDAPCache.pm > +++ b/src/PMG/LDAPCache.pm > @@ -159,12 +159,17 @@ sub queryusers { > next if !$user->{attributes}->{$attr}; > foreach my $mail (@{$user->{attributes}->{$attr}}) { > $mail = lc($mail); > + > + # Check if proxyAddresses entry starts with anything but it's not only 'proxyAddresses' that's accessed here (see 2. above). > + # other than smtp and skip if true > + next if ($mail =~ m/^(?!.*smtp).*[\:\$]/gs); iff we'd do it this way a negated match (`!~` vs. `=~`) could be favorable over a negative-lookahead readability wise. > + > # Test if the Line starts with one of the following lines: > - # proxyAddresses: [smtp|SMTP]: > + # proxyAddresses: [smtp]: > # and also discard this starting string, so that $mail is only the > # address without any other characters... > > - $mail =~ s/^(smtp|SMTP)[\:\$]//gs; > + $mail =~ s/^smtp[\:\$]//gs; > > if ($mail !~ m/[\{\}\\\/]/ && $mail =~ m/^\S+\@\S+$/) { > $umails->{$mail} = 1;