From 93785776a635eff64cf3d24e0bafdd15a7bd5253 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 27 Mar 2016 22:09:57 +0100 Subject: [PATCH] auth: Allow Windows domain account paths --- SparkleLib/SSHAuthenticationInfo.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/SparkleLib/SSHAuthenticationInfo.cs b/SparkleLib/SSHAuthenticationInfo.cs index d4417d84..e5c257b0 100644 --- a/SparkleLib/SSHAuthenticationInfo.cs +++ b/SparkleLib/SSHAuthenticationInfo.cs @@ -41,7 +41,9 @@ namespace SparkleLib { public SSHAuthenticationInfo () { Path = IO.Path.Combine (IO.Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath), "ssh"); + KnownHostsFilePath = IO.Path.Combine (Path, "known_hosts"); + KnownHostsFilePath = MakeWindowsDomainAccountSafe (KnownHostsFilePath); if (IO.Directory.Exists (Path)) { ImportKeys (); @@ -68,6 +70,9 @@ namespace SparkleLib { } if (key_found) { + PrivateKeyFilePath = MakeWindowsDomainAccountSafe (PrivateKeyFilePath); + PublicKeyFilePath = MakeWindowsDomainAccountSafe (PublicKeyFilePath); + PrivateKey = IO.File.ReadAllText (PrivateKeyFilePath); PublicKey = IO.File.ReadAllText (PublicKeyFilePath); @@ -108,5 +113,15 @@ namespace SparkleLib { SparkleLogger.LogInfo ("Auth", "Could not create key pair"); return false; } + + + // Use forward slashes in paths when dealing with Windows domain accounts + string MakeWindowsDomainAccountSafe (string path) + { + if (path.StartsWith ("\\\\")) + return path.Replace ("\\", "/"); + + return path; + } } }