>
> Thanks for the help!  Specifically, would I just add this to the file?  I
> found a copy at:
> /usr/lib/perl5/site_perl/5.6.0/Mail/SpamAssassin/ConfSourceSQL.pm
> Do I need to recompile SA after modifing this file?
> I put the new code you sent after
>    if($dbh) {
> I set the default value to 9.0 for testing.  It didn't seem to work.  Any
> ideas?
> Thanks!
> --chris davis
>
Sorry the code posted was non-functional (i should have made that more
clear)..it was just to give an idea.. the code posted below I installed
and it ran and appears to work .. from sql.log


1121 Query       select preference, value  from userpref where username = 'xxxxx'
1121 Query       insert into userpref values('jlkxxx','auto_whitelist_factor','0.5','')
1121 Query       insert into userpref values('jlkxxx','required_hits','5.0','')
1121 Query       insert into userpref values('jlkxxx','defang_mime','1','')
1121 Query       insert into userpref values('jlkxxx','use_terse_report','0','')
1121 Query       insert into userpref values('jlkxxx','rewrite_subject','1','')
1121 Query       insert into userpref values('jlkxxx','report_header','0','')

But I think this will only bog down spamd..since it increases the size of
the sql database thus increasing query time (plus the insert times for new
users)..

I'm sure there are better ways to do this.. I rely on local.cf for my
defaults and GLOBAL for any global settings and only have entries of
non-defaults for users.

You only would need to modify the .pm file in the /usr/lib/perl5 path and
restart spamd but I'd get advice from the experts first..of which I am
definitely not one :)

Hope this helps.


   if($dbh) {
      my $sql;
        my $sth;
        my $rv;
        my @row;
        #Preload database with default values specified in hash_ref $defaults
        $sql = "select preference, value  from userpref where username = " . 
$dbh->quote($username) ."";
        $sth = $dbh->prepare($sql);
        if($sth) {
        $rv  = $sth->execute();
                if($rv) {
                        #add your defaults here
                        my $defaults={
                                'required_hits'         => '5.0',
                                'auto_whitelist_factor' => '0.5',
                                'use_terse_report'      => '0',
                                'report_header'         => '0',
                                'rewrite_subject'       => '1',
                                'defang_mime'           => '1',
                        };
                        if(!(@row = $sth->fetchrow_array())) {
                                $sth->finish(); #tidy up previous select handle
                                #no existing entries for this user so add some defaults
                                #insert each preference for user
                                my $default_preference;
                                foreach $default_preference (keys %$defaults){
$sql = "insert into userpref 
values(".$dbh->quote($username).",'$default_preference','$$defaults{$default_preference}','')";
                                        $sth = $dbh->prepare($sql);
                                        $sth->execute();
                                }
                        }
                $sth->finish();
                } else { $sth->finish(); warn "SQL Error: $sql\n".$sth->errstr."\n"; }
        } else { warn "SQL Error: " . $dbh->errstr . "\n"; }

      #continue normally
(remove the 'my' preceding the followin $sth,$rv, and @row or you'll get
warnings



>
>
> -------------------------------------------------------
> Sponsored by:
> ThinkGeek at http://www.ThinkGeek.com/
> _______________________________________________
> Spamassassin-talk mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/spamassassin-talk
>



-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to