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;
int port = RemoteUrl.Port;
if (port < 1)
port = 22;
SparkleLogger.LogInfo ("Auth", "Fetching host key for " + host);
Process process = new Process () {
@ -269,7 +273,7 @@ namespace SparkleLib {
};
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.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
@ -282,7 +286,7 @@ namespace SparkleLib {
string host_key = process.StandardOutput.ReadToEnd ().Trim ();
process.WaitForExit ();
if (process.ExitCode == 0 && host_key != "")
if (process.ExitCode == 0 && !string.IsNullOrEmpty (host_key))
return host_key;
else
return null;