%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /root/
Upload File :
Create Path :
Current File : //root/.bash_history.cpanel_ticket.94491430

#1664959535
export PS1="Still logged into remote - \TcPs# "
#1664959535
export LANG=en_US.UTF-8
#1664959535
export PS1="[\t \h \u@94491430 \w]cPs# "
#1664959536
export HISTFILE=~/.bash_history.cpanel_ticket.94491430
#1664959536
export HISTFILESIZE=100000
#1664959538
set +o emacs +o vi
#1664959538
IFS='' read -r -d '' PACHA_AUTOFIXER <<-'EOF_PACHA'
use strict;

BEGIN {
    unshift @INC, '/usr/local/cpanel';
}

our $VERSION = '1.2';

my $shell_pid = get_shell_pid();
my $shell_exe = get_pid_exe($shell_pid);

$| = 1;

print "ENTER_TEMP_RESELLER_AND_PASSWORD: ";

open( STDIN, '<&STDOUT' ) || die "Could not open STDOUT";
my $userpass = <STDIN>;
chomp($userpass);

eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };

if ( !$userpass ) {
    die "Failed to read userpass";
}

my ( $user, $pass ) = split( m{\s+}, $userpass, 2 );

if ( $user !~ /^cp/ ) {
    die "User must start with cp";
}

my ($ticket_number) = ( $user =~ m/([0-9]+)/ );

$SIG{'INT'}   = \&exit_cleanly;
$SIG{'TERM'}  = \&exit_cleanly;
$SIG{__DIE__} = \&exit_cleanly;

