403Webshell
Server IP : 103.119.228.120  /  Your IP : 18.118.19.123
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 :  /sbin/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /sbin/dovecot_cpshutdown
#!/usr/local/cpanel/3rdparty/bin/perl

use strict;
use warnings;

use Time::HiRes ();

use constant DOVECOT_PROCESS_NAMES => qw(
  dovecot
  dovecot-auth
  dovecot/pop3-login
  dovecot/imap-login
  dovecot/anvil
  dovecot/log
  dovecot/config
  dovecot/auth
  dovecot-wrap
);

my $MAX_WAIT       = 30;    #seconds
my $SLEEP_INTERVAL = 0.1;

my $pidfile = '/var/run/dovecot/master.pid';

#----------------------------------------------------------------------

if ( "@ARGV" =~ m<--help> ) {
    print <<END;
This script shuts down Dovecot safely: gracefully at first,
then forcefully if Dovecot’s processes don’t go away.
END
    exit;
}

my $master_pid;
if ( open my $pfh, '<', $pidfile ) {
    print "Opened “$pidfile” …\n";

    $master_pid = readline($pfh);
    if ( !defined $master_pid ) {
        die "read($pidfile): $!" if $!;
    }

    chomp $master_pid;

    if ( $master_pid =~ m<\A[0-9]+\z> ) {
        print "Master Dovecot process = $master_pid\n";
    }
    else {
        warn "Invalid contents in “$pidfile”: [$master_pid]\n";
        undef $master_pid;
    }
}
elsif ( $!{'ENOENT'} ) {
    print "“$pidfile” doesn’t exist!\n";
}
else {
    die "open($pidfile): $!";
}

my @CMD = qw( /usr/sbin/dovecot stop );

print "Executing “@CMD” …\n";

my $pid = fork();
die "Failed to fork child process for “@CMD”" if !defined $pid;

if ( $pid ) {

    print "Waiting $MAX_WAIT seconds for process $pid to end …\n";
    my $start = time();

    my $killed;
    while ( !waitpid( $pid, 1 ) ) {

        if ( time > ( $start + $MAX_WAIT ) ) {
            print "Process $pid has taken over $MAX_WAIT seconds to shut down.\n";
            kill 'KILL', $pid;
            waitpid($pid, 0);
            $killed = 1;
            last;
        }

        Time::HiRes::sleep($SLEEP_INTERVAL);
    }

    # If we killed the dovecot stop command we want to fallthrough to the rest of the shutdown
    # but not if it terminated with a legitimate error.
    exit 1 if $? && !$killed;
}
else {
    exec(@CMD) or die "Failed to run “@CMD”: $!";
}

print "Done! Waiting $MAX_WAIT seconds for process $master_pid to end …\n";

if ( length $master_pid ) {
    my $start = time();

    my $end;

    while ( !$end ) {
        if ( kill 'ZERO', $master_pid ) {
            if ( time > ( $start + $MAX_WAIT ) ) {
                print "Process $master_pid has taken over $MAX_WAIT seconds to shut down.\n";
                _safekill_any_remaining_dovecot_processes();
                $end = 1;
            }

            Time::HiRes::sleep($SLEEP_INTERVAL);
        }
        else {
            print "Dovecot is now shut down.\n";

            # We may have some stragglers so we
            # do a safekill just in case in order to handle:
            #
            # Case 187449: /etc/init.d/dovecot does not stop
            # properly dovecot
            #
            # When stopping dovecot we are killing some processes
            # but a few of them might survive when dovecot-wrap is
            # stalled.
            _safekill_any_remaining_dovecot_processes();
            $end = 1;
        }
    }
}

sub _safekill_any_remaining_dovecot_processes {
    print "Any remaining Dovecot processes will now be terminated.\n";
    system( '/usr/local/cpanel/etc/init/safekill', DOVECOT_PROCESS_NAMES );
}

1;

Youez - 2016 - github.com/yon3zu
LinuXploit