Bug 5637 - [review] bayes_file_mode is handled incorrectly when creating bayes.mutex
Summary: [review] bayes_file_mode is handled incorrectly when creating bayes.mutex
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamassassin (show other bugs)
Version: 3.2.3
Hardware: Other other
: P5 normal
Target Milestone: 3.2.4
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard: can be commited
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-31 14:05 UTC by Mihaly Barasz
Modified: 2007-12-28 05:15 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status
trivial fix patch None Mihaly Barasz [NoCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Mihaly Barasz 2007-08-31 14:05:35 UTC
bayes_file_mode value is not handled correctly in Locker/Flock.pm, which results
in weird permissions on bayes.mutex. Which then results in

bayes: expire_old_tokens: locker: safe_lock: cannot create lockfile
/var/lib/spamd/bayes.mutex: Permission denied

kind of errors.

The root of the problem is that everywhere except Flock.pm:safe_lock() it is
used as string. (It's always used as oct($main->{conf}->{bayes_file_mode}).) 
And safe_lock() could use octal string and numeric values. The default is string
'0700' which works.
But otherwise it's specified as $CONF_TYPE_NUMERIC, so if I put 0770 in config
file, it'll get _decimal_ value 700, which is octal 1402, which is bad. (The
resulting bayes.mutex file get permissions as -r------w-)

Sorry for the lengthy description. Anyway, the fix is trivial: just specify it
as $CONF_TYPE_STRING. Patch is attached.
Comment 1 Mihaly Barasz 2007-08-31 14:07:37 UTC
Created attachment 4112 [details]
trivial fix
Comment 2 Phil Randal 2007-11-22 14:34:47 UTC
Nudges the SA developers...

I hit this bug today.

Any chance of the fix going in to 3.2.4 and 3.3.0?
Comment 3 Justin Mason 2007-11-23 01:50:58 UTC
thanks for the nudge! I'd missed it.

+1 from me

it's in 3.3.0 trunk:

: jm 82...; svn commit -m "bug 5637: bayes_file_mode is handled incorrectly when
creating bayes.mutex, resulting in incorrect permissions on that file; fix by
Mihaly Barasz" lib
Sending        lib/Mail/SpamAssassin/Conf.pm
Sending        lib/Mail/SpamAssassin/Locker/Flock.pm
Transmitting file data ..
Committed revision 597617.
Comment 4 Sidney Markowitz 2007-12-21 12:29:46 UTC
+1

In case someone else is as naive about using the patch program as I was, this
attachment requires a "-p1" option to patch instead of the usual p0.
Comment 5 Doc Schneider 2007-12-22 16:29:33 UTC
+1
Comment 6 Justin Mason 2007-12-28 05:15:55 UTC
applied to 3.2.x:

: jm 238...; svn commit -m "bug 5637: bayes_file_mode is handled incorrectly
when creating bayes.mutex, resulting in incorrect permissions on that file; fix
by Mihaly Barasz"
Sending        lib/Mail/SpamAssassin/Conf.pm
Sending        lib/Mail/SpamAssassin/Locker/Flock.pm
Transmitting file data ..
Committed revision 607236.