Procmail config issues


#1

Hi All, not sure if this is the right place for this but I’m having problems with .procmailrc - I’m trying to use spambayes to filter mail, and the procmail config is the only thing I can’t get to work.

My .procmailrc is:

~/.procmailrc for Dreamhost

Uses Maildir format mail directory.

PATH=$HOME/bin:/usr/bin:/usr/local/bin:/home/dunk/bin:/home/dunk/Maildir
PMDIR=$HOME/.procmail

VERBOSE=yes
LOGFILE=$HOME/logfile
LOGABSTRACT=all

Message directory (Courier IMAP and mutt)

DEFAULT=$HOME/Maildir/
MAILDIR=$HOME/Maildir

:0fwr:hamlock
| $HOME/bin/sb_filter.py -d $HOME/.hammie.db

:0

  • ^X-SpamBayes-Classification: spam; 1.00
    .Spam/

:0

  • ^X-SpamBayes-Classification: spam; 0.9[5-9]
    .Spam/

:0 c

  • ^X-SpamBayes-Classification: spam
    .TrainingSpam/

:0 c

  • ^X-SpamBayes-Classification: unsure
    .Unsure/

:0 c

  • ^X-SpamBayes-Classification: ham; 0.0[2-9]
    .TrainingHam/

:0 c

  • ^X-SpamBayes-Classification: ham; 0.1[0-9]
    .TrainingHam/

INCLUDERC=$PMDIR/spam.rc

INCLUDERC=$PMDIR/testing.rc

:0
$HOME/Maildir/

=========================================

And this produces the following Log file…

procmail: Skipped "
"
procmail: Assigning "LOGABSTRACT=all
"
procmail: Skipped "
"
procmail: Assigning "DEFAULT=/home/dunk/Maildir/
"
procmail: Assigning "MAILDIR=/home/dunk/Maildir
"
procmail: Couldn’t chdir to "/home/dunk/Maildir
"
procmail: Assigning "MAILDIR=."
procmail: Skipped "
"
procmail: Skipped "
"
procmail: Locking "hamlock"
procmail: Executing "/home/dunk/bin/sb_filter.py,-d,/home/dunk/.hammie.db
"
Traceback (most recent call last):
File “/home/dunk/bin/sb_filter.py”, line 257, in ?
main()
File “/home/dunk/bin/sb_filter.py”, line 248, in main
action(msg)
File “/home/dunk/bin/sb_filter.py”, line 179, in filter
self.open(‘r’)
File “/home/dunk/bin/sb_filter.py”, line 163, in open
self.h = hammie.open(self.dbname, self.usedb, self.mode)
File “/home/dunk/lib/python2.3/site-packages/spambayes/hammie.py”, line 267, in open
return Hammie(storage.open_storage(filename, useDB, mode))
File “/home/dunk/lib/python2.3/site-packages/spambayes/storage.py”, line 679, in open_storage
return klass(data_source_name, mode)
File “/home/dunk/lib/python2.3/site-packages/spambayes/storage.py”, line 164, in init
self.load()
File “/home/dunk/lib/python2.3/site-packages/spambayes/storage.py”, line 189, in load
self.dbm = dbmstorage.open(self.db_name, self.mode)
File “/home/dunk/lib/python2.3/site-packages/spambayes/dbmstorage.py”, line 65, in open
return f(db_name, mode)
File “/home/dunk/lib/python2.3/site-packages/spambayes/dbmstorage.py”, line 38, in open_best
return f(*args)
File “/home/dunk/lib/python2.3/site-packages/spambayes/dbmstorage.py”, line 20, in open_dbhash
return bsddb.hashopen(*args)
File “/home/dunk/lib/python2.3/bsddb/init.py”, line 192, in hashopen
d.open(file, db.DB_HASH, flags, mode)
bsddb._db.DBNoSuchFileError: (2, ‘No such file or directory’)
procmail: [14975] Tue May 11 02:13:01 2004
procmail: Program failure (1) of "/home/dunk/bin/sb_filter.py"
procmail: Rescue of unfiltered data succeeded
procmail: [14975] Tue May 11 02:13:01 2004
procmail: Unlocking "hamlock"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: No match on "^X-SpamBayes-Classification: spam; 1.00
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: No match on "^X-SpamBayes-Classification: spam; 0.9[5-9]
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: No match on "^X-SpamBayes-Classification: spam
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: No match on "^X-SpamBayes-Classification: unsure
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: No match on "^X-SpamBayes-Classification: ham; 0.0[2-9]
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: No match on "^X-SpamBayes-Classification: ham; 0.1[0-9]
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: Skipped "
"
procmail: [14975] Tue May 11 02:13:02 2004
procmail: Assigning "LASTFOLDER=/home/dunk/Maildir/new/1084266777.14975_1.knife"
procmail: Notified comsat: "dunk@0:/home/dunk/Maildir/new/1084266777.14975_1.knife"
From dunk@nuptialz.com Tue May 11 02:12:57 2004
Subject: test11
Folder: /home/dunk/Maildir/new/1084266777.14975_1.knife 958

