Compare commits

..

4 Commits

Author SHA1 Message Date
Sean Kaim
e6f3c22064 code clean up / add'l checks
related to #1061
2018-08-03 10:13:31 -04:00
David Sparer
a013518eac bump assembly version 2018-08-03 08:51:44 -05:00
David Sparer
9c88cacb3d hopefully a fix for #1061 2018-08-03 08:33:51 -05:00
David Sparer
d49bf04b15 fixes #1062 2018-08-03 08:13:39 -05:00
5 changed files with 57 additions and 20 deletions

View File

@@ -1,3 +1,9 @@
1.76.6 (2018-08-03):
Fixes:
------
#1062: Entering correct password when starting app does not load connections file
1.76.5 (2018-08-02):
Fixes:

View File

@@ -1,19 +1,19 @@
using Microsoft.Win32;
using mRemoteNG.App;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Messages;
using System;
using System.Collections.Generic;
using System.Management;
using System.Security.Principal;
using System.Text;
using System.Web;
using Microsoft.Win32;
using mRemoteNG.App;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Messages;
namespace mRemoteNG.Config.Putty
{
public class PuttySessionsRegistryProvider : AbstractPuttySessionsProvider
public class PuttySessionsRegistryProvider : AbstractPuttySessionsProvider
{
private const string PuttySessionsKey = "Software\\SimonTatham\\PuTTY\\Sessions";
private static ManagementEventWatcher _eventWatcher;
@@ -39,7 +39,10 @@ namespace mRemoteNG.Config.Putty
}
public override PuttySessionInfo GetSession(string sessionName)
{
{
if (string.IsNullOrEmpty(sessionName))
return null;
var sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
var sessionKey = sessionsKey?.OpenSubKey(sessionName);
if (sessionKey == null) return null;
@@ -53,7 +56,11 @@ namespace mRemoteNG.Config.Putty
Hostname = sessionKey.GetValue("HostName").ToString(),
Username = sessionKey.GetValue("UserName").ToString()
};
var protocol = string.IsNullOrEmpty(sessionKey.GetValue("Protocol").ToString()) ? sessionKey.GetValue("Protocol").ToString() : "ssh";
var protocol = string.IsNullOrEmpty(sessionKey.GetValue("Protocol").ToString())
? sessionKey.GetValue("Protocol").ToString()
: "ssh";
switch (protocol.ToLowerInvariant())
{
case "raw":

View File

@@ -33,6 +33,7 @@ namespace mRemoteNG.Config.Putty
foreach (var sessionName in Directory.GetFiles(sessionsFolderPath))
{
var sessionFileName = Path.GetFileName(sessionName);
// ReSharper disable once ConstantConditionalAccessQualifier
sessionNames.Add(raw ? sessionFileName : System.Web.HttpUtility.UrlDecode(sessionFileName?.Replace("+", "%2B")));
}
@@ -174,7 +175,8 @@ namespace mRemoteNG.Config.Putty
private static string GetPuttyConfPath()
{
var puttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath ? mRemoteNG.Settings.Default.CustomPuttyPath : App.Info.GeneralAppInfo.PuttyPath;
return Path.Combine(Path.GetDirectoryName(puttyPath), "putty.conf");
puttyPath = Path.GetDirectoryName(puttyPath);
return string.IsNullOrEmpty(puttyPath) ? null : Path.Combine(puttyPath, "putty.conf");
}
private static string GetSessionsFolderPath()
@@ -201,6 +203,9 @@ namespace mRemoteNG.Config.Putty
private static PuttySessionInfo ModifyRegistrySessionInfo(PuttySessionInfo sessionInfo)
{
if (sessionInfo == null)
return null;
sessionInfo.Name = string.Format(RegistrySessionNameFormat, sessionInfo.Name);
sessionInfo.PuttySession = string.Format(RegistrySessionNameFormat, sessionInfo.PuttySession);
return sessionInfo;

View File

@@ -33,5 +33,5 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// <Assembly: AssemblyVersion("1.0.*")>
[assembly: AssemblyVersion("1.76.5.*")]
[assembly: AssemblyVersion("1.76.6.*")]
[assembly: NeutralResourcesLanguage("en")]

View File

@@ -11,15 +11,34 @@ namespace mRemoteNG.UI.Forms
private readonly string _passwordName;
private SecureString _password = new SecureString();
private bool Verify { get; }
/// <summary>
/// Puts the dialog into the New Password mode. An extra
/// password box is shown which must match the first password
/// to continue.
/// </summary>
private bool NewPasswordMode { get; }
public PasswordForm(string passwordName = null, bool verify = true)
/// <summary>
/// Creates a new password form for entering or setting a password.
/// </summary>
/// <param name="passwordName"></param>
/// <param name="newPasswordMode">
/// Puts the dialog into the New Password mode. An extra
/// password box is shown which must match the first password
/// to continue.
/// </param>
public PasswordForm(string passwordName = null, bool newPasswordMode = true)
{
InitializeComponent();
_passwordName = passwordName;
Verify = verify;
NewPasswordMode = newPasswordMode;
}
/// <summary>
/// Dispaly a dialog box requesting that the user
/// enter their password.
/// </summary>
/// <returns></returns>
public Optional<SecureString> GetKey()
{
var dialog = ShowDialog();
@@ -33,7 +52,7 @@ namespace mRemoteNG.UI.Forms
{
ApplyLanguage();
if (Verify) return;
if (NewPasswordMode) return;
Height = Height - (txtVerify.Top - txtPassword.Top);
lblVerify.Visible = false;
txtVerify.Visible = false;
@@ -44,7 +63,7 @@ namespace mRemoteNG.UI.Forms
_password = txtPassword.Text.ConvertToSecureString();
txtPassword.Text = "";
txtVerify.Text = "";
if (Verify) return;
if (NewPasswordMode) return;
Height = Height + (txtVerify.Top - txtPassword.Top);
}
@@ -56,10 +75,10 @@ namespace mRemoteNG.UI.Forms
private void btnOK_Click(object sender, EventArgs e)
{
if (Verify && VerifyPassword())
DialogResult = DialogResult.OK;
else
DialogResult = DialogResult.None;
if (NewPasswordMode)
VerifyNewPassword();
DialogResult = DialogResult.OK;
}
private void txtPassword_TextChanged(object sender, EventArgs e)
@@ -79,7 +98,7 @@ namespace mRemoteNG.UI.Forms
btnOK.Text = Language.strButtonOK;
}
private bool VerifyPassword()
private bool VerifyNewPassword()
{
if (txtPassword.Text.Length >= 3)
{