Fix ssh config file not being removed if needed
This commit is contained in:
parent
c67277c079
commit
4b86d9c72e
|
@ -917,13 +917,16 @@ namespace SparkleShare {
|
||||||
private void DisableHostKeyCheckingForHost (string host)
|
private void DisableHostKeyCheckingForHost (string host)
|
||||||
{
|
{
|
||||||
|
|
||||||
string ssh_config_file_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".ssh", "config");
|
string ssh_config_file_path = SparkleHelpers.CombineMore (
|
||||||
string ssh_config = "Host " + host + "\n\tStrictHostKeyChecking no";
|
SparklePaths.HomePath, ".ssh", "config");
|
||||||
|
|
||||||
|
string ssh_config = Environment.NewLine + "Host " + host +
|
||||||
|
Environment.NewLine + "\tStrictHostKeyChecking no";
|
||||||
|
|
||||||
if (File.Exists (ssh_config_file_path)) {
|
if (File.Exists (ssh_config_file_path)) {
|
||||||
|
|
||||||
TextWriter writer = File.AppendText (ssh_config_file_path);
|
TextWriter writer = File.AppendText (ssh_config_file_path);
|
||||||
writer.WriteLine ("\n" + ssh_config);
|
writer.WriteLine (ssh_config);
|
||||||
writer.Close ();
|
writer.Close ();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -940,11 +943,11 @@ namespace SparkleShare {
|
||||||
private void EnableHostKeyCheckingForHost (string host)
|
private void EnableHostKeyCheckingForHost (string host)
|
||||||
{
|
{
|
||||||
|
|
||||||
string ssh_config_file_path = SparkleHelpers.CombineMore
|
string ssh_config_file_path = SparkleHelpers.CombineMore (
|
||||||
(SparklePaths.HomePath, ".ssh", "config");
|
SparklePaths.HomePath, ".ssh", "config");
|
||||||
|
|
||||||
string ssh_config = "Host " + host + "\n" +
|
string ssh_config = Environment.NewLine + "Host " + host +
|
||||||
"\tStrictHostKeyChecking no";
|
Environment.NewLine + "\tStrictHostKeyChecking no";
|
||||||
|
|
||||||
if (File.Exists (ssh_config_file_path)) {
|
if (File.Exists (ssh_config_file_path)) {
|
||||||
|
|
||||||
|
@ -952,10 +955,11 @@ namespace SparkleShare {
|
||||||
string current_ssh_config = reader.ReadToEnd ();
|
string current_ssh_config = reader.ReadToEnd ();
|
||||||
reader.Close ();
|
reader.Close ();
|
||||||
|
|
||||||
current_ssh_config = current_ssh_config.Remove (current_ssh_config.IndexOf (ssh_config),
|
current_ssh_config = current_ssh_config.Remove (
|
||||||
ssh_config.Length);
|
current_ssh_config.IndexOf (ssh_config), ssh_config.Length);
|
||||||
|
|
||||||
if (current_ssh_config.Trim ().Equals ("")) {
|
bool has_some_config = new Regex (@"[a-z]").IsMatch (current_ssh_config);
|
||||||
|
if (!has_some_config) {
|
||||||
|
|
||||||
File.Delete (ssh_config_file_path);
|
File.Delete (ssh_config_file_path);
|
||||||
|
|
||||||
|
@ -965,6 +969,8 @@ namespace SparkleShare {
|
||||||
writer.WriteLine (current_ssh_config);
|
writer.WriteLine (current_ssh_config);
|
||||||
writer.Close ();
|
writer.Close ();
|
||||||
|
|
||||||
|
//Syscall.chmod (ssh_config_file_path, FilePermissions.S_IRWXU);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
controller_name="Lin";
|
|
||||||
// Initialize the controller this way so that
|
// Initialize the controller this way so that
|
||||||
// there aren't any exceptions in the OS specific UI's
|
// there aren't any exceptions in the OS specific UI's
|
||||||
Controller = (SparkleController) Activator.CreateInstance (
|
Controller = (SparkleController) Activator.CreateInstance (
|
||||||
|
|
Loading…
Reference in a new issue