Mailing List Archive

Using spamassassin modules from a git repo
I'm running debian on my mail server. I use etckeeper to track
changes in /etc.

Often I run across modules such as spamassassin-esp and maybe I would
consider playing with Jared Hall's CHAOS module.

I'm curious what the recommended best practice is to install such
modules from a git repo.

For spamassassin-esp, I cloned the repo into my /etc/spamassassin/
directory and then added this to my local.cf:

loadplugin Mail::SpamAssassin::Plugin::Esp spamassassin-esp/Esp.pm
include spamassassin-esp/Esp.cf

This allows me to 'git pull' from this repository from time to time to
update it. But it's not perfect, especially as I have local changes
to Esp.cf. It's actually worse since I forked it to give back some
changes but I'd say that's perhaps less usual.

Furthermore, as I said, I use etckeeper and when I 'apt upgrade', I get
constant warnings:

modified: spamassassin/spamassassin-esp (modified content, untracked content)

So clearly it's not ideal to clone a spamassassin module into
/etc/spamassassin!

I'm curious if someone has a clean solution here that allows updating
the module from time to time from git.

I realize this may be more a debian question and I may post it on the
debian-users list if I don't get any decent replies here.

Michael Grant
Re: Using spamassassin modules from a git repo [ In reply to ]
How about cloning outside your etc directory, for instance in
/usr/local? And then adding the correct paths to local.cf, as usual.

Kind regards,
Tom

On 08-04-2021 11:05, Michael Grant wrote:
> I'm running debian on my mail server. I use etckeeper to track
> changes in /etc.
>
> Often I run across modules such as spamassassin-esp and maybe I would
> consider playing with Jared Hall's CHAOS module.
>
> I'm curious what the recommended best practice is to install such
> modules from a git repo.
>
> For spamassassin-esp, I cloned the repo into my /etc/spamassassin/
> directory and then added this to my local.cf:
>
> loadplugin Mail::SpamAssassin::Plugin::Esp spamassassin-esp/Esp.pm
> include spamassassin-esp/Esp.cf
>
> This allows me to 'git pull' from this repository from time to time to
> update it. But it's not perfect, especially as I have local changes
> to Esp.cf. It's actually worse since I forked it to give back some
> changes but I'd say that's perhaps less usual.
>
> Furthermore, as I said, I use etckeeper and when I 'apt upgrade', I get
> constant warnings:
>
> modified: spamassassin/spamassassin-esp (modified content, untracked content)
>
> So clearly it's not ideal to clone a spamassassin module into
> /etc/spamassassin!
>
> I'm curious if someone has a clean solution here that allows updating
> the module from time to time from git.
>
> I realize this may be more a debian question and I may post it on the
> debian-users list if I don't get any decent replies here.
>
> Michael Grant
>
Re: Using spamassassin modules from a git repo [ In reply to ]
On 2021-04-08 11:05, Michael Grant wrote:

> loadplugin Mail::SpamAssassin::Plugin::Esp spamassassin-esp/Esp.pm
> include spamassassin-esp/Esp.cf

loadplugin must not be in cf files, it belongs to pre files
Re: Using spamassassin modules from a git repo [ In reply to ]
On Thu, Apr 08, 2021 at 04:11:25PM +0200, Benny Pedersen wrote:
> On 2021-04-08 11:05, Michael Grant wrote:
>
> > loadplugin Mail::SpamAssassin::Plugin::Esp spamassassin-esp/Esp.pm
> > include spamassassin-esp/Esp.cf
>
> loadplugin must not be in cf files, it belongs to pre files

This may be a stupid question... but for a spamassassin module, for
example spamassassin-esp, how would one normally "install" this so
that it reads the .pre file?

Putting modules in /usr/local/etc/spamassassin/ as Tom Hendrikx
suggested.

What I have at the moment now is a modified version of
/etc/spamassassin/Esp.pre:

loadplugin Mail::SpamAssassin::Plugin::Esp /usr/local/etc/spamassassin-esp/Esp.pm
include /usr/local/etc/spamassassin-esp/Esp.cf

