Esempio n. 1
0
        public GitCommand(string working_dir, string args, SSHAuthenticationInfo auth_info) : base(GitPath, args)
        {
            StartInfo.WorkingDirectory = working_dir;

            string GIT_SSH_COMMAND = SSHCommand.SSHCommandPath;

            if (auth_info != null)
            {
                GIT_SSH_COMMAND = FormatGitSSHCommand(auth_info);
            }

            if (ExecPath != null)
            {
                SetEnvironmentVariable("GIT_EXEC_PATH", ExecPath);
            }

            SetEnvironmentVariable("GIT_SSH_COMMAND", GIT_SSH_COMMAND);
            SetEnvironmentVariable("GIT_TERMINAL_PROMPT", "0");

            // Don't let Git try to read the config options in PREFIX/etc or ~
            SetEnvironmentVariable("GIT_CONFIG_NOSYSTEM", "1");
            SetEnvironmentVariable("PREFIX", "");
            SetEnvironmentVariable("HOME", "");

            SetEnvironmentVariable("LANG", "en_US");
        }
Esempio n. 2
0
        public GitFetcher(SparkleFetcherInfo fetcher_info, SSHAuthenticationInfo auth_info)
            : base(fetcher_info)
        {
            this.auth_info = auth_info;
            var uri_builder = new UriBuilder (RemoteUrl);

            if (!RemoteUrl.Scheme.Equals ("ssh") && !RemoteUrl.Scheme.Equals ("git"))
                uri_builder.Scheme = "ssh";

            if (RemoteUrl.Host.Equals ("github.com") ||
                RemoteUrl.Host.Equals ("gitlab.com")) {

                AvailableStorageTypes.Add (
                    new StorageTypeInfo (StorageType.LargeFiles, "Large File Storage",
                        "Trade off versioning to save space;\nkeeps file history on the host only"));

                uri_builder.Scheme   = "ssh";
                uri_builder.UserName = "******";

                if (!RemoteUrl.AbsolutePath.EndsWith (".git"))
                    uri_builder.Path += ".git";

            } else if (string.IsNullOrEmpty (RemoteUrl.UserInfo)) {
                uri_builder.UserName = "******";
            }

            RemoteUrl = uri_builder.Uri;

            AvailableStorageTypes.Add (
                new StorageTypeInfo (StorageType.Encrypted, "Encrypted Storage",
                    "Trade off efficiency for privacy;\nencrypts before storing files on the host"));
        }
Esempio n. 3
0
 public static string FormatGitSSHCommand(SSHAuthenticationInfo auth_info)
 {
     return(SSHCommandPath + " " +
            "-i " + auth_info.PrivateKeyFilePath.Replace("\\", "/").Replace(" ", "\\ ") + " " +
            "-o UserKnownHostsFile=" + auth_info.KnownHostsFilePath.Replace("\\", "/").Replace(" ", "\\ ") + " " +
            "-o IdentitiesOnly=yes" + " " +        // Don't fall back to other keys on the system
            "-o PasswordAuthentication=no" + " " + // Don't hang on possible password prompts
            "-F /dev/null");                       // Ignore the system's SSH config file
 }
Esempio n. 4
0
        public GitRepository(string path, Configuration config, SSHAuthenticationInfo auth_info) : base(path, config)
        {
            this.auth_info = auth_info;

            var git_config = new GitCommand(LocalPath, "config core.ignorecase false");

            git_config.StartAndWaitForExit();

            git_config = new GitCommand(LocalPath, "config remote.origin.url \"" + RemoteUrl + "\"");
            git_config.StartAndWaitForExit();
        }
Esempio n. 5
0
        public GitRepository(string path, Configuration config, SSHAuthenticationInfo auth_info)
            : base(path, config)
        {
            this.auth_info = auth_info;

            var git_config = new GitCommand (LocalPath, "config core.ignorecase false");
            git_config.StartAndWaitForExit ();

            git_config = new GitCommand (LocalPath, "config remote.origin.url \"" + RemoteUrl + "\"");
            git_config.StartAndWaitForExit ();
        }