So questions - Why can’t it chdir into my Maildir? Do I need to modify the permission on that folder?

Question 2 - Loads of errors on the python script. I’ve installed python in my $HOME/bin, and if I run the script from the command line it seems to work ok. So whats up with that?

Many thanks for any help you can offer :slight_smile:

Cheers,
Slopey.


#2

My first guess is that the Python script is trying to import modules that aren’t installed on the mail machines - does it import any modules that aren’t installed in your home dir?


#3

Not that I’m aware. I was thinking the “no such file or directory error” was probably coming about as the Chdir to MAILDIR failed.

As I understand it, the script chdir’s into the maildir at that point and all the releative paths are worked out from there. Possibly at that point sb_filter.py can’t find the libraries or something?


#4

I’m not sure about this particular program. Couple other things:

  1. Does adding:
    SHELL=/bin/sh
    to your .procmailrc help?

  2. Does the script work properly if you test it from the shell on your user machine? Since you seem to have all the libraries and stuff installed in your home directory, you can probably pretty safely troubleshoot from there.

  3. Not sure why you have /home/dunk/Maildir set in $PATH in your .procmailrc (or why you have /home/dunk/bin/ set twice). You shouldn’t have any executables in /home/dunk/Maildir/ (this shouldn’t cause any problems… but you might want to fix it).

You might want to use strace to do some further troubleshooting.

I did a test from your user on one of the mail machines, and as long as I specify the db file for sb_filter.py (with -d), it seems to accept / process mails just fine.


#5
  1. Adding SHELL=/bin/sh

nope - does’nt help

  1. Don’t have a machine here, doing it all on hillmont.

  2. tidied up the Path (I was adding directories in there to see if I’d missed something), so maildir isnt included, and only one reference to dunk/bin

The sticky bit seems to be the:

File “/home/dunk/lib/python2.3/bsddb/init.py”, line 192, in hashopen
d.open(file, db.DB_HASH, flags, mode)
bsddb._db.DBNoSuchFileError: (2, ‘No such file or directory’)

I’ve check that all the relevant files are in the lib directories, and they must be as they are being executed. So that would mean that the above is possibly trying to open my db file and failing? I know the file is there and the path is correct to it. Any ideas why it cant (seem to) find the .hammie.db file?

:confused:


#6

[quote]File “/home/dunk/lib/python2.3/bsddb/init.py”, line 192, in hashopen
d.open(file, db.DB_HASH, flags, mode)
bsddb._db.DBNoSuchFileError: (2, ‘No such file or directory’)[/quote]
I saw that too, but I think I only got it when a db file wasn’t explicitly specified; looks like you are specifying one in your .procmailrc.

Maybe you need to play around with quoting of the command you’re piping to. Before you try that, though, try making sure to specify the full path, so instead of:
| sb_filter.py -d .hammie.db
do:
| sb_filter.py -d $HOME/.hammie.db


#7

Gotcha!

I had a Windoze line feed character on the .hammie.db line! Typed the .procmailrc up with pico and problem solved!

Excellent :slight_smile: Thanks for the help though!


#8

Ahh - that’ll do it.

Note that this particular snafu is specifically mentioned at:
https://panel.dreamhost.com/kbase/?area=2626


#9

If you edit script or configuration files on a Windows or Mac system to upload by FTP to a Unix or Linux system, you should use ASCII mode rather than binary mode in the FTP program; then the line breaks will be converted to the proper format for the destination OS.

– Dan