From 1cb01cd7f1c40f4ed6b40bb22f14452b26a6ac1a Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 6 Mar 2016 00:16:37 +0000 Subject: [PATCH] keys: read SSH_AUTH_SOCK --- SparkleShare/SparkleKeys.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SparkleShare/SparkleKeys.cs b/SparkleShare/SparkleKeys.cs index e720cbe5..3505bb96 100644 --- a/SparkleShare/SparkleKeys.cs +++ b/SparkleShare/SparkleKeys.cs @@ -18,6 +18,7 @@ using System; using System.Diagnostics; using System.IO; +using System.Text.RegularExpressions; using SparkleLib; @@ -88,8 +89,12 @@ namespace SparkleShare { SparkleLogger.LogInfo ("Auth", "No key agent running, starting one..."); SparkleProcess process = new SparkleProcess ("ssh-agent", ""); - process.Start (); - process.WaitForExit (); + string output = process.StartAndReadStandardOutput (); + + Match auth_sock_match = new Regex (@"SSH_AUTH_SOCK=([^;\n\r]*)").Match (output); + + if (auth_sock_match.Success) + Environment.SetEnvironmentVariable ("SSH_AUTH_SOCK", auth_sock_match.Groups [1].Value); } } }