scan-mail.pl [-backup|-quarantine] [-daemon] [-server] [-server_port port] [[-milter P|C] | [-postfix address [-proxy [-proxy_address address] [-smtp_address address]]]
If F-Prot Antivirus detects an infection in a message or attachment, the Mail Scanner will try to neutralize the threat. If the message was clean or if all infection are removed, the Mail Scanner will check the filenames of the attachments against rules found in /etc/f-prot.conf to determine if attachments of that type are allowed through the system. If, however, F-Prot Antivirus fails to remove the infection, the message or attachment will be removed, an appropriate message will be appended to the e-mail. In case of a run-time error, the attachment is saved to disk and removed from the e-mail.
The scan-mail.pl script will add the header ""X-Antivirus: Scanned by F-Prot Antivirus (http://www.f-prot.com)"" to all filtered e-mail messages. scan-mail.pl can be passed the same configuration parameters as the sanitizer.pl program that comes with Anomy.
content_filter = smtp:[127.0.0.1]:10025
This will induce Postfix's default SMTP daemon to pipe all mail to the address 127.0.0.1:10025. Then add these 3 entries to master.cf:
scan unix - - n - 10 smtp
localhost:10026 inet n - n - 10 smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o myhostname=localhost.domain.tld
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o smtpd_use_tls=no
-o mynetworks=127.0.0.0/8
localhost:10025 inet n n n - 10 spawn
user=nobody argv=/usr/local/f-prot/tools/scan-mail.pl -postfix 127.0.0.1:10026
The first entry specifies that Postfix's master service shall run at most 10 processes simultaneously to pipe the mail from the SMTP daemon to external filter. The second entry makes the master service run at most 10 SMTP processes simultaneously on address localhost:10026 to receive the mail from the filter, and configures it so it does not loop the mail back to the external filter. And the third entry makes the master service run at most 10 instances simultaneously of the Mail Scanner to filter the mail on address localhost:10026 and advises the Mail Scanner that the SMTP daemon it is supposed to relay SMTP connections to is running on address 127.0.0.1:10026.
content_filter = smtp:[127.0.0.1]:10025
scan unix - - n - 10 smtp
localhost:10026 inet n - n - 10 smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o myhostname=localhost.domain.tld
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o smtpd_use_tls=no
-o mynetworks=127.0.0.0/8
Then, you start scan-mail.pl with the commandline:
scan-mail.pl -daemon -proxy -proxy_address 127.0.0.1:10025 -smtp_address 127.0.0.1:10026
:0 fw
| /usr/local/f-prot/tools/scan-mail.pl
To utilize the -backup option, use:
:0 fw
| /usr/local/f-prot/tools/scan-mail.pl -backup
To utilize the -quarantine option, use:
:0 fw
| /usr/local/f-prot/tools/scan-mail.pl -quarantine
Mail processing is a resource intensive task, and these rules could cause the system to run out of resources. If the system runs out of virtual memory it will start killing processes. In the event of a filter task getting killed procmail will allow the mail through in its original form. This can be avoided by implementing error checking of the filter's return value. The rule below will deliver the message to /usr/local/f-prot/backup/FAILED.<time>.<pid> if the scanners' return value indicates failure. Place it below the scan-mail.pl rule for the desired effect:
:0 fw
| /usr/local/f-prot/tools/scan-mail.pl
:0 e
/usr/local/f-prot/backup/FAILED.`date +%s`.$$
To avoid running out of resources due to multiple parallel instances of scan-mail.pl, locks can be implemented. Below is an example of how to make procmail run only one instance of scan-mail.pl at a given time. Using a lockfile called /var/tmp/scan-mail.pl.lock:
:0 fw:/var/tmp/scan-mail.pl.lock
/usr/local/f-prot/tools/scan-mail.pl
For more information about creating procmailrc rules, see the
procmailrc">procmailrc(5) and
CAVEATS
There is a problem with Unicode character support in some versions of
Red Hat Linux and its interaction with Perl, and therefore Anomy. If
scan-mail.pl fails to work, try making a shell script that sets the
following environment variables to their given respective values
before running scan-mail.pl:
LANG="en_US"
SUPPORTED="en_US:en"
Updates will be advertised on: http://www.f-prot.com/