public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Stoiko Ivanov <s.ivanov@proxmox.com>, pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api 4/5] ruledb: encode e-mail addresses for syslog
Date: Mon, 14 Nov 2022 15:49:36 +0100	[thread overview]
Message-ID: <fac89b40-0645-4d93-603a-ecf5bb7ec349@proxmox.com> (raw)
In-Reply-To: <20221109182728.629576-5-s.ivanov@proxmox.com>

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 <s.ivanov@proxmox.com>
> ---
>   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,
> +		    );
>   		}
>   	    }
>   	}





  reply	other threads:[~2022-11-14 14:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 18:27 [pmg-devel] [PATCH pmg-api 0/5] ruledb - improve experience for non-ascii tests and mails Stoiko Ivanov
2022-11-09 18:27 ` [pmg-devel] [PATCH pmg-api 1/5] ruledb: modfield: properly encode field after variable substitution Stoiko Ivanov
2022-11-11 13:56   ` [pmg-devel] applied: " Thomas Lamprecht
2022-11-09 18:27 ` [pmg-devel] [PATCH pmg-api 2/5] ruledb: add deprecation warnings for unused actions Stoiko Ivanov
2022-11-14 16:02   ` Dominik Csapak
2022-11-15 14:32   ` [pmg-devel] applied: " Thomas Lamprecht
2022-11-09 18:27 ` [pmg-devel] [PATCH pmg-api 3/5] fix #2541 ruledb: encode relevant values as utf-8 in database Stoiko Ivanov
2022-11-14 14:36   ` Dominik Csapak
2022-11-09 18:27 ` [pmg-devel] [PATCH pmg-api 4/5] ruledb: encode e-mail addresses for syslog Stoiko Ivanov
2022-11-14 14:49   ` Dominik Csapak [this message]
2022-11-09 18:27 ` [pmg-devel] [PATCH pmg-api 5/5] partially fix #2465: handle smtputf8 addresses in the rule-system Stoiko Ivanov
2022-11-14 16:03   ` Dominik Csapak
2022-11-14 16:02 ` [pmg-devel] [PATCH pmg-api 0/5] ruledb - improve experience for non-ascii tests and mails Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fac89b40-0645-4d93-603a-ecf5bb7ec349@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    --cc=s.ivanov@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal