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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#!/usr/bin/perl
# Roman Shterenzon <roman@xpert.com> 27/12/2000
# $FreeBSD: /tmp/pcvs/ports/security/amavis-perl/Attic/pkg-install.sendmail,v 1.1 2001-10-21 18:47:20 dwcjr Exp $
use strict;
$ENV{'PATH'}='/bin:/usr/bin';
my $cfg;
my $result;
exit 0 if $ARGV[1] ne "POST-INSTALL";
if ( -f '/etc/mail/sendmail.cf' ) {
$cfg='/etc/mail';
}
elsif ( -f '/etc/sendmail.cf' ) {
$cfg='/etc';
}
my $cf="$cfg/sendmail.cf";
my $new="$cfg/amavis.cf";
print "===> Adding necessary hooks to sendmail.cf file\n";
open(IN, $cf) || die "Cannot open $cf";
open(OUT, ">$new") || die "Cannot create $new";
my $replace=0;
while(<IN>) {
if ( /^O QueueDirectory/ ) {
$_="O QueueDirectory=/var/spool/mqamavis\n";
$replace++;
}
elsif ( /O StatusFile/ ) {
$_="O StatusFile=/var/log/amavis.st\n";
$replace++;
}
elsif ( /^Mlocal/ ) {
print OUT <<'EOF';
Mamavis, P=/usr/local/sbin/amavis, F=mlsACDFMS5:/|@qhP, S=0, R=0
T=DNS/RFC822/X-Unix,
A=amavis $f $u
EOF
$replace++;
}
elsif ( /\s+final\s+parsing$/ ) {
print OUT "R\$*\t\t\t\$#amavis \$:\$1\n";
$replace++;
}
s/^(DZ.*)/$1av/;
print OUT;
}
close(OUT);
close(IN);
die "I couldn't patch the sendmail.cf file, its format is unknown to me\n"
unless ( $replace == 4 );
print "===> Adding alias for virusalert to the aliases file\n";
if ( ! -f "$cfg/aliases" ) {
print "Can't find aliases file, you have to add an alias for virusalert by yourself\n";
}
else {
open (IN, "$cfg/aliases") || die "Cannot open aliases file for reading\n";
my $found;
while(<IN>) {
$found=1, last if /^virusalert/;
}
close(IN);
unless ($found) {
open(OUT, ">>$cfg/aliases") || die "Cannot open aliases file for writing\n";
print OUT "virusalert:\troot\n";
close(OUT);
$result=system("newaliases");
die "Failed to run newaliases command\n" if $result;
}
}
print "===> Creating /var/spool/mqamavis directory\n";
if ( ! -d "/var/spool/mqamavis" ) {
mkdir "/var/spool/mqamavis",0755 || die "Can't create /var/spool/mqamavis\n";
}
my $gid=getgrnam('daemon');
chown 0, $gid, "/var/spool/mqamavis";
die "There's already a $cf.pre-amavis, is amavis already installed?\n"
if -f "$cf.pre-amavis";
$result=system("cp $cf $cf.pre-amavis");
die "Failed to copy $cf to $cf.pre-amavis\n" if $result;
rename "$cf", "${cfg}/sendmail.orig.cf" ||
die "Unable to rename $cf to ${cfg}/sendmail.orig.cf\n";
rename "$new", "$cf" || die "Unable to rename $new to $cf\n";
|