Bug 3595 - [review] Wrong bayes and AWL files being opened
Summary: [review] Wrong bayes and AWL files being opened
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamc/spamd (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: PC Linux
: P3 blocker
Target Milestone: 3.0.0
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
: 3525 3611 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-07-12 04:28 UTC by Al Smith
Modified: 2004-07-15 11:47 UTC (History)
2 users (show)



Attachment Type Modified Status Actions Submitter/CLA Status
test patch patch None Theo Van Dinter [HasCLA]
call copy_config also when virtual-config-dir is set patch None Al Smith [NoCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Al Smith 2004-07-12 04:28:40 UTC
I run spamd with --auth-ident; when a connection comes in I see spamd
sometimes trying to open another user's bayes and AWL files. This is
with 3.0.0-pre2.

ident_username = ajs, spamc_username = ajs
logmsg: info: setuid to ajs succeeded  
debug: user has changed
debug: bayes: no dbs present, cannot tie DB R/O:
/u2/martin/.spamassassin/bayes_toks
debug: Score set 1 chosen.
logmsg: processing message <086e01c46802$74622970$6401a8c0@puff> for ajs:2000.
debug: bayes: no dbs present, cannot tie DB R/O:
/u2/martin/.spamassassin/bayes_toks
[etc etc]
debug: open of AWL file failed: lock: 26117 cannot create tmp lockfile
/u2/martin/.spamassassin/auto-whitelist.lock.spam.26117 for
/u2/martin/.spamassassin/auto-whitelist.lock: Permission denied
logmsg: clean message (0.1/5.0) for ajs:2000 in 6.5 seconds, 4857 bytes.


???
Comment 1 Theo Van Dinter 2004-07-12 07:44:36 UTC
hrm.  well, I don't believe it's ident related, since that just verifies "spamc
username == ident username".  moving to the 3.0.0 queue for more investigation.
Comment 2 Theo Van Dinter 2004-07-12 08:11:24 UTC
Subject: Re:  Wrong bayes and AWL files being opened

On Mon, Jul 12, 2004 at 07:44:38AM -0700, bugzilla-daemon@bugzilla.spamassassin.org wrote:
> hrm.  well, I don't believe it's ident related, since that just verifies "spamc
> username == ident username".  moving to the 3.0.0 queue for more investigation.

can you check to see that the problem still exists without the ident
bit in there?  thanks. :)

Comment 3 Graham Murray 2004-07-12 08:16:31 UTC
This is the same as the problem aleady reported in bug 3525, and is still
happening with SVN 22750
Comment 4 Theo Van Dinter 2004-07-12 16:35:50 UTC
Created attachment 2119 [details]
test patch

in digging around, the only thing I can come up with is that in spamd,
sed_path_cache is backed up w/out the bayes/etc path (forcably removed via
compile_now), then a message processing would set it, then the previous values
are restored but since the bayes/etc wasn't there before the new version isn't
overwritten.

so this patch has copy_config() blow away the destination's sed_path_cache
before restoring the previously backed up values.  this should let us keep the
benefit of the cache without not overwriting new data that gets stored after
the backup.

can the people seeing this issue please try out the patch?  thanks. :)

