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: //scripts.20110531.215904.25158/safeyum
#!/usr/bin/perl
# cpanel - safeyum                                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 strict;
use IPC::Open3          ();
use Cpanel::CleanupStub ();

$| = 1;

Cpanel::CleanupStub::closefds();    #blocked by Yuan to debug, need to unblock when done.  # Prevent potential zombie under upcp

my $version = `yum --version`;
chomp $version;
my ( $v1, $v2 ) = $version =~ m/(?:(\d+)\.?)/g;
$v1 = int $v1;
$v2 = int $v2;

my $acp;
if ( $v1 > 2 || ( $v1 == 2 && $v2 >= 1 ) ) {
    print "Using newyum support.\n";

    #@ARGV = grep( !/\-C/, @ARGV );
    @ARGV = grep( !/^\-C/, @ARGV );    #It will not get perl-CPAN
## Added by Yuan for testing, willl have to remove it after done
############################################################################ Yuan
    #my @RPMS;
    #open( RPMLIST, 'rpmlist' ) || die print "Can't open file rpmlist: $!\n";
    #while (<RPMLIST>) {
    #    chomp();
    #    push( @RPMS, $_ );
    #}
    #close(RPMLIST);
    #@ARGV = @RPMS;
    #unshift (@ARGV, ,'-C', '-y', 'install');
    #foreach (@ARGV){print "ARGV: $_\n";}
######################################################################### Yuan
}
$SIG{'ALRM'} = sub {
    print "Warning, yum might be hung.  Please check your mirror configuration in /etc/yum.conf\n";
    return;
};

# Prevent kernel updates
system '/scripts/checkyum', '--kernel';

my $exit_code          = 0;
my $rpms_not_available = '/var/cpanel/tmp/rpms_not_available';

#open( RNULL, '<', '/dev/null' );
#open( FH, "> $rpms_not_available" ) || die  print "Can't open file $rpms_not_available: $!\n";    #Open to write yum complains.
open( FH, "> $rpms_not_available" );    #Open to write yum complains.

#my $pid = IPC::Open3::open3( '<&RNULL', \*ERR, \*ERR, 'yum', @ARGV );
my $pid = IPC::Open3::open3( my $fh, my $normal_out, my $error_out, 'yum', @ARGV );
if ($pid) {

    #    while (<ERR>) {
    while (<$error_out>) {
        alarm 800;
        if ($acp) {
            kill 'HUP', $acp;
            sleep 1;
            kill 'TERM', $acp;
            sleep 5;
            kill 'KILL', $acp;
            $acp = 0;
        }

        # Quiet yum matching errors
        next if ( m/^Could not find update match/ || m/^Cannot find a package match/ || m/^No Match for argument/ );
        print;
    }
    while (<$normal_out>) {
        print FH "$_";
        print "$_";
    }
    waitpid( $pid, 0 );
    close(ERR);
}
else {
    $exit_code = 1;
}

#close(RNULL);
close FH;
close $fh;
waitpid( $pid, 0 );

# Allow kernel updates
system '/scripts/checkyum', '--nokernel';

exit $exit_code;