Ejemplo n.º 1
0
        /// <summary>Shows the "SSH error" dialog modally, and returns the path to the key, if one was loaded.</summary>
        public static string AskForKey(IWin32Window parent)
        {
            var form = new FormPuttyError();
            form.ShowDialog(parent);

            return form.KeyPath;
        }
Ejemplo n.º 2
0
 /// <summary>Shows the "SSH error" dialog modally, and returns the path to the key, if one was loaded.</summary>
 public static bool AskForKey(IWin32Window parent, out string keyPath)
 {
     var form = new FormPuttyError();
     var result = form.ShowDialog(parent);
     keyPath = form.KeyPath;
     return result == DialogResult.Retry;
 }
Ejemplo n.º 3
0
        /// <summary>Shows the "SSH error" dialog modally, and returns the path to the key, if one was loaded.</summary>
        public static bool AskForKey(IWin32Window parent, [NotNullWhen(returnValue: true)] out string?keyPath)
        {
            using var form = new FormPuttyError();
            var result = form.ShowDialog(parent);

            keyPath = form.KeyPath;
            return(result == DialogResult.Retry);
        }
Ejemplo n.º 4
0
        /// <summary>Shows the "SSH error" dialog modally, and returns the path to the key, if one was loaded.</summary>
        public static bool AskForKey(IWin32Window parent, out string keyPath)
        {
            var form   = new FormPuttyError();
            var result = form.ShowDialog(parent);

            keyPath = form.KeyPath;
            return(result == DialogResult.Retry);
        }
Ejemplo n.º 5
0
        protected override bool HandleOnExit(ref bool isError)
        {
            if (restart)
            {
                Retry();
                return(true);
            }


            // An error occurred!
            if (isError && Plink)
            {
                //there might be an other error, this condition is too weak

                /*
                 * if (OutputString.ToString().Contains("successfully authenticated"))
                 * {
                 *  isError = false;
                 *  return false;
                 * }
                 */

                // If the authentication failed because of a missing key, ask the user to supply one.
                if (OutputString.ToString().Contains("FATAL ERROR") && OutputString.ToString().Contains("authentication"))
                {
                    string loadedKey;
                    if (FormPuttyError.AskForKey(this, out loadedKey))
                    {
                        // To prevent future authentication errors, save this key for this remote.
                        if (!String.IsNullOrEmpty(loadedKey) && !String.IsNullOrEmpty(this.Remote) &&
                            String.IsNullOrEmpty(Module.GetPathSetting("remote.{0}.puttykeyfile")))
                        {
                            Module.SetPathSetting(string.Format("remote.{0}.puttykeyfile", this.Remote), loadedKey);
                        }

                        // Retry the command.
                        Retry();
                        return(true);
                    }
                }
                if (OutputString.ToString().ToLower().Contains("the server's host key is not cached in the registry"))
                {
                    string remoteUrl;

                    if (string.IsNullOrEmpty(UrlTryingToConnect))
                    {
                        remoteUrl = Module.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, Remote));
                        if (string.IsNullOrEmpty(remoteUrl))
                        {
                            remoteUrl = Remote;
                        }
                    }
                    else
                    {
                        remoteUrl = UrlTryingToConnect;
                    }
                    if (!string.IsNullOrEmpty(remoteUrl))
                    {
                        if (MessageBox.Show(this, _serverHotkeyNotCachedText.Text, "SSH", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                        {
                            Module.RunRealCmd(
                                "cmd.exe",
                                string.Format("/k \"\"{0}\" -T \"{1}\"\"", Settings.Plink, remoteUrl));

                            Retry();
                            return(true);
                        }
                    }
                }
            }

            return(base.HandleOnExit(ref isError));
        }