Given that there is an Esp.pre in the spamassassin-esp folder, is
there a way I would use that pre file directly? I mean, is there some
way to add that folder to spamassassin's "path"?
Re: Using spamassassin modules from a git repo [ In reply to ]
On 2021-04-08 18:54, Michael Grant wrote:

> This may be a stupid question... but for a spamassassin module, for
> example spamassassin-esp, how would one normally "install" this so
> that it reads the .pre file?

all content should be placed in same dir as local.cf

and custom plugins should have there own <pluginname>.pre with the
loadplugin

i think it works if Esp.cf is in same dir as local.cf

then there is no need to make include lines
Re: Using spamassassin modules from a git repo [ In reply to ]
On Thu, Apr 08, 2021 at 07:00:57PM +0200, Benny Pedersen wrote:
> On 2021-04-08 18:54, Michael Grant wrote:
>
> > This may be a stupid question... but for a spamassassin module, for
> > example spamassassin-esp, how would one normally "install" this so
> > that it reads the .pre file?
>
> all content should be placed in same dir as local.cf
>
> and custom plugins should have there own <pluginname>.pre with the
> loadplugin
>
> i think it works if Esp.cf is in same dir as local.cf
> then there is no need to make include lines

This is what I want to avoid which was the goal of my original post.

1. Many modules are from git repos and need to live in their own
directory to be updated from time to time, 2. the /etc/spamassassin/
directory can get very messy if you just dump things in there. Hard
to know what's what, it becomes impossible to maintain.

So I don't see any alternative to keeping such modules in separate
directories like this.

Is there really no way to tell spamassassin where to look for such
modules, like some sort of search path? I'm surprised if not, and if
not, would something like this be a reasonable feature to add in the
future?
Re: Using spamassassin modules from a git repo [ In reply to ]
On 8 Apr 2021, at 5:05, Michael Grant wrote:

> I'm running debian on my mail server. I use etckeeper to track
> changes in /etc.
>
> Often I run across modules such as spamassassin-esp and maybe I would
> consider playing with Jared Hall's CHAOS module.
>
> I'm curious what the recommended best practice is to install such
> modules from a git repo.

Best practice? Don't.

> For spamassassin-esp, I cloned the repo into my /etc/spamassassin/
> directory and then added this to my local.cf:

Apart from anything specific to SpamAssassin, putting code under /etc/
is a bad practice.

> loadplugin Mail::SpamAssassin::Plugin::Esp spamassassin-esp/Esp.pm
> include spamassassin-esp/Esp.cf
>
> This allows me to 'git pull' from this repository from time to time to
> update it. But it's not perfect, especially as I have local changes
> to Esp.cf. It's actually worse since I forked it to give back some
> changes but I'd say that's perhaps less usual.
>
> Furthermore, as I said, I use etckeeper and when I 'apt upgrade', I
> get
> constant warnings:
>
> modified: spamassassin/spamassassin-esp (modified content, untracked
> content)

I'm not familiar with etckeeper but it seems like it is working as
designed and that it may be designed for a purpose at odds with how you
actually want to manage your system.

> So clearly it's not ideal to clone a spamassassin module into
> /etc/spamassassin!
>
> I'm curious if someone has a clean solution here that allows updating
> the module from time to time from git.

That module? No. I have the utmost respect for and trust in Giovanni
Bechis and use his code every day, but that module as it exists at
Github is not structured to be used from a git checkout. The 4
significant files all properly belong in different places. The specific
proper places would depend on how your Perl and SA installations were
configured.

> I realize this may be more a debian question and I may post it on the
> debian-users list if I don't get any decent replies here.

I expect this qualifies as an indecent reply...

