Bug 5205

Summary: spamd ldap configuration with same time virtual-config-dir usage
Product: Spamassassin Reporter: braun
Component: spamc/spamdAssignee: SpamAssassin Developer Mailing List <dev>
Status: NEW ---    
Severity: enhancement CC: billcole
Priority: P5    
Version: 3.1.7   
Target Milestone: Undefined   
Hardware: All   
OS: other   
Whiteboard:

Description braun 2006-11-23 22:08:18 UTC
The idea of having the config in a ldap server, so that users can change their
config, without a local server account is great. But running spamd with none
local users, which still have their individual bayes databases but config in a
ldap server does not work, as the two options ldap-config and virtual-config-dir
are exclusive. So what would be great, is, that having the config in the ldap,
but still be able to use virtual-config-dir as data storage for the baayes and
auto-whitelist databases would be even better. 
I changed the code of spamd a little bit, so that exactly that works. So that I
can use the following command line options:
--virtual-config-dir="/spamassassin/users/%u" -x 
and configure the user_scores_dsn, user_scores_ldap_username,
user_scores_ldap_password entries in local.conf.

With the followinf small patch the following happens. If there is no user_prefs
file in the virtual config dir, it tries to find one in the ldap server.
But compared to the plian ldap-config option, if the config e.g. enables bayes
filtering, if still saved the users individual databses in the
virtual-config-dir. So I can have config in ldap but still individual users
databases. Best of two worlds so to say.

The small patch is, which works for me is:

*** spamd       Mon Nov 20 01:41:05 2006
--- /usr/perl/bin/spamd Wed Nov 22 04:37:19 2006
***************
*** 1818,1832 ****
      $userdir   = $dir;
      $prefsfile = $dir . '/user_prefs';
  
-     # Log that the default configuration is being used for a user.
-     info("spamd: using default config for $username: $prefsfile");
    }
  
    if ( -f $prefsfile ) {
! 
      # Found a config, load it.
      $spamtest->read_scoreonly_config($prefsfile);
    }
  
    # assume that $userdir will be a writable directory we can
    # use for Bayes dbs etc.
--- 1821,1838 ----
      $userdir   = $dir;
      $prefsfile = $dir . '/user_prefs';
  
    }
  
    if ( -f $prefsfile ) {
!     # Log that the default configuration is being used for a user.
!     info("spamd: using default config for $username: $prefsfile");
      # Found a config, load it.
      $spamtest->read_scoreonly_config($prefsfile);
    }
+   else {
+     info("ldap: entering handle_user_ldap($username)");
+     $spamtest->load_scoreonly_ldap($username);
+   }
  
    # assume that $userdir will be a writable directory we can
    # use for Bayes dbs etc.