Re: Amavis / SpamAssassin ignoring userpref in SQL

Hans van Zijst <[email protected]>
Newsgroups gmane.mail.virus.amavis.user
Message-ID <[email protected]>
Thanks Damian,


On 16-09-2021 00:23, Damian wrote:
>> @sa_userconf_maps    = ({ '.*' => 'sql:' });
> 
> The left-hand-side is not a regex in a hash lookup.

Turning @sa_userconf_maps into a scalar works, although I'm not really 
sure why. It's been a long time since I did any Perl programming, but I 
thought variables that start with an @ are supposed to be arrays. Guess 
a scalar is a one-element array then.

Anyway, that bit works: every userconf is now pulled from SQL by doing this:

@sa_userconf_maps = 'sql:';


>> @sa_username_maps    = new_RE ( [  '.*' => '$GLOBAL' ] );
> 
> If you want static lookup results, use these:
> 
>> @sa_userconf_maps = 'sql:';
>> @sa_username_maps = '$GLOBAL';

I didn't really want static lookups, I wanted every user to be able to 
configure his own settings. Problem is that I don't understand exactly 
what I'm doing in Amavis, documentation is scattered and although I'm 
very good at searching the Internet, I'm not so good at actually finding ;-)

What I ended up with is this:

@sa_userconf_maps  = 'sql:';
@sa_username_maps  = new_RE ( [ qr'^([^@]+@.*)'i => '${1}' ] );

I found that RE on this same mailinglist:

https://www.mail-archive.com/[email protected]/msg00868.html

Apparently $1 contains the receiving e-mail address when the RE is parsed.

Now I'll have to find a way to make sure the sa_user field in the policy 
table contains the correct value for each user.

Kind regards,

Hans van Zijst
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.