403Webshell
Server IP : 103.119.228.120  /  Your IP : 18.188.68.115
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /scripts/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /scripts/resetquotas
#!/usr/local/cpanel/3rdparty/bin/perl

# cpanel - scripts/resetquotas                     Copyright 2022 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

package scripts::resetquotas;

use strict;
use warnings;

use Cpanel::Config::LoadCpUserFile ();
use Cpanel::Config::Users          ();
use Cpanel::Quota::Common          ();
use Cpanel::FindBin                ();
use Cpanel::SafeRun::Errors        ();
use Cpanel::SysQuota::Cache        ();

__PACKAGE__->run() unless caller();

my %cmd;

sub run {    ## no critic qw(Subroutines::ProhibitExcessComplexity)
    if ( @ARGV && $ARGV[0] ne '--useplanquotas' ) {
        print "Note: call resetquota with --useplanquotas to reset all quotas to plan defaults\n";
    }

    my $quotaconf_ref = {};
    my @systemusers   = Cpanel::Config::Users::getcpusers();

    %cmd = (
        'quotaon'  => undef,
        'quotaoff' => undef,
        'edquota'  => undef,
    );

    my @missing_cmds;
    foreach my $cmd_name ( keys %cmd ) {
        $cmd{$cmd_name} = Cpanel::FindBin::findbin($cmd_name);
        if ( !-x $cmd{$cmd_name} ) {
            push @missing_cmds, $cmd_name;
        }
    }

    if ( scalar @missing_cmds ) {
        print "Incomplete quota kit: unable to reset quotas.\n";
        print 'Missing commands: ', join( ', ', @missing_cmds ), "\n";
        exit 1;
    }

    Cpanel::SafeRun::Errors::saferunnoerror( $cmd{'quotaoff'}, '-a' );

    my %planquota;
    foreach my $user ( sort @systemusers ) {

        # Safe because it's only loading from cpusers list.
        my $cpuser = Cpanel::Config::LoadCpUserFile::loadcpuserfile($user);

        next if !$cpuser->{'PLAN'};
        my $plan = $cpuser->{'PLAN'};
        $plan =~ tr/\///d;
        next if ( $plan eq '' || $plan =~ m/^\.+$/ );
        my $pkgquota;
        if ( exists $planquota{$plan} ) {
            $pkgquota = $planquota{$plan};
        }
        elsif ( -r '/var/cpanel/packages/' . $plan ) {
            if ( open my $plan_fh, '<', '/var/cpanel/packages/' . $plan ) {
                print "Reading package $plan\n";
                while (<$plan_fh>) {
                    if (/^QUOTA=(\S+)/) {
                        my $plan_quota = $1;
                        if ( $plan_quota =~ m/unlimited/i ) {
                            $pkgquota = $planquota{$plan} = 0;
                        }
                        elsif ( $plan_quota =~ m/(\d+)/i ) {
                            $pkgquota = $planquota{$plan} = $1;
                        }
                    }
                }
                close $plan_fh;
            }

            # Default quota to 'unlimited'
            if ( !defined $pkgquota ) {
                $pkgquota = $planquota{$plan} = 0;
            }

        }

        if ( exists $cpuser->{'DISK_BLOCK_LIMIT'} ) {
            $quotaconf_ref->{$user} = $cpuser->{'DISK_BLOCK_LIMIT'} ? ( int( $cpuser->{'DISK_BLOCK_LIMIT'} / $Cpanel::Quota::Common::MEGABYTES_TO_BLOCKS ) || 1 ) : 0;
        }
        if ( ( !exists $quotaconf_ref->{$user} || $quotaconf_ref->{$user} eq '' ) && $pkgquota ) { $quotaconf_ref->{$user} = $pkgquota; }

        if ( @ARGV && $ARGV[0] eq '--useplanquotas' && $pkgquota ne '' ) {
            if ( $quotaconf_ref->{$user} != $pkgquota ) {
                print "Adjusting user $user quota to the package's ($plan) value.\n";
            }
            $quotaconf_ref->{$user} = $pkgquota;
        }
        next if ( !exists $quotaconf_ref->{$user} || $quotaconf_ref->{$user} eq '' );
        if ( my $pid = fork() ) {
            print "Resetting quota for $user to $quotaconf_ref->{$user} M\n";
            waitpid( $pid, 0 );
        }
        else {
            open( STDOUT, '>', '/dev/null' ) || die;
            editquota( $user, $quotaconf_ref->{$user} );
            exit;
        }
    }

    # Update quota file mtimes
    Cpanel::Quota::Common->new()->update_mtimes_to_clear_cache();

    Cpanel::SafeRun::Errors::saferunnoerror( $cmd{'quotaon'}, '-a' );

    Cpanel::SysQuota::Cache::purge_cache();

    exit 0;
}

sub editquota {
    my $user = shift || return;
    my $quot = shift || 0;

    ## TODO @GOLIVE: the cpanelroundcube user is going away
    if ( $user =~ /^cpanel(horde|phpmyadmin|phppgadmin|roundcube)$/ ) {
        $quot = 0;
    }

    my $megquota = $quot;
    $quot = int $quot;
    $quot = ( $quot * 1024 );
    $quot = sprintf( '%.0f', $quot );

    $ENV{'NQUOTA'} = $quot;
    $ENV{'VISUAL'} = '/usr/local/cpanel/scripts/pedquota';
    $ENV{'EDITOR'} = '/usr/local/cpanel/scripts/pedquota';

    system $cmd{'edquota'}, '-u', $user;

    return;
}

Youez - 2016 - github.com/yon3zu
LinuXploit