mirror of
https://github.com/google/cdc-file-transfer.git
synced 2026-09-13 01:10:44 +03:00
[cdc_rsync] Use ephemeral port on client (#96)
Instead of calling netstat locally to find out available ports in a tight range, call bind() with port zero to find an available ephemeral port. This is faster and much simpler, and will eventually help getting rid of PortManager. Also fixes issues with running SSH commands on Windows when the remote shell is Powershell (aka Backslash Bingo).
This commit is contained in:
@@ -147,8 +147,7 @@ absl::StatusOr<ServerArch> ServerArch::DetectFromRemoteDevice(
|
||||
// Note: That space after PROCESSOR_ARCHITECTURE is important or else Windows
|
||||
// command magic interprets quotes as part of the string.
|
||||
std::string arch_out;
|
||||
std::string windows_cmd =
|
||||
RemoteUtil::QuoteForSsh("cmd /C set PROCESSOR_ARCHITECTURE ");
|
||||
std::string windows_cmd = "\"cmd /C set PROCESSOR_ARCHITECTURE \"";
|
||||
status = remote_util->RunWithCapture(windows_cmd,
|
||||
"set PROCESSOR_ARCHITECTURE", &arch_out,
|
||||
nullptr, ArchType::kWindows_x86_64);
|
||||
@@ -223,14 +222,13 @@ std::string ServerArch::GetStartServerCommand(int exit_code_not_found,
|
||||
// a minor issue and means we display "Deploying server..." instead of
|
||||
// "Server not deployed. Deploying...";
|
||||
return RemoteUtil::QuoteForWindows(
|
||||
absl::StrFormat("powershell -Command \" "
|
||||
absl::StrFormat("powershell -Command "
|
||||
"Set-StrictMode -Version 2; "
|
||||
"$ErrorActionPreference = 'Stop'; "
|
||||
"if (-not (Test-Path -Path '%s')) { "
|
||||
" exit %i; "
|
||||
"} "
|
||||
"%s %s "
|
||||
"\"",
|
||||
"%s %s",
|
||||
server_path, exit_code_not_found, server_path, args));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user