--
Bill Cole
bill@scconsult.com or billcole@apache.org
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Not Currently Available For Hire
Re: Using spamassassin modules from a git repo [ In reply to ]
On 4/8/21 7:51 PM, Bill Cole wrote:
>> So clearly it's not ideal to clone a spamassassin module into
>> /etc/spamassassin!
>>
>> I'm curious if someone has a clean solution here that allows updating
>> the module from time to time from git.
>
> That module? No. I have the utmost respect for and trust in Giovanni Bechis and use his code every day, but that module as it exists at Github is not structured to be used from a git checkout. The 4 significant files all properly belong in different places. The specific proper places would depend on how your Perl and SA installations were configured.

To update SpamAssassin module from time to time from Git I am using Puppet/Ansible that will put the code in the right places.
On simpler install I am using a Makefile like this one:

----------------------------------------------------------------------------------------------------
install:
pod2man Esp.pm > "/usr/share/man/man3p/Mail::SpamAssassin::Plugin::Esp.3p"
perl -cw Esp.pm && podlint Esp.pm && cp Esp.{cf,pm,pre} /etc/mail/spamassassin/
----------------------------------------------------------------------------------------------------

Then I can run git pull from the directory and run make install to copy all files to the correct places.

Giovanni
Re: Using spamassassin modules from a git repo [ In reply to ]
> To update SpamAssassin module from time to time from Git I am using Puppet/Ansible that will put the code in the right places.
> On simpler install I am using a Makefile like this one:
>
> ----------------------------------------------------------------------------------------------------
> install:
> pod2man Esp.pm > "/usr/share/man/man3p/Mail::SpamAssassin::Plugin::Esp.3p"
> perl -cw Esp.pm && podlint Esp.pm && cp Esp.{cf,pm,pre} /etc/mail/spamassassin/
> ----------------------------------------------------------------------------------------------------
>
> Then I can run git pull from the directory and run make install to copy all files to the correct places.

Thanks Giovanni, yes, this is what one would normally do, drop the
files into /etc/spamassassin (linked from /etc/mail/spamassassin on my
system).

This also solves my initial problem of git repo within git repo. But
it doesn't solve my desire to keep things in one place. It's true
that with this particular module the file names are the same. And
it's also true that the man page (if I wanted to be able to read it
with the man command) would need to go in a different place.

I do kind of like Tom Hendrikx idea of putting cloning the folder into
somewhere in /usr/local/etc and putting a modified pre file in
/etc/spamassassin/. But it's true it's not perfect.

The next step in this I suppose could be to build a deb or rpm file
around these contributed modules. But I doubt people are going to
want to build and maintain packages for each of the different
unix/linux/other OSs out there.

Maybe just recommending module developers to put in a simple Makefile
with an install and uninstall target? I don't know if that's the
right answer. It does feel like this should be a bit more admin
friendly, by that I mean it should be more than lore to know the right
way to install spamassassin modules in a maintainable way with a
system.

Thanks all for the answers here.
Re: Using spamassassin modules from a git repo [ In reply to ]
> I do kind of like Tom Hendrikx idea of putting cloning the folder into
> somewhere in /usr/local/etc and putting a modified pre file in
> /etc/spamassassin/. But it's true it's not perfect.
Yes.? Tom's idea is correctish; perhaps a more "true" solution for some.

ZERO-TRUST.? SpamAssassin is equally insecure no matter where
you run it; like 3.4.5 is the end of it?
>
> The next step in this I suppose could be to build a deb or rpm file
> around these contributed modules. But I doubt people are going to
> want to build and maintain packages for each of the different
> unix/linux/other OSs out there.
Not to be a bubble-buster or anything, but perhaps you're seeking
a solution for a problem that doesn't exist?

Seriously, nobody is breaking down doors to get a plugin.
> Maybe just recommending module developers to put in a simple Makefile
> with an install and uninstall target? I don't know if that's the
> right answer. It does feel like this should be a bit more admin
> friendly, by that I mean it should be more than lore to know the right
> way to install spamassassin modules in a maintainable way with a
> system.
What is maintainable about third-party plugins?? Hell, what is the
average life-span of a third-party plugin?? Not long.
> Thanks all for the answers here.
No problem.? This is one list's 537 opinions!