MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //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;