File: clampipe

package info (click to toggle)
clamav 0.98.7%2Bdfsg-0%2Bdeb6u2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 60,204 kB
  • ctags: 49,129
  • sloc: cpp: 267,090; ansic: 152,211; sh: 35,196; python: 2,630; makefile: 2,220; perl: 1,690; pascal: 1,218; lisp: 184; csh: 117; xml: 38; asm: 32; exp: 4
file content (30 lines) | stat: -rw-r--r-- 833 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl
# Filters mail through clamav. Intented to be used as a maildrop xfilter,
# So it takes care to exit 0 on success, and nonzero on error. Adds a
# X-Virii-Status header.
# Contributed by Joey Hess <joeyh@debian.org> to be used with procmail
use strict;
use warnings;

$/=undef;
my $msg=<>;

open (CLAM, "| clamscan --quiet -")
	|| die "cannot run clamscan: $!";
# The --mbox support is flakey and requires a From header as in a real
# mbox.
print CLAM "From foo\n";
print CLAM $msg;
close CLAM;
# Returns status of 1 for virii.
my $status= ($? >> 8 == 1) ? "yes" : "no";
#print STDERR "status: ".($? >> 8)." $!\n";

open (FORMAIL, "|formail -i 'X-Virii-Status: $status'")
	|| die "cannot run formail: $!!";
print FORMAIL $msg
	|| die "cannot write to formail: $!";
close FORMAIL
	|| die "formail failed: $!";

exit 0;