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 3B9059196F for ; Mon, 14 Nov 2022 15:50:09 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1BD6524EE4 for ; Mon, 14 Nov 2022 15:49:39 +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 for ; Mon, 14 Nov 2022 15:49:37 +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 6A60543D05; Mon, 14 Nov 2022 15:49:37 +0100 (CET) Message-ID: Date: Mon, 14 Nov 2022 15:49:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:107.0) Gecko/20100101 Thunderbird/107.0 Content-Language: en-US To: Stoiko Ivanov , pmg-devel@lists.proxmox.com References: <20221109182728.629576-1-s.ivanov@proxmox.com> <20221109182728.629576-5-s.ivanov@proxmox.com> From: Dominik Csapak In-Reply-To: <20221109182728.629576-5-s.ivanov@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: =?UTF-8?Q?0=0A=09?=AWL 0.066 Adjusted score from AWL reputation of From: =?UTF-8?Q?address=0A=09?=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 =?UTF-8?Q?Alignment=0A=09?=NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF =?UTF-8?Q?Record=0A=09?=SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pmg-devel] [PATCH pmg-api 4/5] ruledb: encode e-mail addresses for syslog 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: Mon, 14 Nov 2022 14:50:09 -0000 question: since the rulenames are now utf-8, wouldn't we have to encode them here too? nits inline: On 11/9/22 19:27, Stoiko Ivanov wrote: > as done in 114655f4fdb07c789a361b2f397f5345eafd16c6 for Accept and > Block. > > Signed-off-by: Stoiko Ivanov > --- > src/PMG/RuleDB/BCC.pm | 17 +++++++++++++++-- > src/PMG/RuleDB/Notify.pm | 17 +++++++++++++++-- > src/PMG/RuleDB/Quarantine.pm | 16 ++++++++++++++-- > src/PMG/RuleDB/Remove.pm | 8 +++++++- > 4 files changed, 51 insertions(+), 7 deletions(-) > > diff --git a/src/PMG/RuleDB/BCC.pm b/src/PMG/RuleDB/BCC.pm > index c1225f3..e56f051 100644 > --- a/src/PMG/RuleDB/BCC.pm > +++ b/src/PMG/RuleDB/BCC.pm > @@ -165,9 +165,22 @@ sub execute { > $msginfo->{xforward}, $msginfo->{fqdn}, $param); > foreach (@bcc_targets) { > if ($qid) { > - syslog('info', "%s: bcc to <%s> (rule: %s, %s)", $queue->{logid}, $_, $rulename, $qid); > + syslog( > + 'info', > + "%s: bcc to <%s> (rule: %s, %s)", > + $queue->{logid}, > + encode('UTF-8',$_), > + $rulename, > + $qid, > + ); > } else { > - syslog('err', "%s: bcc to <%s> (rule: %s) failed", $queue->{logid}, $_, $rulename); > + syslog( > + 'err', > + "%s: bcc to <%s> (rule: %s) failed", > + $queue->{logid}, > + encode('UTF-8',$_), > + $rulename, > + ); > } i'd rather prefer to encode $_ once before the if and using that instead of having two encode calls: my $target = encode(... $_); if ($qid) { syslog(..., $target); else { syslog(..., $target); } > } > } > diff --git a/src/PMG/RuleDB/Notify.pm b/src/PMG/RuleDB/Notify.pm > index bca5ebf..ee5d2ac 100644 > --- a/src/PMG/RuleDB/Notify.pm > +++ b/src/PMG/RuleDB/Notify.pm > @@ -260,9 +260,22 @@ sub execute { > $top, $from, \@targets, undef, $msginfo->{fqdn}); > foreach (@targets) { > if ($qid) { > - syslog('info', "%s: notify <%s> (rule: %s, %s)", $queue->{logid}, $_, $rulename, $qid); > + syslog( > + 'info', > + "%s: notify <%s> (rule: %s, %s)", > + $queue->{logid}, > + encode('UTF-8', $_), > + $rulename, > + $qid, > + ); > } else { > - syslog ('err', "%s: notify <%s> (rule: %s) failed", $queue->{logid}, $_, $rulename); > + syslog ( > + 'err', > + "%s: notify <%s> (rule: %s) failed", > + $queue->{logid}, > + encode('UTF-8', $_), > + $rulename, > + ); > } same here > } > } > diff --git a/src/PMG/RuleDB/Quarantine.pm b/src/PMG/RuleDB/Quarantine.pm > index 30bc5ec..f7154d8 100644 > --- a/src/PMG/RuleDB/Quarantine.pm > +++ b/src/PMG/RuleDB/Quarantine.pm > @@ -101,7 +101,13 @@ sub execute { > if (my $qid = $queue->quarantine_mail($ruledb, 'V', $entity, $tg, $msginfo, $vars, $ldap)) { > > foreach (@$tg) { > - syslog ('info', "$queue->{logid}: moved mail for <%s> to virus quarantine - %s (rule: %s)", $_, $qid, $rulename); > + syslog ( > + 'info', > + "$queue->{logid}: moved mail for <%s> to virus quarantine - %s (rule: %s)", > + encode('UTF-8',$_), > + $qid, > + $rulename, > + ); > } > > $queue->set_status ($tg, 'delivered'); > @@ -111,7 +117,13 @@ sub execute { > if (my $qid = $queue->quarantine_mail($ruledb, 'S', $entity, $tg, $msginfo, $vars, $ldap)) { > > foreach (@$tg) { > - syslog ('info', "$queue->{logid}: moved mail for <%s> to spam quarantine - %s (rule: %s)", $_, $qid, $rulename); > + syslog ( > + 'info', > + "$queue->{logid}: moved mail for <%s> to spam quarantine - %s (rule: %s)", > + encode('UTF-8',$_), > + $qid, > + $rulename, > + ); > } > > $queue->set_status($tg, 'delivered'); > diff --git a/src/PMG/RuleDB/Remove.pm b/src/PMG/RuleDB/Remove.pm > index da6c25f..e7c353c 100644 > --- a/src/PMG/RuleDB/Remove.pm > +++ b/src/PMG/RuleDB/Remove.pm > @@ -235,7 +235,13 @@ sub execute { > } > > foreach (@$tg) { > - syslog ('info', "$queue->{logid}: moved mail for <%s> to attachment quarantine - %s (rule: %s)", $_, $qid, $rulename); > + syslog ( > + 'info', > + "$queue->{logid}: moved mail for <%s> to attachment quarantine - %s (rule: %s)", > + encode('UTF-8',$_), > + $qid, > + $rulename, > + ); > } > } > }