Hello,

I'm trying to install pythonfilter for the first time. I thought that I installed everything correctly...
But... (there is always a but), test mails I tried to send are not filtered.

I want pythonfilter to scan my mails for viruses.
I modified it a bit to use pyclamd instead of pyclamav (see attachments)

I send test mails using the following command: echo "Hello world" | nail -a clam.zip [my personal mail here] Clam.zip is one of the test files provided by clamav to check everything is OK. I cannot test it from outside for now, as no user are defined (and no maildirs are created). So, for the moment, I'm sending mail from the server.

In /var/log/mail.log, I see that the mail is processed by Courier but I don't see Pythonfilter running (neither clamd, neither debug)

Do you have any idea I could test to solve my problem?
Any help will be appreciated :)

Here are some useful data pieces:

# ls -l /usr/lib/courier/etc/filters/active/
total 0
lrwxrwxrwx 1 root root 45 2007-05-12 19:23 pythonfilter -> /usr/lib/courier/libexec/filters/pythonfilter
# ls -l /usr/lib/courier/libexec/filters/pythonfilter
lrwxrwxrwx 1 root root 21 2007-05-12 18:40 /usr/lib/courier/libexec/filters/pythonfilter -> /usr/bin/pythonfilter
# ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 2007-05-11 18:30 /usr/bin/python -> python2.4
# ls -l /usr/bin/pythonfilter
-rwxr-xr-x 1 root root 8580 2007-05-12 18:37 /usr/bin/pythonfilter

# egrep -v "#|^$" /etc/pythonfilter.conf
debug
clamd
nosuccessdsn

# cat /usr/lib/courier/etc/enablefiltering
esmtp
local

# courier-config
prefix=/usr/lib/courier
exec_prefix=/usr/lib/courier
bindir=/usr/lib/courier/bin
sbindir=/usr/lib/courier/sbin
libexecdir=/usr/lib/courier/libexec
sysconfdir=/usr/lib/courier/etc
datadir=/usr/lib/courier/share
localstatedir=/usr/lib/courier/var
mailuser=daemon
mailgroup=daemon
mailuid=1
mailgid=1
configure_args="'--with-paranoid-smtpext' '--enable-unicode' 'CPPFLAGS=-I/usr/lib/courier/include' --prefix=/usr/lib/courier --with-db=gdbm --enable-utf7-folder-encoding"


#!/usr/bin/python
# clamav -- Courier filter which scans messages with ClamAV
# Copyright (C) 2004  Robert Penz <[EMAIL PROTECTED]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import sys
import pyclamd


# Record in the system log that this filter was initialized.
sys.stderr.write('Initialized the "clamdfilter" python filter\n')


def doFilter(bodyFile, controlFileList):
    # check for viruses
    try:
        
        pyclamd.init_unix_socket('/tmp/clamd.sock')
        avresult = pyclamd.scan_file(bodyFile)

        #avresult = pyclamav.scanfile(bodyFile)

    except Exception, e:
        return "554 " + str(e)
    if avresult[bodyFile]:
        return "554 %s was detected. Abort!" % avresult[bodyFile]
    return ''


if __name__ == '__main__':
    # we only work with 2 parameter
    if len(sys.argv) != 2:
        print "Usage: clamd.py <message_body_file> <controlFileList"
        sys.exit(0)
    print doFilter(sys.argv[1], "")
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to