From: Dietmar Maurer <dietmar@proxmox.com>
To: Stoiko Ivanov <s.ivanov@proxmox.com>, pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api 2/2] update KAM.cf in pmg-daily
Date: Tue, 17 Nov 2020 10:11:28 +0100 (CET) [thread overview]
Message-ID: <81457005.150.1605604288797@webmail.proxmox.com> (raw)
In-Reply-To: <20201117085401.23407-3-s.ivanov@proxmox.com>
This is too dangerous
- no signature verifications
- no funtional verification
> On 11/17/2020 9:54 AM Stoiko Ivanov <s.ivanov@proxmox.com> wrote:
>
>
> KAM.cf provides additional rules for SpamAssassin and is shipped with
> proxmox-spamassassin. Since the rules get updated regularly, they should
> get updated on a running installation along with the rules provided
> by SpamAssassin directly.
>
> The patch adds the functionalilty for downloading KAM.cf to pmg-daily, which
> gets run (daily) by `pmg-daily.timer`
>
> LWP::UserAgent's mirror method is used since it adds a 'If-Modified-Since'
> header to the request, based on the provided localfile, sets the mtime
> to the Last-Modified date and replaces the file only if the download was
> successful.
>
> I chose '/var/lib/pmg/spamassassin-extra' for keeping the updated version
> to mirror '/usr/share/spamassassin-extra'
>
> Tested the updated template:
> * pmg-smtp-filter/SpamAssassin runs if either file is not present
> * the file in /var/lib/pmg/spamassassin-extra takes precedence over the
> one shipped in '/usr/share/spamassassin-extra' (tested by locally modifying
> a rule-score)
>
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
> debian/dirs | 1 +
> src/bin/pmg-daily | 29 ++++++++++++++++++++++++++++-
> src/templates/local.cf.in | 2 ++
> 3 files changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/debian/dirs b/debian/dirs
> index f7ac2e7..55393a8 100644
> --- a/debian/dirs
> +++ b/debian/dirs
> @@ -2,3 +2,4 @@
> /etc/pmg/dkim
> /var/lib/pmg
> /var/lib/pmg/backup
> +/var/lib/pmg/spamassassin-extra
> diff --git a/src/bin/pmg-daily b/src/bin/pmg-daily
> index 32ccb95..011ec25 100755
> --- a/src/bin/pmg-daily
> +++ b/src/bin/pmg-daily
> @@ -19,6 +19,26 @@ use PMG::DBTools;
> use PMG::API2::Subscription;
> use PMG::API2::APT;
>
> +# returns 1 if there was a newer version, 0 if not
> +sub update_KAM {
> +
> + my $kam_url = 'https://mcgrail.com/downloads/KAM.cf';
> + my $kam_local = '/var/lib/pmg/spamassassin-extra/KAM.cf';
> + my $ua = PMG::Utils::lwp_user_agent();
> + $ua->timeout(10);
> + $ua->max_size(1024*1024);
> +
> + my $response;
> + eval { $response = $ua->mirror($kam_url, $kam_local); };
> + die "updating KAM.cf failed: $@\n" if $@;
> +
> + return 1 if $response->is_success;
> + return 0 if $response->code == 304;
> +
> + my $err = sprintf("unexpected response: %s - %s", $response->code(), $response->message());
> + die "fetching KAM.cf - $err\n";
> +}
> +
> $SIG{'__WARN__'} = sub {
> my $err = $@;
> my $t = $_[0];
> @@ -72,13 +92,20 @@ if (my $http_proxy = $cfg->get('admin', 'http_proxy')) {
> $ENV{http_proxy} = $http_proxy;
> }
>
> +my $restart_filter = 0;
> # update spamassassin rules
> if (system('sa-update') == 0) {
> # if the exit code is 0, new updates were downloaded
> # then restart the pmg-smtp-filter to load the new rules
> - PMG::Utils::service_cmd('pmg-smtp-filter', 'restart');
> + $restart_filter = 1;
> +}
> +
> +if (update_KAM()) {
> + $restart_filter = 1;
> }
>
> +PMG::Utils::service_cmd('pmg-smtp-filter', 'restart') if $restart_filter;
> +
> # run bayes database maintainance
> system('sa-learn --force-expire >/dev/null 2>&1');
>
> diff --git a/src/templates/local.cf.in b/src/templates/local.cf.in
> index 899f970..1a64c78 100644
> --- a/src/templates/local.cf.in
> +++ b/src/templates/local.cf.in
> @@ -27,3 +27,5 @@ score ANY_BOUNCE_MESSAGE [% pmg.spam.bounce_score %]
>
> include /usr/share/spamassassin-extra/KAM.cf
>
> +include /var/lib/pmg/spamassassin-extra/KAM.cf
> +
> --
> 2.20.1
>
>
>
> _______________________________________________
> pmg-devel mailing list
> pmg-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
prev parent reply other threads:[~2020-11-17 9:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-17 8:53 [pmg-devel] [PATCH pmg-api 0/2] " Stoiko Ivanov
2020-11-17 8:54 ` [pmg-devel] [PATCH pmg-api 1/2] add lwp_user_agent to PMG::Utils Stoiko Ivanov
2020-11-17 8:54 ` [pmg-devel] [PATCH pmg-api 2/2] update KAM.cf in pmg-daily Stoiko Ivanov
2020-11-17 9:11 ` Dietmar Maurer [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=81457005.150.1605604288797@webmail.proxmox.com \
--to=dietmar@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.