(btw: I've seen an occasional "autolearn=failed" on my box, which could very
well be caused by this issue...  I'll be trying the patch as well to see if the
# of failed occurances goes down.)
Comment 5 Theo Van Dinter 2004-07-12 20:48:40 UTC
I still get the autolearn=failed messages, btw.

/me continues digging
Comment 6 Theo Van Dinter 2004-07-12 21:43:03 UTC
w00t!  I did some more debugging and the test patch does fix the "wrong path" issue for me (most of 
the autolearn=failed states I was seeing, although I still get some, but that's another ticket if it's not a 
locking issue or something not bad...)

Pre patch:
(PID: EUID, cache key => cache value)

31838: EUID 101, __userstate__/bayes => /home/felicity/.spamassassin/bayes
31838: EUID 101, __userstate__/bayes_journal => /home/felicity/.spamassassin/bayes_journal
31839: EUID 101, __userstate__/bayes => /home/felicity/.spamassassin/bayes
31839: EUID 101, __userstate__/bayes_journal => /home/felicity/.spamassassin/bayes_journal
31839: EUID 123, failed, __userstate__/bayes => /home/felicity/.spamassassin/bayes
31839: EUID 123, failed, __userstate__/bayes_journal => /home/felicity/.spamassassin/bayes_journal
31838: EUID 123, failed, __userstate__/bayes => /home/felicity/.spamassassin/bayes
31838: EUID 123, failed, __userstate__/bayes_journal => /home/felicity/.spamassassin/bayes_journal
31839: EUID 107, failed, __userstate__/bayes => /home/felicity/.spamassassin/bayes
31839: EUID 107, failed, __userstate__/bayes_journal => /home/felicity/.spamassassin/bayes_journal
31838: EUID 107, failed, __userstate__/bayes => /home/felicity/.spamassassin/bayes
31838: EUID 107, failed, __userstate__/bayes_journal => /home/felicity/.spamassassin/bayes_journal

so we can see both pids get my cache state, then whenever a different euid comes around (therefore 
different home dir and different required path), it gets a failed state and the cache values are still 
pointing at me.  with the patch:

2152: EUID 101, __userstate__/bayes => /home/felicity/.spamassassin/bayes
2152: EUID 101, __userstate__/bayes_journal => /home/felicity/.spamassassin/bayes_journal
2153: EUID 101, __userstate__/bayes => /home/felicity/.spamassassin/bayes
2153: EUID 101, __userstate__/bayes_journal => /home/felicity/.spamassassin/bayes_journal
2152: EUID 107, __userstate__/bayes => /home/timex/.spamassassin/bayes
2152: EUID 107, __userstate__/bayes_journal => /home/timex/.spamassassin/bayes_journal
2153: EUID 123, __userstate__/bayes => /home/karen/.spamassassin/bayes
2153: EUID 123, __userstate__/bayes_journal => /home/karen/.spamassassin/bayes_journal
Comment 7 Theo Van Dinter 2004-07-12 23:35:36 UTC
*** Bug 3525 has been marked as a duplicate of this bug. ***
Comment 8 Al Smith 2004-07-13 00:43:42 UTC
+1. Works great now. Thanks.
Comment 9 Theo Van Dinter 2004-07-13 08:48:59 UTC
ok, changing to review status. yea. :)
Comment 10 Justin Mason 2004-07-13 11:12:05 UTC
+1
Comment 11 Daniel Quinlan 2004-07-13 17:35:07 UTC
+1 appears to be okay, I'm not set up to test at the moment ... so I didn't
Comment 12 Theo Van Dinter 2004-07-13 17:38:08 UTC
committed.  r22886. :)
Comment 13 Al Smith 2004-07-15 01:49:39 UTC
Damn, I've been noticing missing BAYES tags on some incoming mails, and upon
investigation I'm still seeing this even with the above patch. :(
Comment 14 Al Smith 2004-07-15 02:44:45 UTC
Strictly speaking, this is a solution for 3525 and I'm seeing it again today
because I migrated everything to a central virtual-user-dir configuration.

However, after some looking through I realised that if we have
--virtual-config-dir set, then $setuid_to_user is set to false,
and to cut a short story long, ultimately we do not actually call
copy_config at all.

I've attached a patch which resolves this.
Comment 15 Al Smith 2004-07-15 02:45:41 UTC
Created attachment 2130 [details]
call copy_config also when virtual-config-dir is set
Comment 16 Theo Van Dinter 2004-07-15 11:09:59 UTC
*** Bug 3611 has been marked as a duplicate of this bug. ***
Comment 17 Theo Van Dinter 2004-07-15 11:24:57 UTC
hrm.  so the issue with virtual-config-dir is _specifically_ the sed_cache_path thing?  ie: no 
configuration options change with the use of that option, right?

if so, I'm thinking we should avoid the whole copy_config thing, since it's much more resource intensive 
than "delete $...->{sed_cache_path};"
Comment 18 Theo Van Dinter 2004-07-15 11:28:59 UTC
to answer my own question, yeah, virtual-config-dir lets the virtual users do configs too, so 
copy_config() would be good there.

so +1 on 2130 :)
Comment 19 Justin Mason 2004-07-15 19:08:32 UTC
+1
Comment 20 Michael Parker 2004-07-15 19:25:57 UTC
+1
Comment 21 Theo Van Dinter 2004-07-15 19:47:04 UTC
ok, committed 2130.  r22947