From: Jonas Theisen <j.theisen@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: Re: [PATCH pmg-api] postfix: config: use postalias and update aliases.db only if changed
Date: Tue, 29 Sep 2026 16:49:23 +0200 [thread overview]
Message-ID: <ab9bb54c-04bb-46cc-bc46-17f2b9bb7fb0@proxmox.com> (raw)
In-Reply-To: <20260729160639.431458-1-j.theisen@proxmox.com>
Gentle ping
On 7/30/26 16:18, Jonas Theisen wrote:
> Replace sendmail-interface command newaliases
> with postfix native postalias
>
> Added update logic for postalias to only run if changes are present
> since the overwrite every two minutes would trigger a log message
> next time an email was received on a cluster node.
> This is analogus to the already added run_postmap for other
> postfix files,
> see 78982d93 ("run_postmap: only run postmap if file was modified")
>
> run_postmap could not be reused since it does not handle alias files
>
> Reported by a forum user in https://forum.proxmox.com/threads/185048/
>
> To test change /etc/aliases and run 'pmgcm sync' on cluster node.
> aliases.db should be updated.
> If unchanged aliases.db on cluster node should also stay unchanged
> in contrast to the previous overwrite every two minutes.
>
> Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
> ---
> src/PMG/Config.pm | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/src/PMG/Config.pm b/src/PMG/Config.pm
> index 5f95857..a03e79e 100644
> --- a/src/PMG/Config.pm
> +++ b/src/PMG/Config.pm
> @@ -1923,6 +1923,30 @@ sub rewrite_postfix_welcomelist {
> return $changes;
> }
>
> +my sub run_postalias {
> + my ($filename) = @_;
> +
> + # make sure the file exists (else postalias fails)
> + IO::File->new($filename, 'a', 0644);
> +
> + my $mtime_src = (CORE::stat($filename))[9] // die "unable to read mtime of $filename\n";
> +
> + my $mtime_dst = (CORE::stat("$filename.db"))[9] // 0;
> +
> + # if not changed, do nothing
> + return if $mtime_src <= $mtime_dst;
> +
> + eval {
> + PVE::Tools::run_command(
> + ['/usr/sbin/postalias', $filename],
> + errmsg => "unable to update postfix aliases $filename",
> + );
> + };
> + my $err = $@;
> +
> + warn $err if $err;
> +}
> +
> # rewrite /etc/postfix/*
> sub rewrite_config_postfix {
> my ($self, $rulecache) = @_;
> @@ -1950,8 +1974,8 @@ sub rewrite_config_postfix {
>
> $changes = 1 if $rulecache && rewrite_postfix_welcomelist($rulecache);
>
> - # make sure aliases.db is up to date
> - system('/usr/bin/newaliases');
> + # update aliases.db if necessary
> + run_postalias('/etc/aliases');
>
> return $changes;
> }
prev parent reply other threads:[~2026-09-29 14:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 16:06 [PATCH pmg-api] postfix: config: use postalias and update aliases.db only if changed Jonas Theisen
2026-09-29 14:49 ` Jonas Theisen [this message]
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=ab9bb54c-04bb-46cc-bc46-17f2b9bb7fb0@proxmox.com \
--to=j.theisen@proxmox.com \
--cc=pmg-devel@lists.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