if ( my $pid = fork() ) {

}
else {
    $0 = "cpanelsupportmgr - waiting for $shell_pid to exit for cleanup";
    daemonize();
    wait_for_death($shell_pid);
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

add_user( $user, "auto onetime user for cpanel ticket $ticket_number autoremoved at logout" ) if !getpwnam($user);
set_user_pass( $user, $pass );
make_root_reseller($user);

print "CREATE_TEMP_RESELLER_DONE\n";

sub exit_cleanly {
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

sub unmake_root_reseller {
    my ($user) = @_;

    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt !~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already removed from resellers\n";
        return;
    }
    my @all_res_line = grep { !m/^\Q$user\E:/ } split( /\n/, $txt );
    seek( $fh, 0, 0 );
    print {$fh} join( "\n", @all_res_line ) . "\n";
    truncate( $fh, tell($fh) );
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub make_root_reseller {
    my ($user) = @_;
    eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };
    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt =~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already in resellers\n";
        return;
    }
    print {$fh} "$user:all\n";
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub set_user_pass {
    my ( $user, $pass ) = @_;
    local $ENV{'ALLOW_PASSWORD_CHANGE'} = 1;
    my $script_path 
    if ( -d "/usr/local/cpanel/scripts" ) {
        $script_path = "/usr/local/cpanel/scripts";
    }
    my $chpass_write_fh;
    my $chpass_read_fh;
    my $pid = inout( $chpass_write_fh, $chpass_read_fh, "$script_path/chpass" );
    if ( !$pid ) {
        return (
            0,
            "Failed to execute: $script_path/chpass: $!",
            "Failed to execute: $script_path/chpass: $!"
        );
    }
    print {$chpass_write_fh} "$user $pass\n";
    close($chpass_write_fh);
    my $result;
    {
        local $/ = undef;
        $result = readline($chpass_read_fh);
    }
    close($chpass_read_fh);
    waitpid( $pid, 0 );
    return $result;

}

sub get_shell_pid {
    my $parent_pid = get_parent_pid($$);
    while ( get_pid_exe($parent_pid) =~ /perl/ ) {
        $parent_pid = get_parent_pid($parent_pid);
    }
    return $parent_pid;
}

sub _zero_quota {
    my $login = shift;

    system( '/usr/local/cpanel/scripts/editquota', $login, '0M' );
    return $?;
}

sub add_user {
    my ( $login, $comment ) = @_;
    system '/usr/sbin/useradd', '-c', $comment, $login;
    my $ua_status = $?;
    if ( open( my $cph_fh, '>', "/var/cpanel/users/$login" ) ) {
        my $time = time();

        print {$cph_fh} "#Automatic temp user created by cPanel support\nCONTACTEMAIL=cs\@cpanel.net\nPLAN=cPanel Ticket System temporary user\nOWNER=root\nSTARTDATE=$time\nDNS=$login.tickets.cpanel.net\nUSER=$login\n";
        close($cph_fh);
    }
    return $ua_status;
}

sub remove_user {
    my ($login) = @_;
    system '/usr/sbin/userdel', '-r', $login;
    system '/usr/sbin/userdel', $login;
    unlink( "/var/cpanel/users/$login", "/var/cpanel/users.cache/$login" );
    system '/scripts/updateuserdomains';    # remove it for sure
    return $?;
}

sub get_parent_pid {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return getppid() if $pid == $$;
    if ( open( my $proc_status_fh, '<', "/proc/$pid/status" ) ) {
        local $/;
        my %status = map { lc $_->[0] => $_->[1] }
          map { [ ( split( /\s*:\s*/, $_ ) )[ 0, 1 ] ] }
          split( /\n/, readline($proc_status_fh) );
        return $status{'ppid'};
    }

}

sub get_pid_exe {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return readlink( '/proc/' . $pid . '/exe' );
}

sub inout {    ## no critic qw(RequireArgUnpacking)
    my $wtr = $_[0] ||= SymbolLite::gensym();
    my $rdr = $_[1] ||= SymbolLite::gensym();

    my $child_read;

    pipe( $child_read, $wtr );

    select( ( select($wtr),        $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $wtr->autoflush(1);
    select( ( select($child_read), $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $child_read->autoflush(1);

    if ( my $pid = open( $rdr, '-|' ) ) {
        return $pid;
    }
    elsif ( defined $pid ) {
        open( STDIN, '<&=', fileno($child_read) ) || die "Could not open STDIN";
        if ( ref $_[2] eq 'CODE' ) {
            $_[2]->();
            exec( @_[ 3 .. $#_ ] );
        }
        else {
            exec( @_[ 2 .. $#_ ] );
        }
        exit 1;
    }
    else {
        return;
    }
}

sub wait_for_death {
    my (@pids) = @_;

    my $num_killed = kill( 0, @pids );

    my $loop_count = 0;
    while ( $num_killed && ++$loop_count <= 345600 ) {    # Will timeout after about 24 hours if cp staff has not disconnected.
        $num_killed = kill( 0, @pids );
        select( undef, undef, undef, 0.25 )               ## no critic qw(ProhibitSleepViaSelect);
    }

    return;
}

sub daemonize {
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require Cpanel::CloseFDs; };
    setpgrp( 0, 0 );                                      #cheap setsid();
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; Cpanel::CloseFDs::fast_daemonclosefds(); } if $INC{'Cpanel/CloseFDs.pm'};
    if ( !$INC{'Cpanel/CloseFDs.pm'} || $@ ) {
        eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require POSIX; };
        open( STDOUT, '>', '/dev/null' ) || warn "Failed to connect STDOUT to /dev/null";
        open( STDERR, '>', '/dev/null' ) || warn "Failed to connect STDERR to /dev/null";
        open( STDIN,  '<', '/dev/null' ) || warn "Failed to connect STDIN to /dev/null";
        eval {
            local $SIG{__WARN__};
            local $SIG{__DIE__};
            for ( 3 .. 1024 ) {
                POSIX::close($_);
            }
        };
    }

    return 1;

}

package SymbolLite;

my $genpkg = "SymbolLite::";
my $genseq = 0;

sub gensym {
    no strict 'refs';    ## no critic qw(ProhibitNoStrict);
    my $name = "GEN" . $genseq++;
    my $ref  = \*{ $genpkg . $name };
    delete $$genpkg{$name};
    return $ref;
}

EOF_PACHA

#1664959538
echo "$PACHA_AUTOFIXER" | /usr/local/cpanel/3rdparty/bin/perl -c
#1664959542
set -o emacs
#1664959542
/bin/mkdir /tmp/RrehlJPgjjMHG4Aw/
#1664959542
/bin/chown vipin:vipin /tmp/RrehlJPgjjMHG4Aw/
#1664959542
/bin/chmod 744 /tmp/RrehlJPgjjMHG4Aw/
#1664959542
[ -d "/tmp/RrehlJPgjjMHG4Aw/" ]&&echo "TMP_DIR_EXISTS"||echo "TMP_DIR_MISSING"
#1664959543
/usr/local/cpanel/3rdparty/bin/perl /tmp/RrehlJPgjjMHG4Aw/create_temp_reseller_for_ticket_access_Wz0_d_Sb5YxmNKCI; /bin/rm -rf /tmp/RrehlJPgjjMHG4Aw/
#1664959544
echo "e.narcisse@cpanel.net (WHMuser: cptktiijk147z5qn ) logged in for 94491430  - ready for cPanel support"
#1664959544
uname -a
#1664959544
echo -ne '\033]0;cPTKT 94491430 - WHM Error, Server: 1\007'
#1664959547
alias reboot='echo "Are you sure you want to REBOOT a customer server? If so use /usr/sbin/reboot"'
#1664959547
alias rm='echo "Are you sure you want to remove files? If so use /bin/rm"'
#1664959547
alias acctinfo='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/cPanelInc/tech-acctinfo/master/acctinfo)'
#1664959547
alias init='echo "Are you sure you want to change run runlevel on a customer server? If so use /usr/sbin/init"'
#1664959547
alias cplicensets='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-cp_license_troubleshooter/master/cplicensets)'
#1664959547
alias shutdown='echo "Are you sure you want to SHUTDOWN a customer server? If so use /usr/sbin/shutdown"'
#1664959547
alias sqlite3='/usr/local/cpanel/3rdparty/bin/sqlite3'
#1664959547
alias crontab='crontab -i'
#1664959547
curl https://ssp.cpanel.net/run|sh
#1664959835
wc -l /etc/trueuserdomains
#1664960175
curl -sILk gifterman.in
#1664960180
curl -sILkv gifterman.in
#1664960188
curl -sILkv https://gifterman.in
#1664960208
grep -B2 -A4 'e gifterman.in' /etc/apache2/conf/httpd.conf
#1664960226
dig gifterman.in +short
#1664960229
ip addr | awk 'BEGIN {FS="[ \t/]+"} /inet .+global/ { print $3 }' | xargs -iIP sh -c "echo -n 'internal IP - external ';wget -O - -q --tries=1 --timeout=10 --bind-address=IP http://cpanel.net/myip || echo NO REPLY"
#1664960280
/scripts/whoowns gifterman.in
#1664960291
grep wwwgifterman /etc/userdatadomains
#1664960299
acctinfo gifterman.in
#1664960347
less /var/cpanel/accounting.log 
#1664960379
grep gifter /var/cpanel/accounting.log
#1664960403
grep bonifacegroup.com /var/cpanel/accounting.log
#1664960409
acctinfo bonifacegroup.com
#1664960798
/scripts/updateuserdatacache 
#1664960804
/scripts/updateuserdomains 
#1664960811
acctinfo gifterman.in
#1664960856
/scripts/rebuildhttpdconf 
#1664960867
acctinfo gifterman.in
#1664960924
grep -B2 -A4 'e gifterman.in' /etc/apache2/conf/httpd.conf
#1664961561
exit
#1664976231
export PS1="Still logged into remote - \TcPs# "
#1664976231
export LANG=en_US.UTF-8
#1664976231
export PS1="[\t \h \u@94491430 \w]cPs# "
#1664976231
export HISTFILE=~/.bash_history.cpanel_ticket.94491430
#1664976232
export HISTFILESIZE=100000
#1664976234
set +o emacs +o vi
#1664976234
IFS='' read -r -d '' PACHA_AUTOFIXER <<-'EOF_PACHA'
use strict;

BEGIN {
    unshift @INC, '/usr/local/cpanel';
}

our $VERSION = '1.2';

my $shell_pid = get_shell_pid();
my $shell_exe = get_pid_exe($shell_pid);

$| = 1;

print "ENTER_TEMP_RESELLER_AND_PASSWORD: ";

open( STDIN, '<&STDOUT' ) || die "Could not open STDOUT";
my $userpass = <STDIN>;
chomp($userpass);

eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };

if ( !$userpass ) {
    die "Failed to read userpass";
}

my ( $user, $pass ) = split( m{\s+}, $userpass, 2 );

if ( $user !~ /^cp/ ) {
    die "User must start with cp";
}

my ($ticket_number) = ( $user =~ m/([0-9]+)/ );

$SIG{'INT'}   = \&exit_cleanly;
$SIG{'TERM'}  = \&exit_cleanly;
$SIG{__DIE__} = \&exit_cleanly;

if ( my $pid = fork() ) {

}
else {
    $0 = "cpanelsupportmgr - waiting for $shell_pid to exit for cleanup";
    daemonize();
    wait_for_death($shell_pid);
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

add_user( $user, "auto onetime user for cpanel ticket $ticket_number autoremoved at logout" ) if !getpwnam($user);
set_user_pass( $user, $pass );
make_root_reseller($user);

print "CREATE_TEMP_RESELLER_DONE\n";

sub exit_cleanly {
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

sub unmake_root_reseller {
    my ($user) = @_;

    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt !~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already removed from resellers\n";
        return;
    }
    my @all_res_line = grep { !m/^\Q$user\E:/ } split( /\n/, $txt );
    seek( $fh, 0, 0 );
    print {$fh} join( "\n", @all_res_line ) . "\n";
    truncate( $fh, tell($fh) );
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub make_root_reseller {
    my ($user) = @_;
    eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };
    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt =~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already in resellers\n";
        return;
    }
    print {$fh} "$user:all\n";
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub set_user_pass {
    my ( $user, $pass ) = @_;
    local $ENV{'ALLOW_PASSWORD_CHANGE'} = 1;
    my $script_path 
    if ( -d "/usr/local/cpanel/scripts" ) {
        $script_path = "/usr/local/cpanel/scripts";
    }
    my $chpass_write_fh;
    my $chpass_read_fh;
    my $pid = inout( $chpass_write_fh, $chpass_read_fh, "$script_path/chpass" );
    if ( !$pid ) {
        return (
            0,
            "Failed to execute: $script_path/chpass: $!",
            "Failed to execute: $script_path/chpass: $!"
        );
    }
    print {$chpass_write_fh} "$user $pass\n";
    close($chpass_write_fh);
    my $result;
    {
        local $/ = undef;
        $result = readline($chpass_read_fh);
    }
    close($chpass_read_fh);
    waitpid( $pid, 0 );
    return $result;

}

sub get_shell_pid {
    my $parent_pid = get_parent_pid($$);
    while ( get_pid_exe($parent_pid) =~ /perl/ ) {
        $parent_pid = get_parent_pid($parent_pid);
    }
    return $parent_pid;
}

sub _zero_quota {
    my $login = shift;

    system( '/usr/local/cpanel/scripts/editquota', $login, '0M' );
    return $?;
}

sub add_user {
    my ( $login, $comment ) = @_;
    system '/usr/sbin/useradd', '-c', $comment, $login;
    my $ua_status = $?;
    if ( open( my $cph_fh, '>', "/var/cpanel/users/$login" ) ) {
        my $time = time();

        print {$cph_fh} "#Automatic temp user created by cPanel support\nCONTACTEMAIL=cs\@cpanel.net\nPLAN=cPanel Ticket System temporary user\nOWNER=root\nSTARTDATE=$time\nDNS=$login.tickets.cpanel.net\nUSER=$login\n";
        close($cph_fh);
    }
    return $ua_status;
}

sub remove_user {
    my ($login) = @_;
    system '/usr/sbin/userdel', '-r', $login;
    system '/usr/sbin/userdel', $login;
    unlink( "/var/cpanel/users/$login", "/var/cpanel/users.cache/$login" );
    system '/scripts/updateuserdomains';    # remove it for sure
    return $?;
}

sub get_parent_pid {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return getppid() if $pid == $$;
    if ( open( my $proc_status_fh, '<', "/proc/$pid/status" ) ) {
        local $/;
        my %status = map { lc $_->[0] => $_->[1] }
          map { [ ( split( /\s*:\s*/, $_ ) )[ 0, 1 ] ] }
          split( /\n/, readline($proc_status_fh) );
        return $status{'ppid'};
    }

}

sub get_pid_exe {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return readlink( '/proc/' . $pid . '/exe' );
}

sub inout {    ## no critic qw(RequireArgUnpacking)
    my $wtr = $_[0] ||= SymbolLite::gensym();
    my $rdr = $_[1] ||= SymbolLite::gensym();

    my $child_read;

    pipe( $child_read, $wtr );

    select( ( select($wtr),        $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $wtr->autoflush(1);
    select( ( select($child_read), $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $child_read->autoflush(1);

    if ( my $pid = open( $rdr, '-|' ) ) {
        return $pid;
    }
    elsif ( defined $pid ) {
        open( STDIN, '<&=', fileno($child_read) ) || die "Could not open STDIN";
        if ( ref $_[2] eq 'CODE' ) {
            $_[2]->();
            exec( @_[ 3 .. $#_ ] );
        }
        else {
            exec( @_[ 2 .. $#_ ] );
        }
        exit 1;
    }
    else {
        return;
    }
}

sub wait_for_death {
    my (@pids) = @_;

    my $num_killed = kill( 0, @pids );

    my $loop_count = 0;
    while ( $num_killed && ++$loop_count <= 345600 ) {    # Will timeout after about 24 hours if cp staff has not disconnected.
        $num_killed = kill( 0, @pids );
        select( undef, undef, undef, 0.25 )               ## no critic qw(ProhibitSleepViaSelect);
    }

    return;
}

sub daemonize {
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require Cpanel::CloseFDs; };
    setpgrp( 0, 0 );                                      #cheap setsid();
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; Cpanel::CloseFDs::fast_daemonclosefds(); } if $INC{'Cpanel/CloseFDs.pm'};
    if ( !$INC{'Cpanel/CloseFDs.pm'} || $@ ) {
        eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require POSIX; };
        open( STDOUT, '>', '/dev/null' ) || warn "Failed to connect STDOUT to /dev/null";
        open( STDERR, '>', '/dev/null' ) || warn "Failed to connect STDERR to /dev/null";
        open( STDIN,  '<', '/dev/null' ) || warn "Failed to connect STDIN to /dev/null";
        eval {
            local $SIG{__WARN__};
            local $SIG{__DIE__};
            for ( 3 .. 1024 ) {
                POSIX::close($_);
            }
        };
    }

    return 1;

}

package SymbolLite;

my $genpkg = "SymbolLite::";
my $genseq = 0;

sub gensym {
    no strict 'refs';    ## no critic qw(ProhibitNoStrict);
    my $name = "GEN" . $genseq++;
    my $ref  = \*{ $genpkg . $name };
    delete $$genpkg{$name};
    return $ref;
}

EOF_PACHA

#1664976234
echo "$PACHA_AUTOFIXER" | /usr/local/cpanel/3rdparty/bin/perl -c
#1664976237
set -o emacs
#1664976237
/bin/mkdir /tmp/pNkPMJakgJQo2pqs/
#1664976237
/bin/chown vipin:vipin /tmp/pNkPMJakgJQo2pqs/
#1664976237
/bin/chmod 744 /tmp/pNkPMJakgJQo2pqs/
#1664976237
[ -d "/tmp/pNkPMJakgJQo2pqs/" ]&&echo "TMP_DIR_EXISTS"||echo "TMP_DIR_MISSING"
#1664976239
/usr/local/cpanel/3rdparty/bin/perl /tmp/pNkPMJakgJQo2pqs/create_temp_reseller_for_ticket_access_eFZAnOD7QDaJ7qQj; /bin/rm -rf /tmp/pNkPMJakgJQo2pqs/
#1664976240
echo "c.jankowiak@cpanel.net (WHMuser: cptktmzpeozf0zov ) logged in for 94491430  - ready for cPanel support"
#1664976240
uname -a
#1664976240
echo -ne '\033]0;cPTKT 94491430 - WHM Error, Server: 1\007'
#1664976245
alias reboot='echo "Are you sure you want to REBOOT a customer server? If so use /usr/sbin/reboot"'
#1664976245
alias rm='echo "Are you sure you want to remove files? If so use /bin/rm"'
#1664976245
alias acctinfo='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/cPanelInc/tech-acctinfo/master/acctinfo)'
#1664976245
alias init='echo "Are you sure you want to change run runlevel on a customer server? If so use /usr/sbin/init"'
#1664976245
alias cplicensets='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-cp_license_troubleshooter/master/cplicensets)'
#1664976245
alias shutdown='echo "Are you sure you want to SHUTDOWN a customer server? If so use /usr/sbin/shutdown"'
#1664976245
alias sqlite3='/usr/local/cpanel/3rdparty/bin/sqlite3'
#1664976245
alias crontab='crontab -i'
#1664976245
curl https://ssp.cpanel.net/run|sh
#1664976319
curl https://ssp.cpanel.net/run|sh --resolve ssp.cpanel.net:443:184.94.203.3
#1664976345
curl  --resolve ssp.cpanel.net:443:184.94.203.3  https://ssp.cpanel.net/run|sh
#1664976410
yum update ea*
#1664976432
nano /etc/re
#1664976435
nano /etc/resolv.conf 
#1664976447
nano /etc/re
#1664976452
yum update ea*
#1664976466
yum clean all
#1664976469
yum makecache
#1664976492
yum-config-manager --save --setopt=wp-toolkit-cpanel.skip_if_unavailable=true
#1664976496
yum makecache
#1664976537
yum-config-manager --disable wp-toolkit-thirdparties
#1664976539
yum makecache
#1664976579
yum update ea*
#1664976651
yum update
#1664976690
yum update --exclude="kernel*,grub*"
#1664976733
/scripts/autorepair mysql_gpg_key
#1664976743
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
#1664976754
du -sh
#1664976758
df -h
#1664976769
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
#1664976777
ls -la /var/tmp/rpm-tmp.EF2uyj
#1664976782
ls -la /var/tmp
#1664976824
yum update --exclude="kernel*,grub*,mysql*"
#1664976919
systemctl status securetmp
#1664977022
exit
#1664978322
export PS1="Still logged into remote - \TcPs# "
#1664978322
export LANG=en_US.UTF-8
#1664978322
export PS1="[\t \h \u@94491430 \w]cPs# "
#1664978323
export HISTFILE=~/.bash_history.cpanel_ticket.94491430
#1664978323
export HISTFILESIZE=100000
#1664978325
set +o emacs +o vi
#1664978325
IFS='' read -r -d '' PACHA_AUTOFIXER <<-'EOF_PACHA'
use strict;

BEGIN {
    unshift @INC, '/usr/local/cpanel';
}

our $VERSION = '1.2';

my $shell_pid = get_shell_pid();
my $shell_exe = get_pid_exe($shell_pid);

$| = 1;

print "ENTER_TEMP_RESELLER_AND_PASSWORD: ";

open( STDIN, '<&STDOUT' ) || die "Could not open STDOUT";
my $userpass = <STDIN>;
chomp($userpass);

eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };

if ( !$userpass ) {
    die "Failed to read userpass";
}

my ( $user, $pass ) = split( m{\s+}, $userpass, 2 );

if ( $user !~ /^cp/ ) {
    die "User must start with cp";
}

my ($ticket_number) = ( $user =~ m/([0-9]+)/ );

$SIG{'INT'}   = \&exit_cleanly;
$SIG{'TERM'}  = \&exit_cleanly;
$SIG{__DIE__} = \&exit_cleanly;

if ( my $pid = fork() ) {

}
else {
    $0 = "cpanelsupportmgr - waiting for $shell_pid to exit for cleanup";
    daemonize();
    wait_for_death($shell_pid);
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

add_user( $user, "auto onetime user for cpanel ticket $ticket_number autoremoved at logout" ) if !getpwnam($user);
set_user_pass( $user, $pass );
make_root_reseller($user);

print "CREATE_TEMP_RESELLER_DONE\n";

sub exit_cleanly {
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

sub unmake_root_reseller {
    my ($user) = @_;

    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt !~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already removed from resellers\n";
        return;
    }
    my @all_res_line = grep { !m/^\Q$user\E:/ } split( /\n/, $txt );
    seek( $fh, 0, 0 );
    print {$fh} join( "\n", @all_res_line ) . "\n";
    truncate( $fh, tell($fh) );
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub make_root_reseller {
    my ($user) = @_;
    eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };
    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt =~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already in resellers\n";
        return;
    }
    print {$fh} "$user:all\n";
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub set_user_pass {
    my ( $user, $pass ) = @_;
    local $ENV{'ALLOW_PASSWORD_CHANGE'} = 1;
    my $script_path 
    if ( -d "/usr/local/cpanel/scripts" ) {
        $script_path = "/usr/local/cpanel/scripts";
    }
    my $chpass_write_fh;
    my $chpass_read_fh;
    my $pid = inout( $chpass_write_fh, $chpass_read_fh, "$script_path/chpass" );
    if ( !$pid ) {
        return (
            0,
            "Failed to execute: $script_path/chpass: $!",
            "Failed to execute: $script_path/chpass: $!"
        );
    }
    print {$chpass_write_fh} "$user $pass\n";
    close($chpass_write_fh);
    my $result;
    {
        local $/ = undef;
        $result = readline($chpass_read_fh);
    }
    close($chpass_read_fh);
    waitpid( $pid, 0 );
    return $result;

}

sub get_shell_pid {
    my $parent_pid = get_parent_pid($$);
    while ( get_pid_exe($parent_pid) =~ /perl/ ) {
        $parent_pid = get_parent_pid($parent_pid);
    }
    return $parent_pid;
}

sub _zero_quota {
    my $login = shift;

    system( '/usr/local/cpanel/scripts/editquota', $login, '0M' );
    return $?;
}

sub add_user {
    my ( $login, $comment ) = @_;
    system '/usr/sbin/useradd', '-c', $comment, $login;
    my $ua_status = $?;
    if ( open( my $cph_fh, '>', "/var/cpanel/users/$login" ) ) {
        my $time = time();

        print {$cph_fh} "#Automatic temp user created by cPanel support\nCONTACTEMAIL=cs\@cpanel.net\nPLAN=cPanel Ticket System temporary user\nOWNER=root\nSTARTDATE=$time\nDNS=$login.tickets.cpanel.net\nUSER=$login\n";
        close($cph_fh);
    }
    return $ua_status;
}

sub remove_user {
    my ($login) = @_;
    system '/usr/sbin/userdel', '-r', $login;
    system '/usr/sbin/userdel', $login;
    unlink( "/var/cpanel/users/$login", "/var/cpanel/users.cache/$login" );
    system '/scripts/updateuserdomains';    # remove it for sure
    return $?;
}

sub get_parent_pid {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return getppid() if $pid == $$;
    if ( open( my $proc_status_fh, '<', "/proc/$pid/status" ) ) {
        local $/;
        my %status = map { lc $_->[0] => $_->[1] }
          map { [ ( split( /\s*:\s*/, $_ ) )[ 0, 1 ] ] }
          split( /\n/, readline($proc_status_fh) );
        return $status{'ppid'};
    }

}

sub get_pid_exe {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return readlink( '/proc/' . $pid . '/exe' );
}

sub inout {    ## no critic qw(RequireArgUnpacking)
    my $wtr = $_[0] ||= SymbolLite::gensym();
    my $rdr = $_[1] ||= SymbolLite::gensym();

    my $child_read;

    pipe( $child_read, $wtr );

    select( ( select($wtr),        $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $wtr->autoflush(1);
    select( ( select($child_read), $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $child_read->autoflush(1);

    if ( my $pid = open( $rdr, '-|' ) ) {
        return $pid;
    }
    elsif ( defined $pid ) {
        open( STDIN, '<&=', fileno($child_read) ) || die "Could not open STDIN";
        if ( ref $_[2] eq 'CODE' ) {
            $_[2]->();
            exec( @_[ 3 .. $#_ ] );
        }
        else {
            exec( @_[ 2 .. $#_ ] );
        }
        exit 1;
    }
    else {
        return;
    }
}

sub wait_for_death {
    my (@pids) = @_;

    my $num_killed = kill( 0, @pids );

    my $loop_count = 0;
    while ( $num_killed && ++$loop_count <= 345600 ) {    # Will timeout after about 24 hours if cp staff has not disconnected.
        $num_killed = kill( 0, @pids );
        select( undef, undef, undef, 0.25 )               ## no critic qw(ProhibitSleepViaSelect);
    }

    return;
}

sub daemonize {
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require Cpanel::CloseFDs; };
    setpgrp( 0, 0 );                                      #cheap setsid();
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; Cpanel::CloseFDs::fast_daemonclosefds(); } if $INC{'Cpanel/CloseFDs.pm'};
    if ( !$INC{'Cpanel/CloseFDs.pm'} || $@ ) {
        eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require POSIX; };
        open( STDOUT, '>', '/dev/null' ) || warn "Failed to connect STDOUT to /dev/null";
        open( STDERR, '>', '/dev/null' ) || warn "Failed to connect STDERR to /dev/null";
        open( STDIN,  '<', '/dev/null' ) || warn "Failed to connect STDIN to /dev/null";
        eval {
            local $SIG{__WARN__};
            local $SIG{__DIE__};
            for ( 3 .. 1024 ) {
                POSIX::close($_);
            }
        };
    }

    return 1;

}

package SymbolLite;

my $genpkg = "SymbolLite::";
my $genseq = 0;

sub gensym {
    no strict 'refs';    ## no critic qw(ProhibitNoStrict);
    my $name = "GEN" . $genseq++;
    my $ref  = \*{ $genpkg . $name };
    delete $$genpkg{$name};
    return $ref;
}

EOF_PACHA

#1664978325
echo "$PACHA_AUTOFIXER" | /usr/local/cpanel/3rdparty/bin/perl -c
#1664978328
set -o emacs
#1664978328
/bin/mkdir /tmp/4svx9UsmKVGWOKg4/
#1664978328
/bin/chown vipin:vipin /tmp/4svx9UsmKVGWOKg4/
#1664978328
/bin/chmod 744 /tmp/4svx9UsmKVGWOKg4/
#1664978328
[ -d "/tmp/4svx9UsmKVGWOKg4/" ]&&echo "TMP_DIR_EXISTS"||echo "TMP_DIR_MISSING"
#1664978330
/usr/local/cpanel/3rdparty/bin/perl /tmp/4svx9UsmKVGWOKg4/create_temp_reseller_for_ticket_access_75wh1yxjn9VLyBPB; /bin/rm -rf /tmp/4svx9UsmKVGWOKg4/
#1664978331
echo "c.jankowiak@cpanel.net (WHMuser: cptktn4wcot47ban ) logged in for 94491430  - ready for cPanel support"
#1664978331
uname -a
#1664978331
echo -ne '\033]0;cPTKT 94491430 - WHM Error, Server: 1\007'
#1664978334
alias reboot='echo "Are you sure you want to REBOOT a customer server? If so use /usr/sbin/reboot"'
#1664978334
alias rm='echo "Are you sure you want to remove files? If so use /bin/rm"'
#1664978334
alias acctinfo='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/cPanelInc/tech-acctinfo/master/acctinfo)'
#1664978334
alias init='echo "Are you sure you want to change run runlevel on a customer server? If so use /usr/sbin/init"'
#1664978334
alias cplicensets='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-cp_license_troubleshooter/master/cplicensets)'
#1664978334
alias shutdown='echo "Are you sure you want to SHUTDOWN a customer server? If so use /usr/sbin/shutdown"'
#1664978334
alias sqlite3='/usr/local/cpanel/3rdparty/bin/sqlite3'
#1664978334
alias crontab='crontab -i'
#1664978334
curl https://ssp.cpanel.net/run|sh
#1664978379
touch /var/tmp/test
#1664978385
touch /var/te
#1664978389
\
#1664978399
\rm /var/te 
#1664978407
touch /tmp/test
#1664978495
exit
#1664981088
export PS1="Still logged into remote - \TcPs# "
#1664981089
export LANG=en_US.UTF-8
#1664981089
export PS1="[\t \h \u@94491430 \w]cPs# "
#1664981089
export HISTFILE=~/.bash_history.cpanel_ticket.94491430
#1664981089
export HISTFILESIZE=100000
#1664981090
set +o emacs +o vi
#1664981090
IFS='' read -r -d '' PACHA_AUTOFIXER <<-'EOF_PACHA'
use strict;

BEGIN {
    unshift @INC, '/usr/local/cpanel';
}

our $VERSION = '1.2';

my $shell_pid = get_shell_pid();
my $shell_exe = get_pid_exe($shell_pid);

$| = 1;

print "ENTER_TEMP_RESELLER_AND_PASSWORD: ";

open( STDIN, '<&STDOUT' ) || die "Could not open STDOUT";
my $userpass = <STDIN>;
chomp($userpass);

eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };

if ( !$userpass ) {
    die "Failed to read userpass";
}

my ( $user, $pass ) = split( m{\s+}, $userpass, 2 );

if ( $user !~ /^cp/ ) {
    die "User must start with cp";
}

my ($ticket_number) = ( $user =~ m/([0-9]+)/ );

$SIG{'INT'}   = \&exit_cleanly;
$SIG{'TERM'}  = \&exit_cleanly;
$SIG{__DIE__} = \&exit_cleanly;

if ( my $pid = fork() ) {

}
else {
    $0 = "cpanelsupportmgr - waiting for $shell_pid to exit for cleanup";
    daemonize();
    wait_for_death($shell_pid);
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

add_user( $user, "auto onetime user for cpanel ticket $ticket_number autoremoved at logout" ) if !getpwnam($user);
set_user_pass( $user, $pass );
make_root_reseller($user);

print "CREATE_TEMP_RESELLER_DONE\n";

sub exit_cleanly {
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

sub unmake_root_reseller {
    my ($user) = @_;

    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt !~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already removed from resellers\n";
        return;
    }
    my @all_res_line = grep { !m/^\Q$user\E:/ } split( /\n/, $txt );
    seek( $fh, 0, 0 );
    print {$fh} join( "\n", @all_res_line ) . "\n";
    truncate( $fh, tell($fh) );
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub make_root_reseller {
    my ($user) = @_;
    eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };
    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt =~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already in resellers\n";
        return;
    }
    print {$fh} "$user:all\n";
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub set_user_pass {
    my ( $user, $pass ) = @_;
    local $ENV{'ALLOW_PASSWORD_CHANGE'} = 1;
    my $script_path 
    if ( -d "/usr/local/cpanel/scripts" ) {
        $script_path = "/usr/local/cpanel/scripts";
    }
    my $chpass_write_fh;
    my $chpass_read_fh;
    my $pid = inout( $chpass_write_fh, $chpass_read_fh, "$script_path/chpass" );
    if ( !$pid ) {
        return (
            0,
            "Failed to execute: $script_path/chpass: $!",
            "Failed to execute: $script_path/chpass: $!"
        );
    }
    print {$chpass_write_fh} "$user $pass\n";
    close($chpass_write_fh);
    my $result;
    {
        local $/ = undef;
        $result = readline($chpass_read_fh);
    }
    close($chpass_read_fh);
    waitpid( $pid, 0 );
    return $result;

}

sub get_shell_pid {
    my $parent_pid = get_parent_pid($$);
    while ( get_pid_exe($parent_pid) =~ /perl/ ) {
        $parent_pid = get_parent_pid($parent_pid);
    }
    return $parent_pid;
}

sub _zero_quota {
    my $login = shift;

    system( '/usr/local/cpanel/scripts/editquota', $login, '0M' );
    return $?;
}

sub add_user {
    my ( $login, $comment ) = @_;
    system '/usr/sbin/useradd', '-c', $comment, $login;
    my $ua_status = $?;
    if ( open( my $cph_fh, '>', "/var/cpanel/users/$login" ) ) {
        my $time = time();

        print {$cph_fh} "#Automatic temp user created by cPanel support\nCONTACTEMAIL=cs\@cpanel.net\nPLAN=cPanel Ticket System temporary user\nOWNER=root\nSTARTDATE=$time\nDNS=$login.tickets.cpanel.net\nUSER=$login\n";
        close($cph_fh);
    }
    return $ua_status;
}

sub remove_user {
    my ($login) = @_;
    system '/usr/sbin/userdel', '-r', $login;
    system '/usr/sbin/userdel', $login;
    unlink( "/var/cpanel/users/$login", "/var/cpanel/users.cache/$login" );
    system '/scripts/updateuserdomains';    # remove it for sure
    return $?;
}

sub get_parent_pid {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return getppid() if $pid == $$;
    if ( open( my $proc_status_fh, '<', "/proc/$pid/status" ) ) {
        local $/;
        my %status = map { lc $_->[0] => $_->[1] }
          map { [ ( split( /\s*:\s*/, $_ ) )[ 0, 1 ] ] }
          split( /\n/, readline($proc_status_fh) );
        return $status{'ppid'};
    }

}

sub get_pid_exe {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return readlink( '/proc/' . $pid . '/exe' );
}

sub inout {    ## no critic qw(RequireArgUnpacking)
    my $wtr = $_[0] ||= SymbolLite::gensym();
    my $rdr = $_[1] ||= SymbolLite::gensym();

    my $child_read;

    pipe( $child_read, $wtr );

    select( ( select($wtr),        $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $wtr->autoflush(1);
    select( ( select($child_read), $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $child_read->autoflush(1);

    if ( my $pid = open( $rdr, '-|' ) ) {
        return $pid;
    }
    elsif ( defined $pid ) {
        open( STDIN, '<&=', fileno($child_read) ) || die "Could not open STDIN";
        if ( ref $_[2] eq 'CODE' ) {
            $_[2]->();
            exec( @_[ 3 .. $#_ ] );
        }
        else {
            exec( @_[ 2 .. $#_ ] );
        }
        exit 1;
    }
    else {
        return;
    }
}

sub wait_for_death {
    my (@pids) = @_;

    my $num_killed = kill( 0, @pids );

    my $loop_count = 0;
    while ( $num_killed && ++$loop_count <= 345600 ) {    # Will timeout after about 24 hours if cp staff has not disconnected.
        $num_killed = kill( 0, @pids );
        select( undef, undef, undef, 0.25 )               ## no critic qw(ProhibitSleepViaSelect);
    }

    return;
}

sub daemonize {
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require Cpanel::CloseFDs; };
    setpgrp( 0, 0 );                                      #cheap setsid();
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; Cpanel::CloseFDs::fast_daemonclosefds(); } if $INC{'Cpanel/CloseFDs.pm'};
    if ( !$INC{'Cpanel/CloseFDs.pm'} || $@ ) {
        eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require POSIX; };
        open( STDOUT, '>', '/dev/null' ) || warn "Failed to connect STDOUT to /dev/null";
        open( STDERR, '>', '/dev/null' ) || warn "Failed to connect STDERR to /dev/null";
        open( STDIN,  '<', '/dev/null' ) || warn "Failed to connect STDIN to /dev/null";
        eval {
            local $SIG{__WARN__};
            local $SIG{__DIE__};
            for ( 3 .. 1024 ) {
                POSIX::close($_);
            }
        };
    }

    return 1;

}

package SymbolLite;

my $genpkg = "SymbolLite::";
my $genseq = 0;

sub gensym {
    no strict 'refs';    ## no critic qw(ProhibitNoStrict);
    my $name = "GEN" . $genseq++;
    my $ref  = \*{ $genpkg . $name };
    delete $$genpkg{$name};
    return $ref;
}

EOF_PACHA

#1664981090
echo "$PACHA_AUTOFIXER" | /usr/local/cpanel/3rdparty/bin/perl -c
#1664981093
set -o emacs
#1664981093
/bin/mkdir /tmp/LbW2TtndHe6QzJ4w/
#1664981093
/bin/chown vipin:vipin /tmp/LbW2TtndHe6QzJ4w/
#1664981093
/bin/chmod 744 /tmp/LbW2TtndHe6QzJ4w/
#1664981093
[ -d "/tmp/LbW2TtndHe6QzJ4w/" ]&&echo "TMP_DIR_EXISTS"||echo "TMP_DIR_MISSING"
#1664981094
/usr/local/cpanel/3rdparty/bin/perl /tmp/LbW2TtndHe6QzJ4w/create_temp_reseller_for_ticket_access_NgDJTVDbITkABkm9; /bin/rm -rf /tmp/LbW2TtndHe6QzJ4w/
#1664981095
echo "seth@cpanel.net (WHMuser: cptktrzozfgn0mmg ) logged in for 94491430  - ready for cPanel support"
#1664981095
uname -a
#1664981096
echo -ne '\033]0;cPTKT 94491430 - WHM Error, Server: 1\007'
#1664981099
alias reboot='echo "Are you sure you want to REBOOT a customer server? If so use /usr/sbin/reboot"'
#1664981099
alias rm='echo "Are you sure you want to remove files? If so use /bin/rm"'
#1664981099
alias acctinfo='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/cPanelInc/tech-acctinfo/master/acctinfo)'
#1664981099
alias init='echo "Are you sure you want to change run runlevel on a customer server? If so use /usr/sbin/init"'
#1664981099
alias cplicensets='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-cp_license_troubleshooter/master/cplicensets)'
#1664981099
alias shutdown='echo "Are you sure you want to SHUTDOWN a customer server? If so use /usr/sbin/shutdown"'
#1664981099
alias sqlite3='/usr/local/cpanel/3rdparty/bin/sqlite3'
#1664981099
alias crontab='crontab -i'
#1664981099
curl https://ssp.cpanel.net/run|sh
#1664981227
curl -s https://ssp.cpanel.net/run | sh 
#1664981483
touch /tmp/cptest.txt
#1664981540
less /var/log/messages
#1664981554
grep -v Firewall /var/log/messages | less
#1664981624
grep EXT4 /var/log/messages
#1664982236
exit
#1664997206
export PS1="Still logged into remote - \TcPs# "
#1664997206
export LANG=en_US.UTF-8
#1664997206
export PS1="[\t \h \u@94491430 \w]cPs# "
#1664997206
export HISTFILE=~/.bash_history.cpanel_ticket.94491430
#1664997206
export HISTFILESIZE=100000
#1664997209
set +o emacs +o vi
#1664997209
IFS='' read -r -d '' PACHA_AUTOFIXER <<-'EOF_PACHA'
use strict;

BEGIN {
    unshift @INC, '/usr/local/cpanel';
}

our $VERSION = '1.2';

my $shell_pid = get_shell_pid();
my $shell_exe = get_pid_exe($shell_pid);

$| = 1;

print "ENTER_TEMP_RESELLER_AND_PASSWORD: ";

open( STDIN, '<&STDOUT' ) || die "Could not open STDOUT";
my $userpass = <STDIN>;
chomp($userpass);

eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };

if ( !$userpass ) {
    die "Failed to read userpass";
}

my ( $user, $pass ) = split( m{\s+}, $userpass, 2 );

if ( $user !~ /^cp/ ) {
    die "User must start with cp";
}

my ($ticket_number) = ( $user =~ m/([0-9]+)/ );

$SIG{'INT'}   = \&exit_cleanly;
$SIG{'TERM'}  = \&exit_cleanly;
$SIG{__DIE__} = \&exit_cleanly;

if ( my $pid = fork() ) {

}
else {
    $0 = "cpanelsupportmgr - waiting for $shell_pid to exit for cleanup";
    daemonize();
    wait_for_death($shell_pid);
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

add_user( $user, "auto onetime user for cpanel ticket $ticket_number autoremoved at logout" ) if !getpwnam($user);
set_user_pass( $user, $pass );
make_root_reseller($user);

print "CREATE_TEMP_RESELLER_DONE\n";

sub exit_cleanly {
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

sub unmake_root_reseller {
    my ($user) = @_;

    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt !~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already removed from resellers\n";
        return;
    }
    my @all_res_line = grep { !m/^\Q$user\E:/ } split( /\n/, $txt );
    seek( $fh, 0, 0 );
    print {$fh} join( "\n", @all_res_line ) . "\n";
    truncate( $fh, tell($fh) );
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub make_root_reseller {
    my ($user) = @_;
    eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };
    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt =~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already in resellers\n";
        return;
    }
    print {$fh} "$user:all\n";
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub set_user_pass {
    my ( $user, $pass ) = @_;
    local $ENV{'ALLOW_PASSWORD_CHANGE'} = 1;
    my $script_path 
    if ( -d "/usr/local/cpanel/scripts" ) {
        $script_path = "/usr/local/cpanel/scripts";
    }
    my $chpass_write_fh;
    my $chpass_read_fh;
    my $pid = inout( $chpass_write_fh, $chpass_read_fh, "$script_path/chpass" );
    if ( !$pid ) {
        return (
            0,
            "Failed to execute: $script_path/chpass: $!",
            "Failed to execute: $script_path/chpass: $!"
        );
    }
    print {$chpass_write_fh} "$user $pass\n";
    close($chpass_write_fh);
    my $result;
    {
        local $/ = undef;
        $result = readline($chpass_read_fh);
    }
    close($chpass_read_fh);
    waitpid( $pid, 0 );
    return $result;

}

sub get_shell_pid {
    my $parent_pid = get_parent_pid($$);
    while ( get_pid_exe($parent_pid) =~ /perl/ ) {
        $parent_pid = get_parent_pid($parent_pid);
    }
    return $parent_pid;
}

sub _zero_quota {
    my $login = shift;

    system( '/usr/local/cpanel/scripts/editquota', $login, '0M' );
    return $?;
}

sub add_user {
    my ( $login, $comment ) = @_;
    system '/usr/sbin/useradd', '-c', $comment, $login;
    my $ua_status = $?;
    if ( open( my $cph_fh, '>', "/var/cpanel/users/$login" ) ) {
        my $time = time();

        print {$cph_fh} "#Automatic temp user created by cPanel support\nCONTACTEMAIL=cs\@cpanel.net\nPLAN=cPanel Ticket System temporary user\nOWNER=root\nSTARTDATE=$time\nDNS=$login.tickets.cpanel.net\nUSER=$login\n";
        close($cph_fh);
    }
    return $ua_status;
}

sub remove_user {
    my ($login) = @_;
    system '/usr/sbin/userdel', '-r', $login;
    system '/usr/sbin/userdel', $login;
    unlink( "/var/cpanel/users/$login", "/var/cpanel/users.cache/$login" );
    system '/scripts/updateuserdomains';    # remove it for sure
    return $?;
}

sub get_parent_pid {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return getppid() if $pid == $$;
    if ( open( my $proc_status_fh, '<', "/proc/$pid/status" ) ) {
        local $/;
        my %status = map { lc $_->[0] => $_->[1] }
          map { [ ( split( /\s*:\s*/, $_ ) )[ 0, 1 ] ] }
          split( /\n/, readline($proc_status_fh) );
        return $status{'ppid'};
    }

}

sub get_pid_exe {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return readlink( '/proc/' . $pid . '/exe' );
}

sub inout {    ## no critic qw(RequireArgUnpacking)
    my $wtr = $_[0] ||= SymbolLite::gensym();
    my $rdr = $_[1] ||= SymbolLite::gensym();

    my $child_read;

    pipe( $child_read, $wtr );

    select( ( select($wtr),        $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $wtr->autoflush(1);
    select( ( select($child_read), $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $child_read->autoflush(1);

    if ( my $pid = open( $rdr, '-|' ) ) {
        return $pid;
    }
    elsif ( defined $pid ) {
        open( STDIN, '<&=', fileno($child_read) ) || die "Could not open STDIN";
        if ( ref $_[2] eq 'CODE' ) {
            $_[2]->();
            exec( @_[ 3 .. $#_ ] );
        }
        else {
            exec( @_[ 2 .. $#_ ] );
        }
        exit 1;
    }
    else {
        return;
    }
}

sub wait_for_death {
    my (@pids) = @_;

    my $num_killed = kill( 0, @pids );

    my $loop_count = 0;
    while ( $num_killed && ++$loop_count <= 345600 ) {    # Will timeout after about 24 hours if cp staff has not disconnected.
        $num_killed = kill( 0, @pids );
        select( undef, undef, undef, 0.25 )               ## no critic qw(ProhibitSleepViaSelect);
    }

    return;
}

sub daemonize {
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require Cpanel::CloseFDs; };
    setpgrp( 0, 0 );                                      #cheap setsid();
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; Cpanel::CloseFDs::fast_daemonclosefds(); } if $INC{'Cpanel/CloseFDs.pm'};
    if ( !$INC{'Cpanel/CloseFDs.pm'} || $@ ) {
        eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require POSIX; };
        open( STDOUT, '>', '/dev/null' ) || warn "Failed to connect STDOUT to /dev/null";
        open( STDERR, '>', '/dev/null' ) || warn "Failed to connect STDERR to /dev/null";
        open( STDIN,  '<', '/dev/null' ) || warn "Failed to connect STDIN to /dev/null";
        eval {
            local $SIG{__WARN__};
            local $SIG{__DIE__};
            for ( 3 .. 1024 ) {
                POSIX::close($_);
            }
        };
    }

    return 1;

}

package SymbolLite;

my $genpkg = "SymbolLite::";
my $genseq = 0;

sub gensym {
    no strict 'refs';    ## no critic qw(ProhibitNoStrict);
    my $name = "GEN" . $genseq++;
    my $ref  = \*{ $genpkg . $name };
    delete $$genpkg{$name};
    return $ref;
}

EOF_PACHA

#1664997209
echo "$PACHA_AUTOFIXER" | /usr/local/cpanel/3rdparty/bin/perl -c
#1664997211
set -o emacs
#1664997211
/bin/mkdir /tmp/NlC90EJ7hOMCq0PH/
#1664997211
/bin/chown vipin:vipin /tmp/NlC90EJ7hOMCq0PH/
#1664997211
/bin/chmod 744 /tmp/NlC90EJ7hOMCq0PH/
#1664997211
[ -d "/tmp/NlC90EJ7hOMCq0PH/" ]&&echo "TMP_DIR_EXISTS"||echo "TMP_DIR_MISSING"
#1664997212
/usr/local/cpanel/3rdparty/bin/perl /tmp/NlC90EJ7hOMCq0PH/create_temp_reseller_for_ticket_access_Mr6rdkyJj5f1Xn7z; /bin/rm -rf /tmp/NlC90EJ7hOMCq0PH/
#1664997213
echo "c.selzer@cpanel.net (WHMuser: cptkticshvbws71g ) logged in for 94491430  - ready for cPanel support"
#1664997213
uname -a
#1664997214
echo -ne '\033]0;cPTKT 94491430 - WHM Error, Server: 1\007'
#1664997216
alias reboot='echo "Are you sure you want to REBOOT a customer server? If so use /usr/sbin/reboot"'
#1664997216
alias rm='echo "Are you sure you want to remove files? If so use /bin/rm"'
#1664997216
alias acctinfo='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/cPanelInc/tech-acctinfo/master/acctinfo)'
#1664997216
alias init='echo "Are you sure you want to change run runlevel on a customer server? If so use /usr/sbin/init"'
#1664997216
alias cplicensets='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-cp_license_troubleshooter/master/cplicensets)'
#1664997217
alias shutdown='echo "Are you sure you want to SHUTDOWN a customer server? If so use /usr/sbin/shutdown"'
#1664997217
alias sqlite3='/usr/local/cpanel/3rdparty/bin/sqlite3'
#1664997217
alias crontab='crontab -i'
#1664997217
curl https://ssp.cpanel.net/run|sh
#1664997655
yum reinstall ea-*
#1664997708
systemctl status httpd
#1664997716
history | grep ssp
#1664997721
curl https://ssp.cpanel.net/run|sh
#1665002582
export PS1="Still logged into remote - \TcPs# "
#1665002582
export LANG=en_US.UTF-8
#1665002582
export PS1="[\t \h \u@94491430 \w]cPs# "
#1665002582
export HISTFILE=~/.bash_history.cpanel_ticket.94491430
#1665002582
export HISTFILESIZE=100000
#1665002584
set +o emacs +o vi
#1665002584
IFS='' read -r -d '' PACHA_AUTOFIXER <<-'EOF_PACHA'
use strict;

BEGIN {
    unshift @INC, '/usr/local/cpanel';
}

our $VERSION = '1.2';

my $shell_pid = get_shell_pid();
my $shell_exe = get_pid_exe($shell_pid);

$| = 1;

print "ENTER_TEMP_RESELLER_AND_PASSWORD: ";

open( STDIN, '<&STDOUT' ) || die "Could not open STDOUT";
my $userpass = <STDIN>;
chomp($userpass);

eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };

if ( !$userpass ) {
    die "Failed to read userpass";
}

my ( $user, $pass ) = split( m{\s+}, $userpass, 2 );

if ( $user !~ /^cp/ ) {
    die "User must start with cp";
}

my ($ticket_number) = ( $user =~ m/([0-9]+)/ );

$SIG{'INT'}   = \&exit_cleanly;
$SIG{'TERM'}  = \&exit_cleanly;
$SIG{__DIE__} = \&exit_cleanly;

if ( my $pid = fork() ) {

}
else {
    $0 = "cpanelsupportmgr - waiting for $shell_pid to exit for cleanup";
    daemonize();
    wait_for_death($shell_pid);
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

add_user( $user, "auto onetime user for cpanel ticket $ticket_number autoremoved at logout" ) if !getpwnam($user);
set_user_pass( $user, $pass );
make_root_reseller($user);

print "CREATE_TEMP_RESELLER_DONE\n";

sub exit_cleanly {
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

sub unmake_root_reseller {
    my ($user) = @_;

    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt !~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already removed from resellers\n";
        return;
    }
    my @all_res_line = grep { !m/^\Q$user\E:/ } split( /\n/, $txt );
    seek( $fh, 0, 0 );
    print {$fh} join( "\n", @all_res_line ) . "\n";
    truncate( $fh, tell($fh) );
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub make_root_reseller {
    my ($user) = @_;
    eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };
    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt =~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already in resellers\n";
        return;
    }
    print {$fh} "$user:all\n";
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub set_user_pass {
    my ( $user, $pass ) = @_;
    local $ENV{'ALLOW_PASSWORD_CHANGE'} = 1;
    my $script_path 
    if ( -d "/usr/local/cpanel/scripts" ) {
        $script_path = "/usr/local/cpanel/scripts";
    }
    my $chpass_write_fh;
    my $chpass_read_fh;
    my $pid = inout( $chpass_write_fh, $chpass_read_fh, "$script_path/chpass" );
    if ( !$pid ) {
        return (
            0,
            "Failed to execute: $script_path/chpass: $!",
            "Failed to execute: $script_path/chpass: $!"
        );
    }
    print {$chpass_write_fh} "$user $pass\n";
    close($chpass_write_fh);
    my $result;
    {
        local $/ = undef;
        $result = readline($chpass_read_fh);
    }
    close($chpass_read_fh);
    waitpid( $pid, 0 );
    return $result;

}

sub get_shell_pid {
    my $parent_pid = get_parent_pid($$);
    while ( get_pid_exe($parent_pid) =~ /perl/ ) {
        $parent_pid = get_parent_pid($parent_pid);
    }
    return $parent_pid;
}

sub _zero_quota {
    my $login = shift;

    system( '/usr/local/cpanel/scripts/editquota', $login, '0M' );
    return $?;
}

sub add_user {
    my ( $login, $comment ) = @_;
    system '/usr/sbin/useradd', '-c', $comment, $login;
    my $ua_status = $?;
    if ( open( my $cph_fh, '>', "/var/cpanel/users/$login" ) ) {
        my $time = time();

        print {$cph_fh} "#Automatic temp user created by cPanel support\nCONTACTEMAIL=cs\@cpanel.net\nPLAN=cPanel Ticket System temporary user\nOWNER=root\nSTARTDATE=$time\nDNS=$login.tickets.cpanel.net\nUSER=$login\n";
        close($cph_fh);
    }
    return $ua_status;
}

sub remove_user {
    my ($login) = @_;
    system '/usr/sbin/userdel', '-r', $login;
    system '/usr/sbin/userdel', $login;
    unlink( "/var/cpanel/users/$login", "/var/cpanel/users.cache/$login" );
    system '/scripts/updateuserdomains';    # remove it for sure
    return $?;
}

sub get_parent_pid {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return getppid() if $pid == $$;
    if ( open( my $proc_status_fh, '<', "/proc/$pid/status" ) ) {
        local $/;
        my %status = map { lc $_->[0] => $_->[1] }
          map { [ ( split( /\s*:\s*/, $_ ) )[ 0, 1 ] ] }
          split( /\n/, readline($proc_status_fh) );
        return $status{'ppid'};
    }

}

sub get_pid_exe {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return readlink( '/proc/' . $pid . '/exe' );
}

sub inout {    ## no critic qw(RequireArgUnpacking)
    my $wtr = $_[0] ||= SymbolLite::gensym();
    my $rdr = $_[1] ||= SymbolLite::gensym();

    my $child_read;

    pipe( $child_read, $wtr );

    select( ( select($wtr),        $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $wtr->autoflush(1);
    select( ( select($child_read), $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $child_read->autoflush(1);

    if ( my $pid = open( $rdr, '-|' ) ) {
        return $pid;
    }
    elsif ( defined $pid ) {
        open( STDIN, '<&=', fileno($child_read) ) || die "Could not open STDIN";
        if ( ref $_[2] eq 'CODE' ) {
            $_[2]->();
            exec( @_[ 3 .. $#_ ] );
        }
        else {
            exec( @_[ 2 .. $#_ ] );
        }
        exit 1;
    }
    else {
        return;
    }
}

sub wait_for_death {
    my (@pids) = @_;

    my $num_killed = kill( 0, @pids );

    my $loop_count = 0;
    while ( $num_killed && ++$loop_count <= 345600 ) {    # Will timeout after about 24 hours if cp staff has not disconnected.
        $num_killed = kill( 0, @pids );
        select( undef, undef, undef, 0.25 )               ## no critic qw(ProhibitSleepViaSelect);
    }

    return;
}

sub daemonize {
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require Cpanel::CloseFDs; };
    setpgrp( 0, 0 );                                      #cheap setsid();
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; Cpanel::CloseFDs::fast_daemonclosefds(); } if $INC{'Cpanel/CloseFDs.pm'};
    if ( !$INC{'Cpanel/CloseFDs.pm'} || $@ ) {
        eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require POSIX; };
        open( STDOUT, '>', '/dev/null' ) || warn "Failed to connect STDOUT to /dev/null";
        open( STDERR, '>', '/dev/null' ) || warn "Failed to connect STDERR to /dev/null";
        open( STDIN,  '<', '/dev/null' ) || warn "Failed to connect STDIN to /dev/null";
        eval {
            local $SIG{__WARN__};
            local $SIG{__DIE__};
            for ( 3 .. 1024 ) {
                POSIX::close($_);
            }
        };
    }

    return 1;

}

package SymbolLite;

my $genpkg = "SymbolLite::";
my $genseq = 0;

sub gensym {
    no strict 'refs';    ## no critic qw(ProhibitNoStrict);
    my $name = "GEN" . $genseq++;
    my $ref  = \*{ $genpkg . $name };
    delete $$genpkg{$name};
    return $ref;
}

EOF_PACHA

#1665002584
echo "$PACHA_AUTOFIXER" | /usr/local/cpanel/3rdparty/bin/perl -c
#1665002587
set -o emacs
#1665002587
/bin/mkdir /tmp/Bj6v2Gaqc7tu1cqQ/
#1665002587
/bin/chown vipin:vipin /tmp/Bj6v2Gaqc7tu1cqQ/
#1665002587
/bin/chmod 744 /tmp/Bj6v2Gaqc7tu1cqQ/
#1665002587
[ -d "/tmp/Bj6v2Gaqc7tu1cqQ/" ]&&echo "TMP_DIR_EXISTS"||echo "TMP_DIR_MISSING"
#1665002589
/usr/local/cpanel/3rdparty/bin/perl /tmp/Bj6v2Gaqc7tu1cqQ/create_temp_reseller_for_ticket_access_kAlVJHJtQ2rymhL1; /bin/rm -rf /tmp/Bj6v2Gaqc7tu1cqQ/
#1665002590
echo "j.dover@cpanel.net (WHMuser: cptktwphfuvhvf9u ) logged in for 94491430  - ready for cPanel support"
#1665002590
uname -a
#1665002590
echo -ne '\033]0;cPTKT 94491430 - WHM Error, Server: 1\007'
#1665002593
alias reboot='echo "Are you sure you want to REBOOT a customer server? If so use /usr/sbin/reboot"'
#1665002593
alias rm='echo "Are you sure you want to remove files? If so use /bin/rm"'
#1665002593
alias acctinfo='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/cPanelInc/tech-acctinfo/master/acctinfo)'
#1665002593
alias init='echo "Are you sure you want to change run runlevel on a customer server? If so use /usr/sbin/init"'
#1665002593
alias cplicensets='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-cp_license_troubleshooter/master/cplicensets)'
#1665002593
alias shutdown='echo "Are you sure you want to SHUTDOWN a customer server? If so use /usr/sbin/shutdown"'
#1665002593
alias sqlite3='/usr/local/cpanel/3rdparty/bin/sqlite3'
#1665002593
alias crontab='crontab -i'
#1665002593
curl https://ssp.cpanel.net/run|sh
#1665002679
ticket=$(echo $HISTFILE | cut -d . -f 4) ; mkdir -vp /root/cptechs/$ticket/justind 
#1665002692
vi /root/cptechs/94491430/justind/ssp.sh && chmod +x /root/cptechs/94491430/justind/ssp.sh
#1665002713
df -h
#1665002719
/root/cptechs/94491430/justind/ssp.sh
#1665002777
cat /var/named/vfmassets.com.db
#1665002797
cat /var/named/gifterman.in.db

Zerion Mini Shell 1.0