From ce9dc73d95b5483bd12489e64fe2215605f7e433 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 29 Oct 2011 14:06:49 +0100 Subject: [PATCH] Add some SSH access limiting options to the generated public keys. Closes #392. --- SparkleShare/SparkleBubblesController.cs | 2 +- SparkleShare/SparkleControllerBase.cs | 25 ++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/SparkleShare/SparkleBubblesController.cs b/SparkleShare/SparkleBubblesController.cs index e6983625..dd660b8a 100755 --- a/SparkleShare/SparkleBubblesController.cs +++ b/SparkleShare/SparkleBubblesController.cs @@ -34,7 +34,7 @@ namespace SparkleShare { }; Program.Controller.NotificationRaised += delegate (string user_name, string user_email, - string message, string folder_path) { + string message, string folder_path) { ShowBubble (user_name, message, Program.Controller.GetAvatar (user_email, 36)); }; diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 10c7e09b..b9c663cc 100755 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -876,18 +876,23 @@ namespace SparkleShare { // -f is the file name to store the private key in process.StartInfo.Arguments = "-t rsa -P \"\" -f " + key_file_name; - process.Exited += delegate { - SparkleHelpers.DebugInfo ("Config", "Created private key '" + key_file_name + "'"); - SparkleHelpers.DebugInfo ("Config", "Created public key '" + key_file_name + ".pub'"); - - // Create an easily accessible copy of the public - // key in the user's SparkleShare folder - File.Copy (key_file_path + ".pub", - Path.Combine (SparklePath, UserName + "'s key.txt")); - }; - process.Start (); process.WaitForExit (); + + SparkleHelpers.DebugInfo ("Config", "Created private key '" + key_file_name + "'"); + SparkleHelpers.DebugInfo ("Config", "Created public key '" + key_file_name + ".pub'"); + + // Add some restrictions to what the key can + // do when uploaded to the server + string public_key = File.ReadAllText (key_file_path + ".pub"); + public_key = "no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty " + public_key; + File.WriteAllText (key_file_path + ".pub", public_key); + + // Create an easily accessible copy of the public + // key in the user's SparkleShare folder + File.Copy (key_file_path + ".pub", + Path.Combine (SparklePath, UserName + "'s key.txt")); + } }