Skip to content

Commit

Permalink
[FIX] Removed ability to select constraints when using Client Mode wi…
Browse files Browse the repository at this point in the history
…th Pageant. Closes #34.
  • Loading branch information
dlech committed May 27, 2013
1 parent 842d088 commit d975f53
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 20 deletions.
34 changes: 24 additions & 10 deletions KeeAgent/KeeAgentExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ private void mKeeAgentPwEntryContextMenuItem_Clicked(object aSender, EventArgs a
if (entry.GetKeeAgentSettings().AllowUseOfSshKey) {
try {
var constraints = new List<Agent.KeyConstraint>();
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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions KeeAgent/UI/EntryPickerDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion KeeAgent/UI/EntryPickerDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ public ICollection<Agent.KeyConstraint> 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;
Expand Down
1 change: 0 additions & 1 deletion KeeAgent/UI/EntryPickerDialog.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</root>
4 changes: 3 additions & 1 deletion KeeAgent/UI/ManageDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion SshAgentLib

0 comments on commit d975f53

Please sign in to comment.