Skip to content

Commit

Permalink
fix: scp: downloads would sometimes stall (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
speed47 committed Dec 10, 2024
1 parent 55f276e commit 62613bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions bin/plugin/open/scp
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ $fnret or osh_exit($fnret);

my $machine = $fnret->value->{'machine'};
my @keys = @{$fnret->value->{'keys'} || []};
# now build the command

# now build the command
my @cmd = qw{ ssh -x -oForwardAgent=no -oPermitLocalCommand=no -oClearAllForwardings=yes };
push @cmd, ('-p', $port) if $port;
push @cmd, ('-l', $user) if $user;
Expand All @@ -327,20 +327,18 @@ print STDERR ">>> Hello $self, transferring your file through the bastion "
. ($protocol eq 'scpupload' ? 'to' : 'from')
. " $machine...\n";

#print STDERR join('^', @cmd)."\n";
$fnret = OVH::Bastion::execute(cmd => \@cmd, expects_stdin => 1, is_binary => 1);
# Use system here and in plugin's json config to avoid buffering deadlock issues (#486)
$fnret = OVH::Bastion::execute(cmd => \@cmd, system => 1);
if ($fnret->err ne 'OK') {
osh_exit 'ERR_TRANSFER_FAILED', "Error launching transfer: $fnret";
}
print STDERR sprintf(
">>> Done, %d bytes uploaded, %d bytes downloaded\n",
$fnret->value->{'bytesnb'}{'stdin'} + 0,
$fnret->value->{'bytesnb'}{'stdout'} + 0
);

if ($fnret->value->{'sysret'} != 0) {
print STDERR ">>> On bastion side, scp exited with return code " . $fnret->value->{'sysret'} . ".\n";
}
else {
print STDERR ">>> Done, scp exited successfully.\n";
}

# don't use osh_exit() to avoid getting a footer
exit OVH::Bastion::EXIT_OK;
Expand Down
2 changes: 1 addition & 1 deletion bin/plugin/open/scp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"execution_mode": "binary",
"execution_mode": "system",
"stealth_stdout": true,
"jit_mfa": "token",
"jit_mfa_allow_no_host": true,
Expand Down

0 comments on commit 62613bf

Please sign in to comment.