#!/usr/local/cpanel/3rdparty/bin/perl
# cpanel - scripts/disablefileprotect Copyright 2019 cPanel, L.L.C.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
use strict;
use warnings;
use Cpanel::Filesys::Mounts ();
use Cpanel::FileProtect ();
use Cpanel::FileProtect::Sync ();
use Cpanel::LoginDefs ();
use Cpanel::Config::LoadCpConf ();
use Cpanel::Config::LoadWwwAcctConf ();
use Cpanel::PwCache::Build ();
local $| = 1;
display_help() if ( $ARGV[0] && $ARGV[0] eq '--help' );
my $cpconf_ref = Cpanel::Config::LoadCpConf::loadcpconf_not_copy();
my $wwwacct_ref = Cpanel::Config::LoadWwwAcctConf::loadwwwacctconf();
my $home = $wwwacct_ref->{'HOMEDIR'} || '/home';
my $homematch = $wwwacct_ref->{'HOMEMATCH'};
if ( !-e $home ) {
mkdir $home;
}
my $disks = Cpanel::Filesys::Mounts::get_disk_mounts();
foreach my $mount ( values %{$disks}, $home ) {
if ( $mount eq $home || ( $homematch && $mount =~ m/$homematch/ ) ) {
print "Setting $mount permissions to 0711....";
chmod 0711, $mount;
print "..Done\n";
}
}
if ( Cpanel::FileProtect->is_on() ) {
Cpanel::FileProtect->set_off() or die "Error while removing /var/cpanel/fileprotect to disable Fileprotect support: $!";
}
print 'Setting permissions for.....';
my $pwcache_ref = Cpanel::PwCache::Build::fetch_pwcache();
my $min_uid = Cpanel::LoginDefs::get_uid_min();
foreach my $pw (@$pwcache_ref) {
next if ( !$pw->[0] || !-e '/var/cpanel/users/' . $pw->[0] );
my $useruid = $pw->[2];
my $usergid = $pw->[3];
next if $useruid < $min_uid;
my $homedir = $pw->[7];
next if !$homedir || !-d $homedir;
print "$pw->[0] …\n";
warn $_->to_string() for Cpanel::FileProtect::Sync::sync_user_homedir( $pw->[0] );
}
print "...Done\n";
sub display_help {
print <<"EO_HELP";
Usage: $0 [--help]
Unprotect the public_html directory of each user account so that all users may view its
contents. Use the enablefileprotect script to reverse the process.
Options:
--help - this screen
EO_HELP
exit;
}
Copyright 2K16 - 2K18 Indonesian Hacker Rulez