fetcher: Fix some edge cases on host key check

This commit is contained in:
Hylke Bons 2012-09-05 14:14:15 +01:00
parent 4c9baddc2c
commit 6cbba96963

View file

@ -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;