[pmg-devel] [PATCH pmg-api] sa-custom: fix moving config across mountpoints

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Oct 3 17:27:34 CEST 2024


On 02/10/2024 19:22, Stoiko Ivanov wrote:
> the custom scores are kept in /var/cache/pmg-scores.cf, until they are
> applied, by moving them to /etc/mail/spamassassin/pmg-scores.cf.

Is there a good reason to not keep them in "/etc/mail/spamassassin/"
instead? That would ensure a simple rename can work and be IMO a bit
more in line with what we do else where (like host network changes),
and using "/var/cache" here feels also a bit odd in general, but that
doesn't have to be the deciding factor.

I'm fine with switching to move, but IMO adding a short info for why
not changing the pending changes config file path to the same directory
might be warranted.

> @@ -14,7 +15,9 @@ sub get_shadow_path {
>  }
>  
>  sub apply_changes {
> -    rename($shadow_path, $conf_path) if -f $shadow_path;
> +    if (-f $shadow_path) {
> +	move($shadow_path, $conf_path) || die 'Moving custom scores configuration failed!\n';

is there no error variable?

With rename we could at least do

if (-f $shadow_path) {
    rename($shadow_path, $conf_path) or die "failed to apply custom scores - $!\n";
}

(which would have made exposing that bug much easier in the first place ^^)

> +    }
>  }
>  
>  sub calc_digest {





More information about the pmg-devel mailing list