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/checkallowoverride
#!/usr/bin/perl
# cpanel - checkallowoverride                     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::RcsRecord            ();
use Cpanel::HttpUtils::ApRestart ();
use Cpanel::Logger               ();

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

my $httpdconf = '/usr/local/apache/conf/httpd.conf';
my $restart   = @ARGV && grep( /^--no-restart$/, @ARGV ) ? 0 : 1;
my $verbose   = @ARGV && grep( /^--verbose$/, @ARGV ) ? 1 : 0;

my $hlock = Cpanel::SafeFile::safeopen( \*HTTPC, '<', $httpdconf );
if ( !$hlock ) {
    $logger->die("Could not read from $httpdconf");
}
my $inslashdir;
my $needs_update;
while (<HTTPC>) {
    if ($inslashdir) {
        if ( m/^\s*AllowOverride\s+none/i || m/^\s*Order\s+/i || m/^\s*Deny\s+/i ) {
            $needs_update = 1;
        }
    }
    if (m/^\s*<Directory\s+"?\/"?>/i) {
        $inslashdir = 1;
    }
    elsif (m/^\s*<\/Directory/i) {
        $inslashdir = 0;
    }

}
Cpanel::SafeFile::safeclose( \*HTTPC, $hlock );

exit if !$needs_update;

print "Updating Apache configuration\n";

$inslashdir = 0;
$hlock      = '';

Cpanel::RcsRecord::rcsrecord( $httpdconf, 'checkallowoverride BEGIN' );

$hlock = Cpanel::SafeFile::safeopen( \*HTTPC, '+<', $httpdconf );
if ( !$hlock ) {
    $logger->die("Could not edit $httpdconf");
}
while (<HTTPC>) {
    push @CFILE, $_;
}
seek( HTTPC, 0, 0 );

foreach (@CFILE) {
    if ($inslashdir) {
        if (m/^(\s*)AllowOverride\s+none/i) {
            print "Updating AllowOverride to All\n" if $verbose;
            print HTTPC $1 . "AllowOverride All\n";
        }
        elsif (m/^(\s*)Options\s+(?:none|follow)/i) {
            print "Updating Options to All\n" if $verbose;
            print HTTPC $1 . "Options All\n";
        }
        elsif ( m/^\s*Order\s+/ || m/^\s*Deny\s+/ ) {
            print "Removing $_" if $verbose;
            next;
        }
        else {
            print HTTPC;
        }
    }
    else {
        print HTTPC;
    }
    if (m/^\s*<Directory\s+"?\/"?>/i) {
        $inslashdir = 1;
    }
    if (m/^\s*<\/Directory/i) {
        $inslashdir = 0;
    }
}
truncate( HTTPC, tell(HTTPC) );
Cpanel::SafeFile::safeclose( \*HTTPC, $hlock );

Cpanel::RcsRecord::rcsrecord( $httpdconf, 'checkallowoverride END' );

if ($restart) {
    Cpanel::HttpUtils::ApRestart::safeaprestart();
}

exit;