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/scripts.20110531.215904.25158/fixfrontpageperm
#!/usr/bin/perl
# cpanel - fixfrontpageperm                       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'; }

require 5.006;

use strict;
use warnings;

use Cpanel::FrontpageAdmin              ();
use Cpanel::Logger                      ();
use Cpanel::OSSys                       ();
use Cpanel::SafeFile                    ();

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

$| = 1;

my $sysname   = ( Cpanel::OSSys::uname() )[0];
my $nobodygid = ( getgrnam("nobody") )[2];
my $httpuid   = ( getpwnam("nobody") )[2];
if ( !$httpuid ) {
    $httpuid = ( getpwnam("nouser") )[2];
}
my $homedir;
my $myuid;

print "Setting default permissions....";
if ( $sysname =~ /freebsd/i ) {
    system( 'chflags', 'noschg', '/usr/local/frontpage/version5.0/apache-fp/_vti_bin/fpexe' );
}
else {
    system( 'chattr', '-i', '/usr/local/frontpage/version5.0/apache-fp/_vti_bin/fpexe' );
}
system('/usr/local/frontpage/version5.0/set_default_perms.sh');
if ( $sysname =~ /freebsd/i ) {
    system( 'chflags', 'schg', '/usr/local/frontpage/version5.0/apache-fp/_vti_bin/fpexe' );
}
else {
    system( 'chattr', '+i', '/usr/local/frontpage/version5.0/apache-fp/_vti_bin/fpexe' );
}
print "Done\n";

system '/scripts/initfpsuexec';

my $fileprotect = -e '/var/cpanel/fileprotect';

#
#   Read all the vhosts (main domains and subdomains) from the userdata cache
#
my $cache_lock = Cpanel::SafeFile::safeopen( \*CACHE, '<', '/etc/userdatadomains' );
if ( !$cache_lock ) {
    $logger->die( "Failed to open userdata cache file for reading: $!" );
}

my %vhosts;
while ( my $line = <CACHE> ) {
    chomp $line;
    next unless ( $line =~ /^\s*(.*?)\s*:\s*(.*)/ );
    my( $dns_name, $user, $reseller, $type, $parent, $docroot ) = ( $1, split( '==', $2 ) );
    if ( $type eq 'main' || $type eq 'sub' ) {
        $vhosts{$dns_name} = { user => $user, docroot => $docroot };
    }
}

if ( !Cpanel::SafeFile::safeclose( \*CACHE, $cache_lock ) ) {
    $logger->die( "Error closing userdata cache file: $!" );
}

my %SEEN_DOCROOTS;
foreach my $vhost ( keys %vhosts ) {
    next if ( $vhost =~ m/^__/ );

    my $docroot = $vhosts{$vhost}->{'docroot'};
    next if ( $SEEN_DOCROOTS{$docroot} );
    $SEEN_DOCROOTS{$docroot} = 1;

    my $user = $vhosts{$vhost}->{'user'};
    if ( !$user || $user eq 'root' ) { next; }

    my %WEBS;
    $WEBS{$docroot} = 1;
    Cpanel::FrontpageAdmin::loadsubwebs( \%WEBS, $docroot, 1 );

    my ( $uid, $gid ) = ( Cpanel::PwCache::getpwnam($user) )[ 2, 3 ];

    foreach my $docroot ( keys %WEBS ) {

        if ($fileprotect) {
            Cpanel::FrontpageAdmin::webprotect( $docroot, $uid, $nobodygid );
        }
        else {
            Cpanel::FrontpageAdmin::unwebprotect( $docroot, $uid, $gid );
        }

        Cpanel::FrontpageAdmin::dopassmod( $docroot, $uid, $nobodygid );
    }
}

exit();