Ejemplo n.º 6
0
        protected override bool HandleOnExit(ref bool isError)
        {
            if (restart)
            {
                Retry();
                return true;
            }

            // An error occurred!
            if (isError && Plink)
            {
                //there might be an other error, this condition is too weak
                /*
                if (OutputString.ToString().Contains("successfully authenticated"))
                {
                    isError = false;
                    return false;
                }
                */

                if (OutputString.ToString().Contains("FATAL ERROR") && OutputString.ToString().Contains("authentication"))
                {
                    var puttyError = new FormPuttyError();
                    puttyError.ShowDialog();
                    if (puttyError.RetryProcess)
                    {
                        Retry();
                        return true;
                    }
                }
                if (OutputString.ToString().ToLower().Contains("the server's host key is not cached in the registry"))
                {
                    string remoteUrl;

                    if (string.IsNullOrEmpty(UrlTryingToConnect))
                    {
                        remoteUrl = GitCommandHelpers.GetSetting("remote." + Remote + ".url");
                        if (string.IsNullOrEmpty(remoteUrl))
                            remoteUrl = Remote;
                    }
                    else
                        remoteUrl = UrlTryingToConnect;
                    if (!string.IsNullOrEmpty(remoteUrl))
                        if (MessageBox.Show("The server's host key is not cached in the registry.\n\nDo you want to trust this host key and then try again?", "SSH", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                        {
                            GitCommandHelpers.RunRealCmd(
                                "cmd.exe",
                                string.Format("/k \"\"{0}\" -T \"{1}\"\"", Settings.Plink, remoteUrl));

                            Retry();
                            return true;
                        }

                }
            }

            return base.HandleOnExit(ref isError);
        }
Ejemplo n.º 7
0
        void gitCommand_Exited(object sender, EventArgs e)
        {
            // This has to happen on the UI thread
            SendOrPostCallback method = new SendOrPostCallback(delegate(object o)
            {

                if (restart)
                {
                    Reset();
                    ProcessCallback(this);
                    return;
                }

                bool isError;
                try
                {
                    // An error occurred!
                if (gitCommand != null && gitCommand.ExitCode != 0)
                {
                    isError = true;

                    // TODO: This Plink stuff here seems misplaced. Is there a better
                    // home for all of this stuff? For example, if I had a label called pull,
                    // we could end up in this code incorrectly.
                    if (Plink)
                    {
                        if (ProcessArguments.ToLower().Contains("pull") ||
                            ProcessArguments.ToLower().Contains("push") ||
                            ProcessArguments.ToLower().Contains("plink") ||
                            ProcessArguments.ToLower().Contains("tortoiseplink") ||
                            ProcessArguments.ToLower().Contains("remote") ||
                            ProcessString.ToLower().Contains("clone") ||
                            ProcessArguments.ToLower().Contains("clone"))
                        {
                            if (OutputString.ToString().Contains("successfully authenticated"))
                            {
                                isError = false;
                            }

                            if (OutputString.ToString().Contains("FATAL ERROR") && OutputString.ToString().Contains("authentication"))
                            {
                                FormPuttyError puttyError = new FormPuttyError();
                                puttyError.ShowDialog();
                                if (puttyError.RetryProcess)
                                {
                                    Reset();
                                    ProcessCallback(this);
                                    return;
                                }
                            }
                        }
                    }
                }
                else
                {
                    isError = false;
                }
                }
                catch
                {
                    isError = true;
                }

                Done(!isError);

            });

            syncContext.Send(method, this);
        }
Ejemplo n.º 8
0
        void Done()
        {
            if (restart)
            {
                Start();
                return;
            }

            AddOutput(outputString.ToString());
            AddOutput("Done");
            ProgressBar.Visible = false;
            Ok.Enabled = true;
            Abort.Enabled = false;
            try
            {
                //An error occured!
                if (gitCommand != null && gitCommand.Process != null && gitCommand.Process.ExitCode != 0)
                {
                    ErrorImage.Visible = true;
                    errorOccured = true;
                    SuccessImage.Visible = false;
                    if (Plink)
                    {
                        if (ProcessArguments.Contains("pull") ||
                            ProcessArguments.Contains("push") ||
                            ProcessArguments.Contains("plink") ||
                            ProcessArguments.Contains("remote") ||
                            ProcessString.Contains("clone") ||
                            ProcessArguments.Contains("clone"))
                        {
                            if (Output.Text.Contains("successfully authenticated"))
                            {
                                SuccessImage.Visible = true;
                                ErrorImage.Visible = false;
                                errorOccured = false;
                            }

                            if (Output.Text.Contains("FATAL ERROR") && Output.Text.Contains("authentication"))
                            {
                                FormPuttyError puttyError = new FormPuttyError();
                                puttyError.ShowDialog();
                                if (puttyError.RetryProcess)
                                {
                                    FormProcess_Load(null, null);
                                }
                            }
                        }
                    }
                }
                else
                {
                    ErrorImage.Visible = false;
                    SuccessImage.Visible = true;
                    errorOccured = false;

                    if (GitCommands.Settings.CloseProcessDialog)
                        Close();

                }
            }
            catch
            {
                errorOccured = true;
                ErrorImage.Visible = true;
                SuccessImage.Visible = false;
            }
        }
Ejemplo n.º 9
0
        private void OnExit(object state)
        {
            if (restart)
            {
                Reset();
                ProcessCallback(this);
                return;
            }

            bool isError;
            try
            {
                // An error occurred!
                if (gitCommand != null && gitCommand.ExitCode != 0)
                {
                    isError = true;

                    // TODO: This Plink stuff here seems misplaced. Is there a better
                    // home for all of this stuff? For example, if I had a label called pull,
                    // we could end up in this code incorrectly.
                    if (Plink)
                    {
                        if (ProcessArguments.ToLower().Contains("pull") || ProcessArguments.ToLower().Contains("push") || ProcessArguments.ToLower().Contains("plink") || ProcessArguments.ToLower().Contains("tortoiseplink") || ProcessArguments.ToLower().Contains("remote") || ProcessString.ToLower().Contains("clone") || ProcessArguments.ToLower().Contains("clone"))
                        {
                            if (OutputString.ToString().Contains("successfully authenticated"))
                            {
                                isError = false;
                            }

                            if (OutputString.ToString().Contains("FATAL ERROR") && OutputString.ToString().Contains("authentication"))
                            {
                                var puttyError = new FormPuttyError();
                                puttyError.ShowDialog();
                                if (puttyError.RetryProcess)
                                {
                                    Reset();
                                    ProcessCallback(this);
                                    return;
                                }
                            }
                            if (OutputString.ToString().ToLower().Contains("the server's host key is not cached in the registry") && !string.IsNullOrEmpty(UrlTryingToConnect))
                            {
                                if (MessageBox.Show("The server's host key is not cached in the registry.\n\nDo you want to trust this host key and then try again?", "SSH", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                                {
                                    GitCommandHelpers.RunRealCmdDetached(
                                        "cmd.exe",
                                        string.Format("/k \"\"{0}\" -T \"{1}\"\"", Settings.Plink, UrlTryingToConnect));

                                    Reset();
                                    ProcessCallback(this);
                                    return;
                                }

                            }
                        }

                    }
                }
                else
                {
                    isError = false;
                }
            }
            catch
            {
                isError = true;
            }

            Done(!isError);
        }
Ejemplo n.º 10
0
        protected override bool HandleOnExit(ref bool isError)
        {
            if (restart)
            {
                Retry();
                return(true);
            }


            // An error occurred!
            if (isError && Plink)
            {
                //there might be an other error, this condition is too weak

                /*
                 * if (GetOutputString().Contains("successfully authenticated"))
                 * {
                 *  isError = false;
                 *  return false;
                 * }
                 */

                // If the authentication failed because of a missing key, ask the user to supply one.
                if (GetOutputString().Contains("FATAL ERROR") && GetOutputString().Contains("authentication"))
                {
                    string loadedKey;
                    if (FormPuttyError.AskForKey(this, out loadedKey))
                    {
                        // To prevent future authentication errors, save this key for this remote.
                        if (!String.IsNullOrEmpty(loadedKey) && !String.IsNullOrEmpty(this.Remote) &&
                            String.IsNullOrEmpty(Module.GetPathSetting("remote.{0}.puttykeyfile")))
                        {
                            Module.SetPathSetting(string.Format("remote.{0}.puttykeyfile", this.Remote), loadedKey);
                        }

                        // Retry the command.
                        Retry();
                        return(true);
                    }
                }
                if (GetOutputString().ToLower().Contains("the server's host key is not cached in the registry"))
                {
                    string remoteUrl;

                    if (string.IsNullOrEmpty(UrlTryingToConnect))
                    {
                        remoteUrl = Module.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, Remote));
                        if (string.IsNullOrEmpty(remoteUrl))
                        {
                            remoteUrl = Remote;
                        }
                    }
                    else
                    {
                        remoteUrl = UrlTryingToConnect;
                    }

                    if (AskForCacheHostkey(this, Module, remoteUrl))
                    {
                        Retry();
                        return(true);
                    }
                }
            }

            return(base.HandleOnExit(ref isError));
        }
Ejemplo n.º 11
0
        private void OnExit(object state)
        {
            if (restart)
            {
                Reset();
                ProcessCallback(this);
                return;
            }

            bool isError;

            try
            {
                // An error occurred!
                if (gitCommand != null && gitCommand.ExitCode != 0)
                {
                    isError = true;

                    // TODO: This Plink stuff here seems misplaced. Is there a better
                    // home for all of this stuff? For example, if I had a label called pull,
                    // we could end up in this code incorrectly.
                    if (Plink)
                    {
                        if (ProcessArguments.ToLower().Contains("pull") || ProcessArguments.ToLower().Contains("push") || ProcessArguments.ToLower().Contains("plink") || ProcessArguments.ToLower().Contains("tortoiseplink") || ProcessArguments.ToLower().Contains("remote") || ProcessString.ToLower().Contains("clone") || ProcessArguments.ToLower().Contains("clone"))
                        {
                            if (OutputString.ToString().Contains("successfully authenticated"))
                            {
                                isError = false;
                            }

                            if (OutputString.ToString().Contains("FATAL ERROR") && OutputString.ToString().Contains("authentication"))
                            {
                                var puttyError = new FormPuttyError();
                                puttyError.ShowDialog();
                                if (puttyError.RetryProcess)
                                {
                                    Reset();
                                    ProcessCallback(this);
                                    return;
                                }
                            }
                            if (OutputString.ToString().ToLower().Contains("the server's host key is not cached in the registry") && !string.IsNullOrEmpty(UrlTryingToConnect))
                            {
                                if (MessageBox.Show("The server's host key is not cached in the registry.\n\nDo you want to trust this host key and then try again?", "SSH", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                                {
                                    GitCommandHelpers.RunRealCmdDetached(
                                        "cmd.exe",
                                        string.Format("/k \"\"{0}\" -T \"{1}\"\"", Settings.Plink, UrlTryingToConnect));

                                    Reset();
                                    ProcessCallback(this);
                                    return;
                                }
                            }
                        }
                    }
                }
                else
                {
                    isError = false;
                }
            }
            catch
            {
                isError = true;
            }

            Done(!isError);
        }
Ejemplo n.º 12
0
        protected override bool HandleOnExit(ref bool isError)
        {
            if (restart)
            {
                Retry();
                return(true);
            }


            // An error occurred!
            if (isError && Plink)
            {
                //there might be an other error, this condition is too weak

                /*
                 * if (OutputString.ToString().Contains("successfully authenticated"))
                 * {
                 *  isError = false;
                 *  return false;
                 * }
                 */

                if (OutputString.ToString().Contains("FATAL ERROR") && OutputString.ToString().Contains("authentication"))
                {
                    var puttyError = new FormPuttyError();
                    puttyError.ShowDialog(this);
                    if (puttyError.RetryProcess)
                    {
                        Retry();
                        return(true);
                    }
                }
                if (OutputString.ToString().ToLower().Contains("the server's host key is not cached in the registry"))
                {
                    string remoteUrl;

                    if (string.IsNullOrEmpty(UrlTryingToConnect))
                    {
                        remoteUrl = Settings.Module.GetSetting("remote." + Remote + ".url");
                        if (string.IsNullOrEmpty(remoteUrl))
                        {
                            remoteUrl = Remote;
                        }
                    }
                    else
                    {
                        remoteUrl = UrlTryingToConnect;
                    }
                    if (!string.IsNullOrEmpty(remoteUrl))
                    {
                        if (MessageBox.Show(this, _serverHotkeyNotCachedText.Text, "SSH", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                        {
                            Settings.Module.RunRealCmd(
                                "cmd.exe",
                                string.Format("/k \"\"{0}\" -T \"{1}\"\"", Settings.Plink, remoteUrl));

                            Retry();
                            return(true);
                        }
                    }
                }
            }

            return(base.HandleOnExit(ref isError));
        }