#! /usr/bin/env python ''' Simple antivirus mail filter for procmail and ClamAV. If you have procmail set up, put this in your $PATH, then put the following in your ~/.procmailrc: ---[ recipe starts here :0f: /var/lock/clamailfilter.lock | clamailfilter ---[ recipe ends here clamailfilter is (C) 2004 Janusz A. Urbanowicz . 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 Licens 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,os CLAMSCAN = 'clamdscan --quiet -' input = sys.stdin.read() stream = os.popen(CLAMSCAN,'w') try: stream.write(input) except IOError: sys.stdout.write(input) sys.exit(2) rc = stream.close() if rc == None: code = 0 else: code = (rc & 65280)/ 256 if code == 0 or code == 2: sys.stdout.write(input) sys.exit(0) sys.exit(1)