setup: Start thread to create first run key pair. Fixes #694

This commit is contained in:
Hylke Bons 2012-04-11 13:57:46 +02:00
parent bf45b91ddc
commit 5fe7284385
2 changed files with 27 additions and 35 deletions

View file

@ -814,15 +814,14 @@ namespace SparkleShare {
string key_file_path = Path.Combine (keys_path, key_file_name); string key_file_path = Path.Combine (keys_path, key_file_name);
if (File.Exists (key_file_path)) { if (File.Exists (key_file_path)) {
SparkleHelpers.DebugInfo ("Auth", "Key already exists ('" + key_file_name + "'), " + SparkleHelpers.DebugInfo ("Auth", "Keypair exists ('" + key_file_name + "'), leaving it untouched");
"leaving it untouched");
return; return;
}
} else {
if (!Directory.Exists (keys_path)) if (!Directory.Exists (keys_path))
Directory.CreateDirectory (keys_path); Directory.CreateDirectory (keys_path);
}
if (!File.Exists (key_file_name)) {
Process process = new Process () { Process process = new Process () {
EnableRaisingEvents = true EnableRaisingEvents = true
}; };
@ -841,21 +840,14 @@ namespace SparkleShare {
process.Start (); process.Start ();
process.WaitForExit (); process.WaitForExit ();
SparkleHelpers.DebugInfo ("Auth", "Created private key '" + key_file_name + "'"); if (process.ExitCode == 0)
SparkleHelpers.DebugInfo ("Auth", "Created public key '" + key_file_name + ".pub'"); SparkleHelpers.DebugInfo ("Auth", "Created keypair '" + key_file_name + "'");
else
// Add some restrictions to what the key can SparkleHelpers.DebugInfo ("Auth", "Could not create keypair '" + key_file_name + "'");
// 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 // Create an easily accessible copy of the public
// key in the user's SparkleShare folder // key in the user's SparkleShare folder
File.Copy (key_file_path + ".pub", File.Copy (key_file_path + ".pub", Path.Combine (SparklePath, UserName + "'s key.txt"), true);
Path.Combine (SparklePath, UserName + "'s key.txt"),
true); // Overwriting is allowed
}
} }

View file

@ -227,7 +227,7 @@ namespace SparkleShare {
Program.Controller.GenerateKeyPair (); Program.Controller.GenerateKeyPair ();
Program.Controller.ImportPrivateKey (); Program.Controller.ImportPrivateKey ();
}) })
); ).Start ();
TutorialPageNumber = 1; TutorialPageNumber = 1;