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/proc/self/root/scripts.20110531.215904.25158/setupmakeconf
#!/usr/bin/perl
# cpanel - setupmakeconf                          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::RcsRecord ();
use Cpanel::SafeFile;
use strict;
use Cpanel::Logger ();
my $logger = Cpanel::Logger->new();

exit if ( $^O !~ /freebsd/i );

my (@L);
open( AP, "/scripts/make_config" );
while (<AP>) {
    next if (/^$/);
    next if (/^\n$/);
    next if (/^\r\n$/);
    push( @L, $_ );
}

close(AP);

Cpanel::RcsRecord::rcsrecord("/etc/make.conf");

addlinedelold( "/etc/make.conf", @L );

Cpanel::RcsRecord::rcsrecord("/etc/make.conf");

sub addlinedelold {
    my ( $file, @LINES ) = @_;
    my (@CFILE);
    my $fhlock = Cpanel::SafeFile::safeopen( \*FH, "+<", "$file" );
    if ( !$fhlock ) {
        $logger->die("Could not edit $file");
    }
    while (<FH>) {
        if ( -e "/usr/local/apache/bin/suexec" && /scgi-bin/ && /^ScriptAlias/i && /scgiwrap/ ) { next; }
        if ( $_ =~ /^$/ || $_ eq "\n" || $_ eq "\r\n" ) {
            push( @CFILE, $_ );
        }
        else {
            my $printthisline = 1;
            foreach my $line (@LINES) {
                my $testline = $line;
                $testline =~ s/^\*REMOVE\*\s//g;
                if ( beginmatch( $_, ${testline} ) ) {
                    $printthisline = 0;
                    last;
                }
            }
            if ($printthisline) { push( @CFILE, $_ ); }
        }
    }
    seek( FH, 0, 0 );
    foreach my $line (@LINES) {
        next if ( $line =~ /^\*REMOVE\*\s/ );
        push( @CFILE, $line );
    }
    print FH join( "", @CFILE );
    truncate( FH, tell(FH) );
    Cpanel::SafeFile::safeclose( \*FH, $fhlock );
}

sub beginmatch {
    my ( $haystack, $needle ) = @_;

    $haystack =~ tr/[A-Z]/[a-z]/;
    $needle   =~ tr/[A-Z]/[a-z]/;
    if ( substr( $haystack, 0, length($needle) ) eq $needle ) {
        return (1);
    }

    return (0);
}