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/patch_xml_libxml
#!/usr/bin/perl
# cpanel - patch_xml_libxml                       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::LoadFile        ();
use Cpanel::SafeRun::Simple ();
use Cpanel::Logger          ();

eval 'local $SIG{__DIE__}; use XML::LibXML;';

my $module_path = $INC{'XML/LibXML.pm'};

my $logger = Cpanel::Logger->new();

my $txt = Cpanel::LoadFile::loadfile($module_path);
if ( $txt !~ /(require|use) DynaLoader/ ) { exit; }
if ( $txt =~ /XSLoader/ ) { exit; }

print "Removing bloated DynaLoader Dep from XML::LibXML.\n";

my $mod_fh = Cpanel::SafeFile::safeopen( \*ER, '+<', $module_path );
if ( !$mod_fh ) {
    $logger->warn("Could not edit $module_path");
}
else {
    my @EN = <ER>;
    seek( ER, 0, 0 );
    my $inconfig = 0;
    foreach (@EN) {
        s/require DynaLoader/use XSLoader/g;
        s/use DynaLoader/use XSLoader/g;
        s/DynaLoader/XSLoader/g;
        s/^\s*bootstrap.*/XSLoader::load 'XML::LibXML', \$VERSION\;/g;
        print ER $_;
    }
    truncate( ER, tell(ER) );
    Cpanel::SafeFile::safeclose( \*ER, $mod_fh );
}

my $is_ok = Cpanel::SafeRun::Simple::saferun( ( -e '/usr/local/cpanel/scripts/check_xml_libxml' ? '/usr/local/cpanel/scripts/check_xml_libxml' : '/scripts/check_xml_libxml' ) );
chomp($is_ok);
if ( !$is_ok || $is_ok ne 'ok' ) {
    print "Patching Failed, restoring previous XML::LibXML!\n";
    my $mod_fh2 = Cpanel::SafeFile::safeopen( \*ER, '>', $module_path );
    if ( !$mod_fh2 ) {
        $logger->warn("Could not write to $module_path");
    }
    else {
        print ER $txt;
        Cpanel::SafeFile::safeclose( \*ER, $mod_fh2 );
    }
}

$ENV{XML::LibXML_PUREPERL} = 1;
$is_ok = Cpanel::SafeRun::Simple::saferun( ( -e '/usr/local/cpanel/scripts/check_xml_libxml' ? '/usr/local/cpanel/scripts/check_xml_libxml' : '/scripts/check_xml_libxml' ) );
chomp($is_ok);
if ( !$is_ok || $is_ok ne 'ok' ) {
    print "Patching Failed, restoring previous XML::LibXML!\n";
    my $mod_fh3 = Cpanel::SafeFile::safeopen( \*ER, '>', $module_path );
    if ( !$mod_fh3 ) {
        $logger->warn("Could not write to $module_path");
    }
    else {
        print ER $txt;
        Cpanel::SafeFile::safeclose( \*ER, $mod_fh3 );
    }
}

$is_ok = Cpanel::SafeRun::Simple::saferun( ( -e '/usr/local/cpanel/scripts/check_xml_libxml' ? '/usr/local/cpanel/scripts/check_xml_libxml' : '/scripts/check_xml_libxml' ) );
chomp($is_ok);
if ( !$is_ok || $is_ok ne 'ok' ) {
    system '/scripts/perlinstaller', '--force', 'XML::LibXML';
}