Jérôme Blion escribió:
Jérôme Blion a écrit :
Jérôme Blion a écrit :
Courier and clamd are working as root...
I meant daemon... looooool I wrote too quickly...
Definitely...
I have to sleep...
clamd is started as root and courier as daemon... :)))))
With clamd running as root everything is going fine. But, my boss asked
me he wanted that, when a virus infected mail were rejected, the
intended recipient get a warning about it. So, being my first time doing
python programming, began looking on variuos web sites and crafted this
solution using smtp and email.Message modules.
---snip---
def mail(to='', who=''):
sender='[EMAIL PROTECTED]'
message = email.Message.Message()
message["To"] = to
message["From"] = sender
message["Date"] = email.Utils.formatdate(localtime=1)
message["Subject"] = 'Aviso de e-mail con virus'
text=who + "Le envio un mail que fue rechazado por el antivirus en
el servidor"
message.set_payload(text)
mailServer = smtplib.SMTP('localhost:25')
mailServer.sendmail(sender, to, message.as_string())
mailServer.quit()
def doFilter(bodyFile, controlFileList):
# check for viruses
try:
pyclamd.init_unix_socket('/var/run/clamav/clamd.socket')
avresult = pyclamd.contscan_file(bodyFile)
except Exception, e:
return "554 " + str(e)
if avresult == None:
return ''
if avresult.has_key(bodyFile):
mail(courier.control.getRecipients(controlFileList),
courier.control.getSender(controlFileList))
return "554 %s was detected. Abort!" % avresult[bodyFile]
---snip---
but I'm getting this in the log files:
Jun 12 15:22:42 jupiter courierfilter: Raw stat: (33200, 3594100L,
2304L, 1, 200, 200, 2365L, 1181672562, 1181672562, 1181672562)
Jun 12 15:22:42 jupiter courierfilter: Control file:
/usr/lib/courier/var/tmp/118167/1181672561.3403.mail.uygroup.com.uy
Jun 12 15:22:42 jupiter courierfilter: Raw stat: (33200, 3594099L,
2304L, 1, 200, 200, 143L, 1181672561, 1181672561, 1181672561)
Jun 12 15:22:42 jupiter courierfilter: Uncaught exception in "clamav"
doFilter function: exceptions.AttributeError:'list' object has no
attribute 'lstrip'
Jun 12 15:22:42 jupiter courierfilter: File
"/usr/lib/courier/etc/filters/active/pythonfilter", line 180, in
processMessage
Jun 12 15:22:42 jupiter courierfilter: replyCode = i_filter[1](bodyFile,
controlFileList)
Jun 12 15:22:42 jupiter courierfilter: File
"/usr/lib/python2.4/site-packages/pythonfilter/clamav.py", line 58, in
doFilter
Jun 12 15:22:42 jupiter courierfilter:
mail(courier.control.getRecipients(controlFileList),
courier.control.getSender(controlFileList))
Jun 12 15:22:42 jupiter courierfilter: File
"/usr/lib/python2.4/site-packages/pythonfilter/clamav.py", line 41, in mail
Jun 12 15:22:42 jupiter courierfilter: mailServer.sendmail(sender, to,
message.as_string())
Jun 12 15:22:42 jupiter courierfilter: File
"/usr/lib/python2.4/email/Message.py", line 129, in as_string
Jun 12 15:22:42 jupiter courierfilter: g.flatten(self, unixfrom=unixfrom)
Jun 12 15:22:42 jupiter courierfilter: File
"/usr/lib/python2.4/email/Generator.py", line 82, in flatten
Jun 12 15:22:42 jupiter courierfilter: self._write(msg)
Jun 12 15:22:42 jupiter courierfilter: File
"/usr/lib/python2.4/email/Generator.py", line 120, in _write
Jun 12 15:22:42 jupiter courierfilter: self._write_headers(msg)
Jun 12 15:22:42 jupiter courierfilter: File
"/usr/lib/python2.4/email/Generator.py", line 166, in _write_headers
Jun 12 15:22:42 jupiter courierfilter: header_name=h,
continuation_ws='\t').encode()
Jun 12 15:22:42 jupiter courierfilter: File
"/usr/lib/python2.4/email/Header.py", line 395, in encode
Jun 12 15:22:42 jupiter courierfilter: return
self._encode_chunks(newchunks, maxlinelen)
Jun 12 15:22:42 jupiter courierfilter: File
"/usr/lib/python2.4/email/Header.py", line 355, in _encode_chunks
Jun 12 15:22:42 jupiter courierfilter: _max_append(chunks, s,
maxlinelen, extra)
Jun 12 15:22:42 jupiter courierfilter: File
"/usr/lib/python2.4/email/quopriMIME.py", line 79, in _max_append
Jun 12 15:22:42 jupiter courierfilter: L.append(s.lstrip())
as far as I can tell, there's a problem with getSender, but I can't go
further. If anybody has a clue or a better solution, I'll be very thankfull.
Jerome Blion.
------------------------------------------------------------------------
-------------------------------------------------------------------------
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
--
*/------------------------------------------------------------------------------------------------------------------
Enrique Verdes/**
UyGroup*/ /Consulting & Technology
*/_
www.uygroup.com.uy <http://www.uygroup.com.uy>_/*/
Av. Gral. Paz 1481 - CP 11400
Montevideo - Uruguay
Phone/Fax: (+598-2) 600-6200 - ext. 223
*/------------------------------------------------------------------------------------------------------------------/*
AVISO DE CONFIDENCIALIDAD:
LA INFORMACIÓN CONTENIDA EN ESTE CORREO ELECTRÓNICO ES PRIVILEGIADA Y
CONFIDENCIAL Y FUE ENVIADO PARA EL USO EXCLUSIVO DEL DESTINATARIO
DESIGNADO EN EL MISMO.
Si usted no es el destinatario, se prohibe estrictamente la
reproducción, distribución, y cualquier otra forma de difusión o uso de
esta comunicación.
Si usted ha recibido este correo electrónico por error, por favor
contéctese con nosotros inmediatamente al teléfono: (+598-2) 600-62-00 o
por el correo electrónico: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
*/------------------------------------------------------------------------------------------------------------------/*
CONFIDENTIALITY NOTICE:
THE INFORMATION CONTAINED IN THIS E-MAIL IS PRIVILEGED AND CONFIDENTIAL
AND IS INTENDED FOR THE EXCLUSIVE USE OF THE ADDRESSEE DESIGNATED ABOVE.
If you are not the addressee, any disclosure, reproduction distribution,
or other dissemination or use of this communication is strictly prohibited.
If you have received this electronic mail by error please contact us
immediately by telephone: (+598-2) 600-62-00 or by e-mail:
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
*/------------------------------------------------------------------------------------------------------------------/*
/
-------------------------------------------------------------------------
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