SA Bugzilla – Bug 2866
patch: allow user config file in places other than ~/.spamassassin
Last modified: 2006-10-19 06:39:34 UTC
Due to the peculiarities of our setup (we use AFS), we store user_prefs and the Bayes database in /mail/<username>/spamassassin/ , rather than ~/.spamassassin/ , which is not writable by the MTA. The first patch below adds a new replaceable keyword "__username__" to Mail/SpamAssassassin.pm which allows us to specify /mail/__username__ in local.cf The second patch fixes spamd/spamd.raw to use the default_userstate_dir and default_userprefs_path settings from local.cf, rather than assume that they're in ~/.spamassassin/ --- Mail-SpamAssassin-2.61/lib/Mail/SpamAssassin.pm 2003/12/16 23:17:20 1.1 +++ Mail-SpamAssassin-2.61/lib/Mail/SpamAssassin.pm 2003/12/16 23:18:41 @@ -1369,6 +1371,7 @@ $path =~ s/__def_rules_dir__/$self->{DEF_RULES_DIR} || ''/ges; $path =~ s{__prefix__}{$self->{PREFIX} || $Config{prefix} || '/usr'}ges; $path =~ s{__userstate__}{$self->get_and_create_userstate_dir()}ges; + $path =~ s{__username__}{$self->{username}}gs; $path =~ s/^\~([^\/]*)/$self->expand_name($1)/es; return Mail::SpamAssassin::Util::untaint_file_path ($path); --- Mail-SpamAssassin-2.61/spamd/spamd.raw 2003/12/16 23:16:26 1.1 +++ Mail-SpamAssassin-2.61/spamd/spamd.raw 2003/12/16 23:56:49 @@ -943,15 +943,21 @@ logmsg "info: setuid to $username succeeded"; } } - + $spamtest->{username} = $name; + + my $cf_file; # # If vpopmail config enabled then set $dir to virtual homedir # if ($opt{'vpopmail'}) { $dir = `$dir/bin/vuserinfo -d $username`; chomp ($dir); + $dir .= "/.spamassassin"; + $cf_file = $dir . "/user_prefs"; + } else { + $dir = $spamtest->first_existing_path(@Mail::SpamAssassin::default_userstate_dir); + $cf_file = $spamtest->first_existing_path(@Mail::SpamAssassin::default_userprefs_path); } - my $cf_file = $dir."/.spamassassin/user_prefs"; # # If vpopmail config enabled then pass virtual homedir onto create_default_cf_needed @@ -972,8 +978,7 @@ } else { create_default_cf_if_needed ($cf_file, $username); $spamtest->read_scoreonly_config ($cf_file); - $spamtest->signal_user_changed ({ username => $username, - user_dir => $dir }); + $spamtest->signal_user_changed ({ username => $username }); } return 1;
Is this something that --virtual-config-dir could rememdy?
we also now support "include" from user prefs files...
move bug to Future milestone (previously set to Future -- I hope)
implementing bug 5138 would be the perfect way to do this