fetcher: Fix some edge cases on host key check
This commit is contained in:
parent
70e88288f0
commit
416b23bd5b
|
@ -262,6 +262,10 @@ namespace SparkleLib {
|
||||||
{
|
{
|
||||||
string host = RemoteUrl.Host;
|
string host = RemoteUrl.Host;
|
||||||
int port = RemoteUrl.Port;
|
int port = RemoteUrl.Port;
|
||||||
|
|
||||||
|
if (port < 1)
|
||||||
|
port = 22;
|
||||||
|
|
||||||
SparkleLogger.LogInfo ("Auth", "Fetching host key for " + host);
|
SparkleLogger.LogInfo ("Auth", "Fetching host key for " + host);
|
||||||
|
|
||||||
Process process = new Process () {
|
Process process = new Process () {
|
||||||
|
@ -269,7 +273,7 @@ namespace SparkleLib {
|
||||||
};
|
};
|
||||||
|
|
||||||
process.StartInfo.FileName = "ssh-keyscan";
|
process.StartInfo.FileName = "ssh-keyscan";
|
||||||
process.StartInfo.Arguments = "-t rsa -p " + port.ToString() + " " + host;
|
process.StartInfo.Arguments = "-t rsa -p " + port + " " + host;
|
||||||
process.StartInfo.WorkingDirectory = SparkleConfig.DefaultConfig.TmpPath;
|
process.StartInfo.WorkingDirectory = SparkleConfig.DefaultConfig.TmpPath;
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
|
@ -282,7 +286,7 @@ namespace SparkleLib {
|
||||||
string host_key = process.StandardOutput.ReadToEnd ().Trim ();
|
string host_key = process.StandardOutput.ReadToEnd ().Trim ();
|
||||||
process.WaitForExit ();
|
process.WaitForExit ();
|
||||||
|
|
||||||
if (process.ExitCode == 0 && host_key != "")
|
if (process.ExitCode == 0 && !string.IsNullOrEmpty (host_key))
|
||||||
return host_key;
|
return host_key;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue