aboutsummaryrefslogtreecommitdiff
path: root/security/amavis-perl/pkg-install.qmail
blob: 0ca188f02604caee380fc98e62eb1032cbd0bf22 (plain) (blame)
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
#!/usr/bin/perl

use strict;

my $qmailDir;
my ( $uid, $gid );
local *F;

# ensure we are running only as post installation
exit 0 if $ARGV[ 1 ] ne "POST-INSTALL";

# find location of qmail
if ( -f "/var/qmail/bin/qmail-send" ) {
    $qmailDir = "/var/qmail";
} else {
    $qmailDir = "/usr/local/qmail";
}

# create virusalert use as root
print "==> Creating virusalert user as root\n";
open( F, ">${qmailDir}/alias/.qmail-virusalert" );
print F "root\n";
close( F );

# move qmail-queue to qmail-queue-real
print "==> Moving qmail-queue\n";
if ( ! -f "${qmailDir}/bin/qmail-queue-real" ) {
    system( "mv ${qmailDir}/bin/qmail-queue ${qmailDir}/bin/qmail-queue-real" );
    system( "cp /usr/local/sbin/amavis ${qmailDir}/bin/qmail-queue" );
    ( undef, undef, $uid, $gid ) = getpwnam( "qmailq" );
    chown $uid, $gid, "${qmailDir}/bin/qmail-queue";
    chmod 04711, "${qmailDir}/bin/qmail-queue";
} else {
    print "FAILURE: ${qmailDir}/bin/qmail-queue-real already exists!!\n";
    exit 1;
}

print "==> Changing permissions on suidperl\n";
chmod 04755, "/usr/bin/suidperl";