I have ALREADY done everything stated at the beginning of the script file
(which I have attached for clarity - some of you may not have seen it).
When I have done all this, I get an error when performing the test :

[root@ns bin]# echo "test 1" | mail -s okay [EMAIL PROTECTED]
[root@ns bin]# qmail-inject: fatal: unable to exec qq (#4.3.0)

When I try to run the script directly :

[root@ns bin]# ./qmail-filter.py

bash: ./qmail-filter.py: No such file or directory


Now. Does anyone have any ideas what the problem could be? I've tried
running strace ./qmail-filter.py, but it only outputs a "exec: file not
found" error.

/Jesper


---------[SNIP]-----------------

#!/usr/bin/python
#
# A quick hack to filter the ILOVEYOU worm with qmail.  Use:
#
#   $ cp qmail-filter.py /var/qmail/bin
#   $ cd /var/qmail/bin
#   $ chmod +x qmail-filter.py
#   $ mv qmail-queue qmail-queue-real; ln -s qmail-filter.py qmail-queue
#
# Test:
#
#   $ echo "test 1" | mail -s okay myself
#   $ echo "test 2" | mail -s ILOVEYOU myself
#
# You might have to modify the Python path at the top.  This is a
# temporary fix.  Remove it after the dust settles:
#
#   $ cd /var/qmail/bin
#   $ mv qmail-queue-real qmail-queue
#
# Neil Schemenauer <[EMAIL PROTECTED]>

PATTERN = r"^Subject: ILOVEYOU\s*$"
QMAIL_QUEUE = "/var/qmail/bin/qmail-queue-real"

import re
import string
import sys
import os
import tempfile

def mktemp():
    for i in range(10):
        tmp = tempfile.mktemp()
        try:
            fd = os.open(tmp, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700)
        except OSError:
            continue
        file = os.fdopen(fd, "w+b")
        os.unlink(tmp)
        return file
    return None


try:
    mess = mktemp()
    if not mess:
        os._exit(53) # write error
    header = 1
    while 1:
        line = sys.stdin.readline()
        if not line:
            break
        if line in ("\r\n", "\n"):
            header = 0
        if header and re.search(PATTERN, line):
            os._exit(31) # blocked, permanent error
        mess.write(line)
    mess.flush()
    mess.seek(0)
    os.dup2(mess.fileno(), 0)
    os.execv(QMAIL_QUEUE, ())
except:
    os._exit(81) # internal error


-------------------[SNIP]---------------------


Reply via email to