From 45655d4395535dead87803956119eefbaf939a9b Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 25 Dec 2011 20:33:39 +0100 Subject: [PATCH] fetcher: fix permissions on ssh config file --- SparkleLib/SparkleConfig.cs | 8 ++++++-- SparkleLib/SparkleFetcherBase.cs | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/SparkleLib/SparkleConfig.cs b/SparkleLib/SparkleConfig.cs index 305827a9..1b301f8b 100755 --- a/SparkleLib/SparkleConfig.cs +++ b/SparkleLib/SparkleConfig.cs @@ -32,9 +32,13 @@ namespace SparkleLib { "sparkleshare"); public static SparkleConfig DefaultConfig = new SparkleConfig (ConfigPath, "config.xml"); - public string FullPath; - public string HomePath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); + + public string HomePath { + get { + return Environment.GetFolderPath (Environment.SpecialFolder.Personal); + } + } public string FoldersPath { diff --git a/SparkleLib/SparkleFetcherBase.cs b/SparkleLib/SparkleFetcherBase.cs index 22894770..da69976d 100755 --- a/SparkleLib/SparkleFetcherBase.cs +++ b/SparkleLib/SparkleFetcherBase.cs @@ -22,8 +22,6 @@ using System.Security.AccessControl; using System.Text.RegularExpressions; using System.Threading; -using Mono.Unix; - namespace SparkleLib { // Sets up a fetcher that can get remote folders @@ -158,10 +156,7 @@ namespace SparkleLib { File.WriteAllText (ssh_config_file_path, ssh_config); } - UnixFileSystemInfo file_info = new UnixFileInfo (ssh_config_file_path); - file_info.FileAccessPermissions = (FileAccessPermissions.UserRead | - FileAccessPermissions.UserWrite); - + Chmod644 (ssh_config_file_path); SparkleHelpers.DebugInfo ("Fetcher", "Disabled host key checking for " + host); } @@ -208,10 +203,7 @@ namespace SparkleLib { } else { File.WriteAllText (ssh_config_file_path, new_ssh_config.Trim ()); - - UnixFileSystemInfo file_info = new UnixFileInfo (ssh_config_file_path); - file_info.FileAccessPermissions = (FileAccessPermissions.UserRead | - FileAccessPermissions.UserWrite); + Chmod644 (ssh_config_file_path); } } @@ -229,5 +221,15 @@ namespace SparkleLib { else return null; } + + + private void Chmod644 (string file_path) + { + // Hack to be able to set the permissions on a file + // that OpenSSH still likes without resorting to Mono.Unix + FileInfo file_info = new FileInfo (file_path); + file_info.Attributes = FileAttributes.ReadOnly; + file_info.Attributes = FileAttributes.Normal; + } } }