You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Justin Mason <jm...@jmason.org> on 2004/02/24 23:31:08 UTC

Re: Interest in a patch for Mail/SpamAssassin/ConfSourceSQL.pm for enabling a per-user config with mysql?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


The problems we've had with ConfSourceSQL is that it's effectively
unmaintained, and the dev team didn't have enough SQL experience
to know what's likely to work portably etc.   However now that 
we have Michael Parker on board he might be able to review these ;)
Michael?

- --j.

Adam Denenberg writes:
>Erik,
>
> Inside ConfSourceSql.pm just do 2 things
>
>1) pull out the domain like    
>
>my ($local, $domain) = split(/\@/, $username);
>
>2) then re-order the select query .. i used unions, there may be a
>better way
>
>   my $sql = "select $f_preference, $f_value  from $f_table where ".
>        " $f_username = 'GLOBAL' union ".
>        " select $f_preference, $f_value  from $f_table where ".
>        " $f_username = '\@GLOBAL' union ".
>        " select $f_preference, $f_value  from $f_table where ".
>        " $f_username = ".$dbh->quote($domain). " union " .
>        " select $f_preference, $f_value  from $f_table where ".
>        " $f_username = ".$dbh->quote($username);
> 
>this will order the preferences, with the more specific ones overriding
>the previous ones. If no domain or user pref is found, the gloabal will
>be used.. and so on.
>
>  SA will use the last one found so this will probably do what you
>want.. it seems to work for us.
>
>:adam
>   
>
>   
>On Tue, 2004-02-24 at 15:49, Erik Wasser wrote:
>> Hi SA friends,
>> 
>> today I turned on the "MySQL-connection" of SA so I can save the config 
>> in a mysql database described at 
>> "http://www.spamassassin.org/full/2.6x/dist/sql/README". If was 
>> satisfied with the results, but one little thing scratched my back. B-)
>> 
>> There a global and a per user config like this example:
>> 
>> +--------+-------------+-----------------+-------+
>> | prefid | username    | preference      | value |
>> +--------+-------------+-----------------+-------+
>> |      1 | GLOBAL      | rewrite_subject | 0     |
>> |      2 | foo@bar.com | rewrite_subject | 1     |
>> +--------+-------------+-----------------+-------+
>> 
>> The subjects will be *not* rewritten except for the user foo@bar.com. So 
>> far so good: but I want a per site config (one setting for a whole 
>> domain) too, so I extended the table a little bit:
>> 
>> +--------+-------------+-----------------+-------+ The 'prefid'
>> | prefid | username    | preference      | value | is not
>> +--------+-------------+-----------------+-------+ important
>> |      1 | GLOBAL      | rewrite_subject | 0     | for the
>> |      2 | foo@bar.com | rewrite_subject | 0     | ordering!
>> |      3 | bar.com     | rewrite_subject | 1     |
>> +--------+-------------+-----------------+-------+
>> 
>> Mails to "foo@bar.com" are not(!) marked.
>> Mails to other members of bar.com are marked.
>> All other's are not marked. Got it?
>> 
>> 1) global    (least important)
>> 2) per site
>> 3) per user  (most important)
>> 
>> Advantages:
>> - backward compabtible to the "@GLOBAL" and "GLOBAL" settings.
>> - only changes made in "Mail/SpamAssassin/ConfSourceSQL.pm"
>> - no changes in calling the method 'load_with_dbi'
>> - the modified SQL query is fully ANSI compatible (I hope so. B-)
>>   No weird MySQL stuff in here.
>> 
>> Disadvantages:
>> - The sorting of the parameter of the query is now done by perl
>> 
>> My Questions:
>> 
>> - Is anybody interessested in the patch?
>> - Is there any chance that this patch goes in the offical release? I 
>> would like it!
>> 
>> Result:
>> 
>> - Please drop a mail if you are interessested I don't wan't to polute 
>> the ML more than it's needed.
>> 
>> Feedback is welcome.
>> 
>> BTW: Thanks to the SA maintainers for the great work. You guys saved my 
>> inbox. B-)
>> 
>> P.S: I used SA 2.60 for the work but there is no change in the file 
>> "Mail/SpamAssassin/ConfSourceSQL.pm" between 2.60 and 2.63.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Exmh CVS

iD8DBQFAO9CsQTcbUG5Y7woRAuGjAKCaF1SG4lrrSnS7+4PELXk7+R6adACgzZaO
bI4Z2wRscnOtg2sXEC4VNAo=
=vYQQ
-----END PGP SIGNATURE-----


Re: Interest in a patch for Mail/SpamAssassin/ConfSourceSQL.pm for enabling a per-user config with mysql?

Posted by Michael Parker <pa...@pobox.com>.
On Tue, Feb 24, 2004 at 02:31:08PM -0800, Justin Mason wrote:
> 
> The problems we've had with ConfSourceSQL is that it's effectively
> unmaintained, and the dev team didn't have enough SQL experience
> to know what's likely to work portably etc.   However now that 
> we have Michael Parker on board he might be able to review these ;)
> Michael?
> 

I'm planning to pick this up and work on it.  The original itch behind
SQL based bayes and awl was me moving to ConfSourceSQL.  Now that I've
finished that part, I can move on :)

Michael

Re: Interest in a patch for Mail/SpamAssassin/ConfSourceSQL.pm for enabling a per-user config with mysql?

Posted by Michael Parker <pa...@pobox.com>.
On Tue, Feb 24, 2004 at 02:31:08PM -0800, Justin Mason wrote:
> 
> The problems we've had with ConfSourceSQL is that it's effectively
> unmaintained, and the dev team didn't have enough SQL experience
> to know what's likely to work portably etc.   However now that 
> we have Michael Parker on board he might be able to review these ;)
> Michael?
> 

I'm planning to pick this up and work on it.  The original itch behind
SQL based bayes and awl was me moving to ConfSourceSQL.  Now that I've
finished that part, I can move on :)

Michael