diff --git a/KeeAgent/KeeAgentExt.cs b/KeeAgent/KeeAgentExt.cs index 757c196..6e5c902 100644 --- a/KeeAgent/KeeAgentExt.cs +++ b/KeeAgent/KeeAgentExt.cs @@ -230,7 +230,9 @@ private void mKeeAgentPwEntryContextMenuItem_Clicked(object aSender, EventArgs a if (entry.GetKeeAgentSettings().AllowUseOfSshKey) { try { var constraints = new List(); - if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { + if (!(mAgent is PageantClient) && + (Control.ModifierKeys & Keys.Control) == Keys.Control) + { var dialog = new ConstraintsInputDialog(); dialog.ShowDialog(); if (dialog.DialogResult == DialogResult.OK) { @@ -562,7 +564,7 @@ private void MainForm_FileOpened(object aSender, break; } var settings = entry.GetKeeAgentSettings(); - if (settings.AllowUseOfSshKey && settings.AddAtDatabaseOpen) { + if (settings.AllowUseOfSshKey && settings.AddAtDatabaseOpen) { try { AddEntry(entry, null); } catch (Exception) { @@ -638,15 +640,27 @@ public ISshKey AddEntry(PwEntry aEntry, var settings = aEntry.GetKeeAgentSettings(); try { var key = aEntry.GetSshKey(); - if (aConstraints != null) { - foreach (var constraint in aConstraints) { - key.AddConstraint(constraint); + + if (mAgent is PageantClient) { + // Pageant errors if you try to add a key that is already loaded + // so try to remove the key first so that it behaves like other agents + try { + mAgent.RemoveKey(key); + } catch (Exception) { + // ignore failure + } + } else { + // also, Pageant does not support constraints + if (aConstraints != null) { + foreach (var constraint in aConstraints) { + key.AddConstraint(constraint); + } + } + if (Options.AlwasyConfirm && + !key.HasConstraint(Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_CONFIRM)) + { + key.addConfirmConstraint(); } - } - if (Options.AlwasyConfirm && - !key.HasConstraint(Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_CONFIRM)) - { - key.addConfirmConstraint(); } mAgent.AddKey(key); return key; diff --git a/KeeAgent/UI/EntryPickerDialog.Designer.cs b/KeeAgent/UI/EntryPickerDialog.Designer.cs index 7cbfd1d..8ac5d67 100644 --- a/KeeAgent/UI/EntryPickerDialog.Designer.cs +++ b/KeeAgent/UI/EntryPickerDialog.Designer.cs @@ -27,7 +27,6 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EntryPickerDialog)); this.mCancelButton = new System.Windows.Forms.Button(); this.mOkButton = new System.Windows.Forms.Button(); this.mCustomTreeViewEx = new KeeAgent.UI.TreeViewEx(); @@ -83,12 +82,12 @@ private void InitializeComponent() this.mTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.mTableLayoutPanel.Controls.Add(this.mConfirmConstraintControl, 0, 0); this.mTableLayoutPanel.Controls.Add(this.mLifetimeConstraintControl, 1, 0); - this.mTableLayoutPanel.Location = new System.Drawing.Point(12, 356); + this.mTableLayoutPanel.Location = new System.Drawing.Point(12, 362); this.mTableLayoutPanel.Margin = new System.Windows.Forms.Padding(0); this.mTableLayoutPanel.Name = "mTableLayoutPanel"; this.mTableLayoutPanel.RowCount = 1; this.mTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.mTableLayoutPanel.Size = new System.Drawing.Size(352, 26); + this.mTableLayoutPanel.Size = new System.Drawing.Size(352, 20); this.mTableLayoutPanel.TabIndex = 3; // // mConfirmConstraintControl @@ -101,7 +100,7 @@ private void InitializeComponent() this.mConfirmConstraintControl.Location = new System.Drawing.Point(10, 0); this.mConfirmConstraintControl.Margin = new System.Windows.Forms.Padding(10, 0, 0, 0); this.mConfirmConstraintControl.Name = "mConfirmConstraintControl"; - this.mConfirmConstraintControl.Size = new System.Drawing.Size(166, 26); + this.mConfirmConstraintControl.Size = new System.Drawing.Size(166, 20); this.mConfirmConstraintControl.TabIndex = 0; // // mLifetimeConstraintControl @@ -114,7 +113,7 @@ private void InitializeComponent() this.mLifetimeConstraintControl.Location = new System.Drawing.Point(176, 0); this.mLifetimeConstraintControl.Margin = new System.Windows.Forms.Padding(0); this.mLifetimeConstraintControl.Name = "mLifetimeConstraintControl"; - this.mLifetimeConstraintControl.Size = new System.Drawing.Size(176, 26); + this.mLifetimeConstraintControl.Size = new System.Drawing.Size(176, 20); this.mLifetimeConstraintControl.TabIndex = 1; // // EntryPickerDialog @@ -128,7 +127,6 @@ private void InitializeComponent() this.Controls.Add(this.mOkButton); this.Controls.Add(this.mCancelButton); this.Controls.Add(this.mCustomTreeViewEx); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "EntryPickerDialog"; diff --git a/KeeAgent/UI/EntryPickerDialog.cs b/KeeAgent/UI/EntryPickerDialog.cs index 313cae1..dbbf883 100644 --- a/KeeAgent/UI/EntryPickerDialog.cs +++ b/KeeAgent/UI/EntryPickerDialog.cs @@ -35,10 +35,15 @@ public ICollection Constraints } } - public EntryPickerDialog(IPluginHost aPluginHost) + public EntryPickerDialog(IPluginHost aPluginHost, bool aShowConstraintControls) { mPluginHost = aPluginHost; InitializeComponent(); + if (!aShowConstraintControls) { + Controls.Remove(mTableLayoutPanel); + mCustomTreeViewEx.Height += mTableLayoutPanel.Height + 6; + } + #if !__MonoCS__ // TODO figure out why this crashes mono Icon = Properties.Resources.KeeAgent_ico; diff --git a/KeeAgent/UI/EntryPickerDialog.resx b/KeeAgent/UI/EntryPickerDialog.resx index a1b9380..29dcb1b 100644 --- a/KeeAgent/UI/EntryPickerDialog.resx +++ b/KeeAgent/UI/EntryPickerDialog.resx @@ -117,5 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - \ No newline at end of file diff --git a/KeeAgent/UI/ManageDialog.cs b/KeeAgent/UI/ManageDialog.cs index e0f35c7..ce947fd 100644 --- a/KeeAgent/UI/ManageDialog.cs +++ b/KeeAgent/UI/ManageDialog.cs @@ -34,7 +34,9 @@ private void addButtonFromFileMenuItem_Click(object sender, EventArgs e) private void addButtonFromKeePassMenuItem_Click(object sender, EventArgs e) { - var entryPicker = new EntryPickerDialog(mExt.mPluginHost); + var showConstraintControls = !(mExt.mAgent is PageantClient); + var entryPicker = + new EntryPickerDialog(mExt.mPluginHost, showConstraintControls); var result = entryPicker.ShowDialog(); if (result == DialogResult.OK) { try { diff --git a/SshAgentLib b/SshAgentLib index cffc855..dc06792 160000 --- a/SshAgentLib +++ b/SshAgentLib @@ -1 +1 @@ -Subproject commit cffc8557462f092c86b3dea8eab8948fa895ddd6 +Subproject commit dc067926c28a49d5d19bbd160dab38da1b273abc