Lines 163-168
Link Here
|
163 |
'port|p=s' => \$opt{'port'}, |
163 |
'port|p=s' => \$opt{'port'}, |
164 |
'Q' => \$opt{'setuid-with-sql'}, |
164 |
'Q' => \$opt{'setuid-with-sql'}, |
165 |
'q' => \$opt{'sql-config'}, |
165 |
'q' => \$opt{'sql-config'}, |
|
|
166 |
'spamc-configs' => \$opt{'spamc_config_dir'}, |
166 |
'server-cert=s' => \$opt{'server-cert'}, |
167 |
'server-cert=s' => \$opt{'server-cert'}, |
167 |
'server-key=s' => \$opt{'server-key'}, |
168 |
'server-key=s' => \$opt{'server-key'}, |
168 |
'setuid-with-ldap' => \$opt{'setuid-with-ldap'}, |
169 |
'setuid-with-ldap' => \$opt{'setuid-with-ldap'}, |
Lines 493-498
Link Here
|
493 |
|
494 |
|
494 |
my $current_user; |
495 |
my $current_user; |
495 |
|
496 |
|
|
|
497 |
my $spc_user_prefs; # used for prefs location passed from spamc |
496 |
my $client; # used for the client connection ... |
498 |
my $client; # used for the client connection ... |
497 |
my $childlimit; # max number of kids allowed |
499 |
my $childlimit; # max number of kids allowed |
498 |
my $clients_per_child; # number of clients each child should process |
500 |
my $clients_per_child; # number of clients each child should process |
Lines 903-908
Link Here
|
903 |
die "error returned from copy_config, no Storable module?\n"; |
905 |
die "error returned from copy_config, no Storable module?\n"; |
904 |
} |
906 |
} |
905 |
undef $current_user; |
907 |
undef $current_user; |
|
|
908 |
undef $spc_user_prefs; |
906 |
|
909 |
|
907 |
} |
910 |
} |
908 |
|
911 |
|
Lines 1026-1032
Link Here
|
1026 |
$hdrs, $client, |
1029 |
$hdrs, $client, |
1027 |
{ |
1030 |
{ |
1028 |
'Content-length' => \&got_clen_header, |
1031 |
'Content-length' => \&got_clen_header, |
1029 |
'User' => \&got_user_header |
1032 |
'User' => \&got_user_header, |
|
|
1033 |
'UserPrefs' => \&got_userprefs_header |
1030 |
} |
1034 |
} |
1031 |
); |
1035 |
); |
1032 |
|
1036 |
|
Lines 1319-1324
Link Here
|
1319 |
return 0; |
1323 |
return 0; |
1320 |
} |
1324 |
} |
1321 |
|
1325 |
|
|
|
1326 |
# |
1327 |
# Handle a static user_prefs location that is passed |
1328 |
# to us from spamc for virtual directories that |
1329 |
# can't be guessed |
1330 |
# |
1331 |
sub got_userprefs_header { |
1332 |
my ( $client, $header, $value ) = @_; |
1333 |
|
1334 |
if ( $value !~ /^([\x20-\xFF]*)$/ ) { |
1335 |
protocol_error("(UserPrefs header contains control chars)"); |
1336 |
return 1; |
1337 |
} |
1338 |
$spc_user_prefs = $1; |
1339 |
if ( $opt{'spamc_config_dir'} ) { |
1340 |
my $safedir = $spc_user_prefs; |
1341 |
$safedir =~ s/\%\%/\%/g; |
1342 |
my $prefsfile = $safedir . '/user_prefs'; |
1343 |
|
1344 |
# Log that a static prefs file location is being used for the user |
1345 |
logmsg("Using static prefs file provided by spamc for $current_user: $prefsfile"); |
1346 |
|
1347 |
if ( -f $prefsfile ) { |
1348 |
# Found a config, Load it. |
1349 |
$spamtest->read_scoreonly_config($prefsfile); |
1350 |
} else { |
1351 |
my $cf_file = $prefsfile; |
1352 |
create_default_cf_if_needed( $cf_file, $current_user ); |
1353 |
$spamtest->read_scoreonly_config($prefsfile); |
1354 |
} |
1355 |
|
1356 |
# Assume that $safedir will be a writable directory we can |
1357 |
# use for AWL, Bayes dbs etc. |
1358 |
# we should sanitize $current_user into something else just |
1359 |
# in case |
1360 |
$spamtest->signal_user_changed( |
1361 |
{ |
1362 |
username => $current_user, |
1363 |
userstate_dir => $safedir, |
1364 |
user_dir => $safedir, |
1365 |
} |
1366 |
); |
1367 |
|
1368 |
} |
1369 |
return 0; |
1370 |
} |
1371 |
|
1322 |
sub got_clen_header { |
1372 |
sub got_clen_header { |
1323 |
my ( $hdrs, $header, $value ) = @_; |
1373 |
my ( $hdrs, $header, $value ) = @_; |
1324 |
if ( $value !~ /^(\d*)$/ ) { |
1374 |
if ( $value !~ /^(\d*)$/ ) { |
Lines 1426-1432
Link Here
|
1426 |
); |
1476 |
); |
1427 |
|
1477 |
|
1428 |
} |
1478 |
} |
1429 |
else { |
1479 |
elsif ( !$opt{'spamc_config_dir'} ) { |
1430 |
create_default_cf_if_needed( $cf_file, $username ); |
1480 |
create_default_cf_if_needed( $cf_file, $username ); |
1431 |
$spamtest->read_scoreonly_config($cf_file); |
1481 |
$spamtest->read_scoreonly_config($cf_file); |
1432 |
$spamtest->signal_user_changed( |
1482 |
$spamtest->signal_user_changed( |