File: //proc/self/root/proc/self/root/scripts.20110531.215904.25158/mailscannerupdate
#!/usr/bin/perl
# cpanel - mailscannerupdate Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel'; }
use Cpanel::SafeFile;
use Cpanel::Logger ();
my $logger = Cpanel::Logger->new();
if ( $ARGV[0] !~ /force/i ) {
print "$0: This script should not be run manually. If you really wanted to do that, please add --force\n";
exit(1);
}
if ( open my $conf_fh, '<', '/etc/exim.conf' ) {
while (<$conf_fh>) {
if (m/^\s*av_scanner/) {
close $conf_fh;
exit 0;
}
}
close $conf_fh;
}
if ( -e '/etc/exim_outgoing.conf' ) {
print 'Mail Scanner exim.conf updating...';
system 'cp', '-fv', '/etc/exim.conf', '/etc/exim_outgoing.conf';
$file = '/etc/exim.conf';
$filelock = Cpanel::SafeFile::safeopen( \*FH, $file );
if ( !$filelock ) {
$logger->die("Could not read from $file");
}
$fileeditlock = Cpanel::SafeFile::safeopen( \*FHT, '>', $file . '.tmpeditlib' );
if ( !$fileeditlock ) {
$logger->die("Could not write to $file\.tmpeditlib");
}
chmod( 0600, $file . '.tmpeditlib' );
while (<FH>) {
next if m/^\s*system_filter/ || m/^\s*spool_directory/ || m/^\s*queue_only/ || m/^\s*queue_only_override/;
print FHT;
if (m/cPanel\s+Exim\s+4\s+Config/) {
print FHT "\n";
print FHT "spool_directory = /var/spool/exim_incoming\n";
print FHT "queue_only = true\n";
print FHT "queue_only_override = false\n\n";
}
if (m/^begin routers/) {
print FHT <<'EOM';
defer_router:
driver = redirect
allow_defer
data = :defer: All deliveries are handled by MailScanner
verify = false
EOM
}
}
Cpanel::SafeFile::safeclose( \*FH, $filelock );
Cpanel::SafeFile::safeclose( \*FHT, $fileeditlock );
$fileeditlock = Cpanel::SafeFile::safeopen( \*FHT, '<', $file . '.tmpeditlib' );
if ( !$fileeditlock ) {
$logger->die("Could not read from $file\.tmpeditlib");
}
$filelock = Cpanel::SafeFile::safeopen( \*FH, '>', $file );
if ( !$filelock ) {
$logger->die("Could not write to $file");
}
while (<FHT>) { print FH; }
Cpanel::SafeFile::safeclose( \*FH, $filelock );
Cpanel::SafeFile::safeclose( \*FHT, $fileeditlock );
if ( -d '/usr/local/etc/exim' ) {
system 'cp', '-fv', '/etc/exim.conf', '/usr/local/etc/exim/configure';
}
print "Done\n";
system 'chown', '-R', 'mailnull:mail', '/var/spool/exim_incoming';
}
exit 0;