[spambayes-bugs] [ spambayes-Bugs-936821 ] sb_mboxtrain.py requires
writeaccess to mbox
SourceForge.net
noreply at sourceforge.net
Sat Apr 17 04:45:44 EDT 2004
Bugs item #936821, was opened at 2004-04-17 08:45
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=498103&aid=936821&group_id=61702
Category: None
Group: Source code - CVS
Status: Open
Resolution: None
Priority: 5
Submitted By: PieterB (pieterb)
Assigned to: Nobody/Anonymous (nobody)
Summary: sb_mboxtrain.py requires writeaccess to mbox
Initial Comment:
This is tested with spambayes1.0b1.1, which isn't listed
in the Group pulldownbox on sourceforge (yet).
At our system we use a spamtrap which catches a lot of
spam. I want to use that spammailbox for improving
spambayes. When I try to learn from this read-only
mbox I get the following traceback:
Training spam (/var/mail/spamtrap):
Reading as Unix mbox
Traceback (most recent call last):
File "/usr/local/bin/sb_mboxtrain.py", line 350, in ?
main()
File "/usr/local/bin/sb_mboxtrain.py", line 341, in main
train(h, s, True, force, trainnew, removetrained)
File "/usr/local/bin/sb_mboxtrain.py", line 265, in train
mbox_train(h, path, is_spam, force)
File "/usr/local/bin/sb_mboxtrain.py", line 172, in
mbox_train
f = file(path, "r+b")
IOError: [Errno 13] Permission
denied: '/var/mail/spamtrap'
It can be fixed by first trying to open the file readonly,
and when that fails open the file for 'r+b'.
In the method mbox_train from sb_mboxtrain.py,
use the following code.
# Open and lock the mailbox. Some systems require
it be opened for
# writes in order to assert an exclusive lock.
try: # opening the file read only
f = file(path, "rb")
fcntl.flock(f, fcntl.LOCK_EX)
except: # opening file fails
f = file(path, "r+b")
fcntl.flock(f, fcntl.LOCK_EX)
This makes spambayes start learning from the mbox.
Unfortuately, spambayes really wants to write to the
mailbox and it fails:
Training spam (/var/mail/spamtrap):
Reading as Unix mbox
3960Problem truncating mbox--nothing written
Traceback (most recent call last):
File "/usr/local/bin/sb_mboxtrain.py", line 355, in ?
main()
File "/usr/local/bin/sb_mboxtrain.py", line 346, in main
train(h, s, True, force, trainnew, removetrained)
File "/usr/local/bin/sb_mboxtrain.py", line 270, in train
mbox_train(h, path, is_spam, force)
File "/usr/local/bin/sb_mboxtrain.py", line 202, in
mbox_train
os.ftruncate(f.fileno(), 0)
IOError: [Errno 22] Invalid argument
This can be fixed by setting Headers:include_trained to
false, e.g.
/usr/local/bin/sb_mboxtrain.py -o
Headers:include_trained:False -
p /home/foobar/var/spambayes.db -s /var/mail/spamtrap
I would expect sb_mboxtrain.py not to open files for
writing if it's not necessary/requested.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=498103&aid=936821&group_id=61702
More information about the Spambayes-bugs
mailing list