Esempio n. 6
0
        public virtual void Initialize()
        {
            string version = InstallationInfo.Version;

            if (InstallationInfo.Directory.StartsWith("/app", StringComparison.InvariantCulture))
            {
                version += " (Flatpak)";
            }

            Logger.LogInfo("Environment", "SparkleShare " + version);
            Logger.LogInfo("Environment", "Git LFS " + Sparkles.Git.GitCommand.GitLFSVersion);
            Logger.LogInfo("Environment", "Git " + Sparkles.Git.GitCommand.GitVersion);

            // TODO: Nice OS version names for Linux (Fedora 24, Ubuntu 16.04, etc.)
            if (InstallationInfo.OperatingSystem == OS.Mac)
            {
                Logger.LogInfo("Environment", InstallationInfo.MacOSVersion());
            }
            else
            {
                Logger.LogInfo("Environment", InstallationInfo.OperatingSystem + " (" + Environment.OSVersion + ")");
            }

            UserAuthenticationInfo = new SSHAuthenticationInfo();
            SSHAuthenticationInfo.DefaultAuthenticationInfo = UserAuthenticationInfo;

            Preset.PresetsPath = PresetsPath;
            InstallProtocolHandler();

            try {
                CreateSparkleShareFolder();
            } catch (DirectoryNotFoundException) {
                this.lost_folders_path = true;
            }

            SetFolderIcon();

            // Watch the SparkleShare folder
            this.watcher = new FileSystemWatcher()
            {
                Filter = "*",
                IncludeSubdirectories = false,
                Path = FoldersPath
            };

            watcher.Created            += OnFolderActivity;
            watcher.EnableRaisingEvents = true;
        }
Esempio n. 7
0
        public GitCommand(string working_dir, string args, SSHAuthenticationInfo auth_info)
            : base(GitPath, args)
        {
            StartInfo.WorkingDirectory = working_dir;

            string GIT_SSH_COMMAND = SSHPath;

            if (auth_info != null)
                GIT_SSH_COMMAND = FormatGitSSHCommand (auth_info);

            if (ExecPath != null)
                SetEnvironmentVariable ("GIT_EXEC_PATH", ExecPath);

            SetEnvironmentVariable ("GIT_SSH_COMMAND", GIT_SSH_COMMAND);
            SetEnvironmentVariable ("GIT_TERMINAL_PROMPT", "0");
            SetEnvironmentVariable ("LANG", "en_US");
        }
Esempio n. 8
0
        public BaseController()
        {
            string app_data_path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            if (InstallationInfo.OperatingSystem != OS.Windows && InstallationInfo.OperatingSystem != OS.Mac)
            {
                app_data_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".config");
            }

            string config_path = Path.Combine(app_data_path, "org.sparkleshare.SparkleShare");

            Config = new Configuration(config_path, "projects.xml");
            Configuration.DefaultConfiguration = Config;

            UserAuthenticationInfo = new SSHAuthenticationInfo();
            SSHAuthenticationInfo.DefaultAuthenticationInfo = UserAuthenticationInfo;

            FoldersPath = Config.FoldersPath;
        }
Esempio n. 9
0
        public GitCommand(string working_dir, string args, SSHAuthenticationInfo auth_info) : base(GitPath, args)
        {
            StartInfo.WorkingDirectory = working_dir;

            string GIT_SSH_COMMAND = SSHCommand.SSHCommandPath;

            if (auth_info != null)
            {
                GIT_SSH_COMMAND = FormatGitSSHCommand(auth_info);
            }

            if (ExecPath != null)
            {
                SetEnvironmentVariable("GIT_EXEC_PATH", ExecPath);
            }

            SetEnvironmentVariable("GIT_SSH_COMMAND", GIT_SSH_COMMAND);
            SetEnvironmentVariable("GIT_TERMINAL_PROMPT", "0");
            SetEnvironmentVariable("LANG", "en_US");
        }
