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/checkexim.pl
#!/usr/bin/perl
# cpanel - checkexim.pl                        Copyright(c) 2004-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::FileUtils::TouchFile ();
eval "use Lchown ();";
my $has_lchown = $@ ? 0 : 1;
my $chown_func_ref = $has_lchown ? \&Lchown::lchown : sub { chown(@_); };

sub checkeximlogs {
    require Cpanel::PwCache;
    my $mailnull_uid = ( Cpanel::PwCache::getpwnam('mailnull') )[2];

    if ( $^O !~ /freebsd/i ) {
        my $mail_gid     = ( getgrnam('mail') )[2];
        if ( opendir( my $exim_dir_fh, '/var/log' ) ) {
            my %log_files = map { $_ => undef } grep { /^exim_/ } readdir($exim_dir_fh);
            $log_files{'exim_mainlog'}   = undef;
            $log_files{'exim_paniclog'}  = undef;
            $log_files{'exim_rejectlog'} = undef;
            foreach my $log_file ( keys %log_files ) {
                my ( $mode, $uid, $gid ) = ( stat('/var/log/' . $log_file) )[ 2, 4, 5 ];
                if ( !$mode ) { Cpanel::FileUtils::TouchFile::touchfile( '/var/log/' . $log_file ) }
                $chown_func_ref->( $mailnull_uid, $mail_gid, '/var/log/' . $log_file ) if ( $uid != $mailnull_uid || $gid != $mail_gid );
                chmod( 0640, '/var/log/' . $log_file ) if ( $mode & 00777 != 0640 );
            }
        }
    }
    else {
        my $mailnull_gid     = ( getgrnam('mailnull') )[2];
        if ( opendir( my $exim_dir_fh, '/var/log/exim' ) ) {
            my %log_files = map { $_ => undef } grep { !/^\./ } readdir($exim_dir_fh);
            $log_files{'mainlog'}   = undef;
            $log_files{'paniclog'}  = undef;
            $log_files{'rejectlog'} = undef;
            foreach my $log_file ( keys %log_files ) {
                my ( $mode, $uid, $gid ) = ( stat('/var/log/exim' . $log_file) )[ 2, 4, 5 ];
                if ( !$mode ) { Cpanel::FileUtils::TouchFile::touchfile( '/var/log/exim/' . $log_file ) }
                $chown_func_ref->( $mailnull_uid, $mailnull_gid, '/var/log/exim/' . $log_file ) if ( $uid != $mailnull_uid || $gid != $mailnull_gid );
                chmod( 0640, '/var/log/exim/' . $log_file ) if ( $mode & 00777 != 0640 );
            }
        }

    }
}

sub checkeximperms {
    require Cpanel::PwCache;
    if ( Cpanel::PwCache::getpwnam("mailnull") ) {
        my $mailnull_uid = ( Cpanel::PwCache::getpwnam('mailnull') )[2];
        my $mail_gid     = ( getgrnam('mail') )[2];

        checkeximlogs();

        system( '/bin/chown', '-R', $mailnull_uid . ':' . $mail_gid, '/var/spool/exim' );
        chown $mailnull_uid, $mail_gid, '/etc/exim.crt', '/etc/exim.key';
    }
}

1;