~ubuntu-branches/ubuntu/utopic/spamassassin/utopic-updates

« back to all changes in this revision

Viewing changes to lib/Mail/SpamAssassin/Conf/SQL.pm

  • Committer: Package Import Robot
  • Author(s): Noah Meyerhans
  • Date: 2014-02-14 22:45:15 UTC
  • mfrom: (0.8.1) (0.6.2) (5.1.22 sid)
  • Revision ID: package-import@ubuntu.com-20140214224515-z1es2twos8xh7n2y
Tags: 3.4.0-1
* New upstream version! (Closes: 738963, 738872, 738867)
* Scrub the environment when switching to the debian-spamd user in
  postinst and cron.daily. (Closes: 738951)
* Enhancements to postinst to better manage ownership of
  /var/lib/spamassassin, via Iain Lane <iain.lane@canonical.com>
  (Closes: 738974)

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
sub load {
93
93
   my ($self, $username) = @_;
94
94
 
95
 
   my $dsn = $self->{main}->{conf}->{user_scores_dsn};
 
95
   my $conf = $self->{main}->{conf};
 
96
   my $dsn = $conf->{user_scores_dsn};
96
97
   if (!defined($dsn) || $dsn eq '') {
97
98
     dbg("config: no DSN defined; skipping sql");
98
99
     return 1;
106
107
     1;
107
108
   } or do {
108
109
     my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
109
 
     warn "config: failed to load user ($username) scores from SQL database: $eval_stat\n";
110
 
     return 0;
 
110
     if ($conf->{user_scores_fail_to_global}) {
 
111
       info("config: failed to load user (%s) scores from SQL database, ".
 
112
            "using a global default: %s", $username, $eval_stat);
 
113
       return 1;
 
114
     } else {
 
115
       warn sprintf(
 
116
            "config: failed to load user (%s) scores from SQL database: %s\n",
 
117
            $username, $eval_stat);
 
118
       return 0;
 
119
     }
111
120
   };
112
121
   return 1;
113
122
}
116
125
   my ($self, $username, $dsn) = @_;
117
126
 
118
127
   my $main = $self->{main};
119
 
   my $dbuser = $main->{conf}->{user_scores_sql_username};
120
 
   my $dbpass = $main->{conf}->{user_scores_sql_password};
121
 
   my $custom_query = $main->{conf}->{user_scores_sql_custom_query};
 
128
   my $conf = $main->{conf};
 
129
   my $dbuser = $conf->{user_scores_sql_username};
 
130
   my $dbpass = $conf->{user_scores_sql_password};
 
131
   my $custom_query = $conf->{user_scores_sql_custom_query};
122
132
 
123
133
   my $f_preference = 'preference';
124
134
   my $f_value = 'value';
153
163
       if ($rv) {
154
164
         dbg("config: retrieving prefs for $username from SQL server");
155
165
         my @row;
156
 
         my $text = '';
 
166
         my $config_text = '';
157
167
         while (@row = $sth->fetchrow_array()) {
158
 
           $text .= (defined($row[0]) ? $row[0] : '') . "\t" .
 
168
           $config_text .= (defined($row[0]) ? $row[0] : '') . "\t" .
159
169
               (defined($row[1]) ? $row[1] : '')  . "\n";
160
170
         }
161
 
         if ($text ne '') {
162
 
           $main->{conf}->{main} = $main;
163
 
           $main->{conf}->parse_scores_only(join('', $text));
164
 
           delete $main->{conf}->{main};
 
171
         if ($config_text ne '') {
 
172
           $conf->{main} = $main;
 
173
           $conf->parse_scores_only($config_text);
 
174
           delete $conf->{main};
165
175
         }
166
176
         $sth->finish();
167
177
         undef $sth;