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_cpanel_net_ssleay
#!/usr/bin/perl
# cpanel - build-tools/patch_cpanel_net_ssleay           Copyright(c) 2011 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

# This can double as an autofixer

BEGIN { unshift @INC, '/usr/local/cpanel' }

use Cpanel::SafeFile ();
use Cpanel::LoadFile ();
use Cpanel::Logger   ();
use AutoSplit        ();

my $logger      = Cpanel::Logger->new();
my $module_path = '/usr/local/cpanel/perl/Net/SSLeay.pm';
if ( !-e $module_path ) {
    print STDERR "Net::SSLeay is not installed at /usr/local/cpanel/perl/Net/SSLeay.pm\n";
    exit 1;
}

my $txt = Cpanel::LoadFile::loadfile($module_path);

my ($NetSSLeayVERSION) = $txt =~ m/^\s*\$VERSION\s*=\s*\'?([^;']+)/m;

if ( $NetSSLeayVERSION != 1.35 && $NetSSLeayVERSION != 1.36 ) {
    die "I do not know how to patch NetSSLeay other than 1.35-1.36. This is version $NetSSLeayVERSION\n";
}

print "Checking $module_path\n";

my $module_dir = $module_path;
$module_dir =~ s{/Net/SSLeay.pm}{}g;
my $auto_dir = $module_dir . '/auto';

if ( $txt !~ m/^\s*use\s+Socket\s*;/m && $txt !~ m/^\s*use\s+Carp\s*;/m && $txt !~ /([\(\s]+)sockaddr_in([\s+\(])/m && $txt !~ /^sockaddr_in([\s+\(])/m && $txt !~ /([\(\s]+)inet_ntoa([\s+\(])/m && $txt !~ /^inet_ntoa([\s+\(])/m ) { exit; }

print "Removing unneeded import of Socket and Carp symbols from Net::SSLeay\n";

my $el = Cpanel::SafeFile::safeopen( \*ER, '+<', $module_path );
if ( !$el ) {
    $logger->die("Could not edit $module_path");
}
my @EN = <ER>;
seek( ER, 0, 0 );
my $inconfig = 0;
foreach (@EN) {
    s/use\s*Socket[\s\(\)]*;/use Socket qw(PF_INET SOCK_STREAM);/g;
    s/use\s*Carp\s*;/use Carp ();/g;
    s/([\(\s]+)croak([\s+\(])/${1}Carp::croak$2/g;
    s/([\(\s]+)carp([\s+\(])/${1}Carp::carp$2/g;
    s/([\(\s]+)confess([\s+\(])/${1}Carp::confess$2/g;
    s/([\(\s]+)cluck([\s+\(])/${1}Carp::cluck$2/g;
    s/([\(\s]+)sockaddr_in([\s+\(])/${1}Socket::sockaddr_in$2/g;
    s/([\(\s]+)inet_ntoa([\s+\(])/${1}Socket::inet_ntoa$2/g;
    s/^croak([\s+\(])/Carp::croak$1/g;
    s/^carp([\s+\(])/Carp::carp$1/g;
    s/^confess([\s+\(])/Carp::confess$1/g;
    s/^cluck([\s+\(])/Carp::cluck$1/g;
    s/^sockaddr_in([\s+\(])/Socket::sockaddr_in$1/g;
    s/^inet_ntoa([\s+\(])/Socket::inet_ntoa$1/g;

    print ER $_;
}
truncate( ER, tell(ER) );
Cpanel::SafeFile::safeclose( \*ER, $el );

AutoSplit::autosplit( $module_path, $auto_dir, 0, 1, 1 )