Esempio n. 10
0
        public virtual void Initialize()
        {
            string version = InstallationInfo.Version;

            if (InstallationInfo.IsFlatpak)
            {
                version += " (Flatpak)";
            }

            Logger.LogInfo("Environment", "SparkleShare " + version);
            Logger.LogInfo("Environment", "Git LFS " + Sparkles.Git.GitCommand.GitLFSVersion);
            Logger.LogInfo("Environment", "Git " + Sparkles.Git.GitCommand.GitVersion);
            Logger.LogInfo("Environment", InstallationInfo.OperatingSystem + " " + InstallationInfo.OperatingSystemVersion);

            UserAuthenticationInfo = new SSHAuthenticationInfo();
            SSHAuthenticationInfo.DefaultAuthenticationInfo = UserAuthenticationInfo;

            Preset.PresetsPath = PresetsPath;
            InstallProtocolHandler();

            try {
                CreateSparkleShareFolder();
            } catch (DirectoryNotFoundException) {
                this.lost_folders_path = true;
            }

            SetFolderIcon();

            // Watch the SparkleShare folder
            this.watcher = new FileSystemWatcher()
            {
                Filter = "*",
                IncludeSubdirectories = false,
                Path = FoldersPath
            };

            watcher.Created            += OnFolderActivity;
            watcher.EnableRaisingEvents = true;
        }
Esempio n. 11
0
        public GitRepository(string path, Configuration config, SSHAuthenticationInfo auth_info) : base(path, config)
        {
            this.auth_info = auth_info;

            var git_config = new GitCommand(LocalPath, "config core.ignorecase false");

            git_config.StartAndWaitForExit();

            git_config = new GitCommand(LocalPath, "config remote.origin.url \"" + RemoteUrl + "\"");
            git_config.StartAndWaitForExit();

            git_config = new GitCommand(LocalPath, "config core.sshCommand " + GitCommand.FormatGitSSHCommand(auth_info));
            git_config.StartAndWaitForExit();

            if (InstallationInfo.OperatingSystem != OS.Windows)
            {
                string pre_push_hook_path = Path.Combine(LocalPath, ".git", "hooks", "pre-push");

                // TODO: Use proper API
                var chmod = new Command("chmod", "700 " + pre_push_hook_path);
                chmod.StartAndWaitForExit();
            }
        }
Esempio n. 12
0
        public GitFetcher(SparkleFetcherInfo fetcher_info, SSHAuthenticationInfo auth_info) : base(fetcher_info)
        {
            this.auth_info = auth_info;
            var uri_builder = new UriBuilder(RemoteUrl);

            if (!RemoteUrl.Scheme.Equals("ssh") && !RemoteUrl.Scheme.Equals("git"))
            {
                uri_builder.Scheme = "ssh";
            }

            if (RemoteUrl.Host.Equals("github.com") ||
                RemoteUrl.Host.Equals("gitlab.com"))
            {
                AvailableStorageTypes.Add(
                    new StorageTypeInfo(StorageType.LargeFiles, "Large File Storage",
                                        "Trade off versioning to save space;\nkeeps file history on the host only"));

                uri_builder.Scheme   = "ssh";
                uri_builder.UserName = "******";

                if (!RemoteUrl.AbsolutePath.EndsWith(".git"))
                {
                    uri_builder.Path += ".git";
                }
            }
            else if (string.IsNullOrEmpty(RemoteUrl.UserInfo))
            {
                uri_builder.UserName = "******";
            }

            RemoteUrl = uri_builder.Uri;

            AvailableStorageTypes.Add(
                new StorageTypeInfo(StorageType.Encrypted, "Encrypted Storage",
                                    "Trade off efficiency for privacy;\nencrypts before storing files on the host"));
        }
Esempio n. 13
0
 public static string FormatGitSSHCommand(SSHAuthenticationInfo auth_info)
 {
     return SSHPath + " " +
         "-i " + auth_info.PrivateKeyFilePath.Replace (" ", "\\ ") + " " +
         "-o UserKnownHostsFile=" + auth_info.KnownHostsFilePath.Replace (" ", "\\ ") + " " +
         "-o IdentitiesOnly=yes" + " " + // Don't fall back to other keys on the system
         "-o PasswordAuthentication=no" + " " + // Don't hang on possible password prompts
         "-F /dev/null"; // Ignore the system's SSH config file
 }