> > I tried using '[EMAIL PROTECTED]', '[EMAIL PROTECTED]' and > '@testdomain.com' as the username in our SA database but it > doesn't work (using 2.61). Not a *huge* problem, we can > either just use @GLOBAL or just set them in the actual .cf > files, but it would be cool to have per-domain whitelists > when using SQL preferences... >
oopps... forgot the patch to ConfStoreSQL.pm - this is actually against 2.61, but will work against nearly all versions. diff -Naur Mail-SpamAssassin-2.61.vanilla/lib/Mail/SpamAssassin/ConfSourceSQL.pm Mail-SpamAssassin-2.61/lib/Mail/SpamAssassin/ConfSourceSQL.pm --- Mail-SpamAssassin-2.61.vanilla/lib/Mail/SpamAssassin/ConfSourceSQL.pm Fri Feb 14 12:43:08 2003 +++ Mail-SpamAssassin-2.61/lib/Mail/SpamAssassin/ConfSourceSQL.pm Thu Dec 11 13:58:46 2003 @@ -99,20 +99,34 @@ my $f_value = $main->{conf}->{user_scores_sql_field_value}; my $f_username = $main->{conf}->{user_scores_sql_field_username}; my $f_table = $main->{conf}->{user_scores_sql_table}; + my ($pw_user,$pw_domain); my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'PrintError' => 0}); + if ($username =~ m/(.*)\@(.*)/) { + $pw_user = $1; $pw_domain = $2; + $pw_domain =~ s/[^A-z0-9\.\-]//g; # remove invalid chars in domain name + } + if($dbh) { my $sql = "select $f_preference, $f_value from $f_table where ". "$f_username = ".$dbh->quote($username). " or $f_username = 'GLOBAL'". - " or $f_username = '[EMAIL PROTECTED]' order by $f_username asc"; + " or $f_username = '[EMAIL PROTECTED]'". + " or $f_username = '\$GLOBAL'"; + dbg("pull global user prefs from sql"); + + if ($pw_domain) { + dbg("pull domain specific user prefs for $pw_domain from sql"); + $sql .= " or $f_username = '\%${pw_domain}'"; + } + $sql .= " order by $f_username asc"; my $sth = $dbh->prepare($sql); if($sth) { my $rv = $sth->execute(); if($rv) { - dbg("retrieving prefs for $username from SQL server"); + dbg("pull user prefs for $username from sql"); my @row; my $text = ''; while(@row = $sth->fetchrow_array()) { ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click _______________________________________________ Spamassassin-talk mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/spamassassin-talk