Bug 2555 - Add Exim-like search algorithm for virtual-user config-files
Summary: Add Exim-like search algorithm for virtual-user config-files
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamc/spamd (show other bugs)
Version: 2.60
Hardware: All All
: P5 enhancement
Target Milestone: 3.4.2
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on: 5138 2536
Blocks:
  Show dependency tree
 
Reported: 2003-10-06 05:18 UTC by Martin Treusch von Buttlar
Modified: 2018-09-04 22:35 UTC (History)
4 users (show)



Attachment Type Modified Status Actions Submitter/CLA Status
Exim-style lookup for virtual-user config-files patch None Martin Treusch von Buttlar [NoCLA]
Updated patch to v3.2.5 patch None Martin Treusch von Buttlar [NoCLA]
Updated patch to v3.3.1 patch None Martin Treusch von Buttlar [NoCLA]
Patch adapted to 3.4 and trunk of 2018-08-31 patch None Bill Cole [HasCLA]
Patch to documentation, describing the addition of '%x' token patch None Bill Cole [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Treusch von Buttlar 2003-10-06 05:18:04 UTC
This patch adds another search alogrithm for virtual-user config-files, trying
first the full email-address and if it fails it uses only the domain-part.

It applies to 2.55 and 2.60 (with offsets) and works with our setup for 3 months.
Comment 1 Martin Treusch von Buttlar 2003-10-06 05:18:37 UTC
Created attachment 1457 [details]
Exim-style lookup for virtual-user config-files
Comment 2 Malte S. Stretz 2003-10-06 05:31:41 UTC
currently working on that code, will have a look 
Comment 3 Daniel Quinlan 2005-03-30 01:08:23 UTC
move bug to Future milestone (previously set to Future -- I hope)
Comment 4 Martin Treusch von Buttlar 2009-06-23 15:10:10 UTC
Created attachment 4467 [details]
Updated patch to v3.2.5
Comment 5 Martin Treusch von Buttlar 2011-12-30 21:20:19 UTC
Created attachment 5029 [details]
Updated patch to v3.3.1
Comment 6 Kevin A. McGrail 2011-12-30 21:43:52 UTC
Martin,

Can I assume you've been using this since 2003 essentially?  Are their any caveats that you see to implementing this because it looks like it uses the defaults as a fall back.

At worst, it looks like this needs to be checked if it patches clean against trunk and the documentation updated about the feature.
Comment 7 Martin Treusch von Buttlar 2011-12-30 23:24:11 UTC
Kevin,

yes, you are right - this patch works with approximately 20,000 emails since 2003 per day. The default behaviour of spamassassin is retained, as the new code is only used if the newly introduced "%x" replacement appears in the configured directory.

I would be happy to provide additional documentation if you could point me to the appropriate section.
Comment 8 Kevin A. McGrail 2012-01-18 22:14:26 UTC
(In reply to comment #7)
> Kevin,
> 
> yes, you are right - this patch works with approximately 20,000 emails since
> 2003 per day. The default behaviour of spamassassin is retained, as the new
> code is only used if the newly introduced "%x" replacement appears in the
> configured directory.
> 
> I would be happy to provide additional documentation if you could point me to
> the appropriate section.

I'm targeting this for 3.4.0.  It won't block the release and I would like some votes on it but first, I need to see documentation.

From reviewing your patch, it changes the behavior of the --virtual-config-dir

So that is the documentation to change, I believe.

Specifically:

--virtual-config-dir=pattern
           This option specifies where per-user preferences can be found for virtual users, for the -x switch. The pattern is used as a base pattern for the directory name.  Any of the following escapes can be
           used:

           %u -- replaced with the full name of the current user, as sent by spamc.
           %l -- replaced with the 'local part' of the current username.  In other words, if the username is an email address, this is the part before the "@" sign.
           %d -- replaced with the 'domain' of the current username.  In other words, if the username is an email address, this is the part after the "@" sign.
           %% -- replaced with a single percent sign (%).

           So for example, if "/vhome/users/%u/spamassassin" is specified, and spamc sends a virtual username of "jm@example.com", the directory "/vhome/users/jm@example.com/spamassassin" will be used.

           The set of characters allowed in the virtual username for this path are restricted to:

                   A-Z a-z 0-9 - + _ . , @ =

           All others will be replaced by underscores ("_").

           This path must be a writable directory.  It will be created if it does not already exist.  If a file called user_prefs exists in this directory (note: not in a ".spamassassin" subdirectory!), it will be
           loaded as the user's preferences.  The Bayes databases for that user will be stored in this directory.

           Note that this requires that -x is used, and cannot be combined with SQL- or LDAP-based configuration.

           The pattern must expand to an absolute directory when spamd is running daemonized (-d).

           Currently, use of this without -u is not supported. This inhibits setuid.
Comment 9 Kevin A. McGrail 2013-06-21 16:25:27 UTC
Moving all open bugs where target is defined and 3.4.0 or lower to 3.4.1 target
Comment 10 Kevin A. McGrail 2015-04-07 13:38:31 UTC
Martin,

Would like to get this patched in but need a CLA (see https://www.apache.org/licenses/) and some pointers for documentation as noted. 

Moving to 3.4.2 unless you can respond in the next day or two.

Regards,
KAM
Comment 11 Bill Cole 2018-08-31 23:58:29 UTC
Created attachment 5591 [details]
Patch adapted to 3.4 and trunk of 2018-08-31

Do we really need a CLA for this relatively simple addition? 
Pushing to 3.4.3 pending a CLA or judgment of triviality
Comment 12 Kevin A. McGrail 2018-09-01 00:31:47 UTC
In reviewing again, it's trivial logic so I think you can do it without a CLA but see my note with all the documentation changes in comment 8
Comment 13 Martin Treusch von Buttlar 2018-09-04 06:09:58 UTC
I signed and sent the ICLA just now.

Cheers

Martin
Comment 14 Kevin A. McGrail 2018-09-04 14:37:10 UTC
Bringing back to 3.4.2 because it's trivial AND we have a CLA coming :-)


Bill, can you commit before our Noon deadline today?
Comment 15 Bill Cole 2018-09-04 15:21:59 UTC
(In reply to Kevin A. McGrail from comment #14)
> Bringing back to 3.4.2 because it's trivial AND we have a CLA coming :-)
> 
> 
> Bill, can you commit before our Noon deadline today?

Code committed to 3.4 and trunk r1839832 

Working on documentation.
Comment 16 Bill Cole 2018-09-04 16:25:17 UTC
Created attachment 5593 [details]
Patch to documentation, describing the addition of '%x' token

Documents code already committed. 

NEEDS REVIEW BEFORE COMMIT
Comment 17 Kevin A. McGrail 2018-09-04 16:32:33 UTC
Per https://wiki.apache.org/spamassassin/DevelopmentMode, documentation isn't required to follow R-T-C
Comment 18 Bill Cole 2018-09-04 22:35:24 UTC
Fixed in r 1840050