DaemonForums  

Go Back   DaemonForums > Miscellaneous > General software and network

General software and network General OS-independent software and network questions, X11, MTA, routing, etc.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 24th July 2009
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default Mailx and Clamav

Is it possible to pipe messages and in particular attachments through clamscan while fetching them from IMAP server with Mailx? I looking for something like using Clamav with Getmail. It seems to me that I could pipe messages from the command line with something as simple as

Code:
& pi message_number clamscan
but I end up scanning dot files from.
Reply With Quote
  #2   (View Single Post)  
Old 24th July 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

I don't have them running on the same machine at the moment, so I can't run a proper test, but like many programs clamscan should understand '-' as scanning its standard input.

I tried using cat and head as a test on my OpenBSD machine:

Code:
& pi 1 cat
 ... output for message number 1 ...
&  pi 1 head -n 3
Referencing before 1
& pi 1 /tmp/filterscript
 ... top 3 lines of message number 1 ...
The test was done using the mailx util on an OpenBSD 4.4-release box. Perhaps nailx/heirloom mailx may be different (or I'm just being stupid) but it seems to have an issue about executing a command > 1 word. If needed you can always create a filter script to supply any needed arguments to clamscan.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #3   (View Single Post)  
Old 24th July 2009
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default

Thanks Tarry,

You really helped me. This is the proper command.

Code:
Pi message_number "clamscan -"
Or you can probably use the following option
Code:
Pi message_number "clamscan --scan-mail=yes  -"
Note that you must use Pi (not pi) in order to pipe all parts of message including attachments.

I will post my .nailrc when I check man pages.

Last edited by Oko; 26th July 2009 at 04:50 AM.
Reply With Quote
  #4   (View Single Post)  
Old 24th July 2009
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default

The real way to do it is by scripting a nice folder-hook. It looks to me that would be very easy to write a hook which would also pipe attachments through file command thereby determining the their true nature (most email clients have a serious problems with it) and then strip the message from binary attachments for instance.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two antiviruse F-prot and ClamAV mfaridi FreeBSD Security 4 12th October 2008 09:15 PM
Can't connect to clamd through /var/run/clamav/clamd ccc FreeBSD Ports and Packages 2 12th July 2008 08:27 PM


All times are GMT. The time now is 10:01 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick