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/killdrrootvhost
#!/usr/bin/perl
# cpanel - killrrootvhost                         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 Cpanel::Logger ();

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

my $httpconf = find_httpconf();

my $user = $ARGV[0];
die "No user specified" if !$user;

if ( !getpwnam $user ) {
    print "user $user does not exist!\n";
    exit 1;
}

my $homedir = ( getpwnam($user) )[7];

if ( !$homedir || $homedir eq '/' ) {
    print "Invalid Homedir for user $user\n";
    exit 1;
}

$hasip = 1;

Cpanel::RcsRecord::rcsrecord($httpconf);

$httplock = Cpanel::SafeFile::safeopen( \*HTTPCONF, "+<", $httpconf );
if ( !$httplock ) {
    $logger->die("Could not edit $httpconf");
}
my @THTTPCONF = <HTTPCONF>;
seek( HTTPCONF, 0, 0 );
$pln = 1;
foreach $line (@THTTPCONF) {
    $line =~ s/\n//g;
    $sline = $line;
    $sline =~ s/[\s\t]*$//g;

    if ( $sline =~ /documentroot[\s\t]+${homedir}\//i ) {
        $pln = 0;
    }
    if ( $sline =~ /<virtualhost/i && $sline !~ /^(\s*\t*)#/ && $sline !~ /^#/ ) {
        $ivh = 1;
        $vh  = '';
        $pln = 1;
    }
    if ($ivh) { $vh = $vh . $line . "\n"; }
    if ( $ivh == 0 ) {
        print HTTPCONF "$line\n";
    }
    if ( $sline =~ /<\/virtualhost/i && $sline !~ /^(\s*\t*)#/ && $sline !~ /^#/ ) {
        $ivh = 0;
        if ( $pln == 1 ) { print HTTPCONF $vh; }
        $vh = '';
    }
}
truncate( HTTPCONF, tell(HTTPCONF) );
Cpanel::SafeFile::safeclose( \*HTTPCONF, $httplock );
Cpanel::RcsRecord::rcsrecord("$httpconf");

print "Removed Extra Entries from httpd.conf\n";

sub find_httpconf {
    my ( @LOC, $loc );
    @LOC = ( "/usr/local/apache/conf/httpd.conf", "/etc/httpd/conf/httpd.conf" );
    foreach $loc (@LOC) {
        if ( -e $loc ) { return $loc; }
    }
    return "";
}