Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scp: downloads would sometimes stall (#486) #509

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading