Skip to content

Commit

Permalink
SSH Agent: Replace all occurrences of 'flush' with 'clear' (keepassxr…
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexpFr committed Jun 23, 2024
1 parent bba6e12 commit ee37774
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 30 deletions.
20 changes: 20 additions & 0 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3267,6 +3267,10 @@ Would you like to correct it?</source>
<source> seconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear agent</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditGroupWidget</name>
Expand Down Expand Up @@ -6047,6 +6051,14 @@ Expect some bugs and minor issues, this version is meant for testing purposes.</
<source>Setup Remote Sync…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear SSH Agent</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear all identities like ssh-add -D</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ManageDatabase</name>
Expand Down Expand Up @@ -9484,6 +9496,14 @@ This option is deprecated, use --set-key-file instead.</source>
<source>No agent running, cannot list identities.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to remove all SSH identities from agent.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All SSH identities removed from agent.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SearchHelpWidget</name>
Expand Down
4 changes: 2 additions & 2 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,10 +832,10 @@ void DatabaseWidget::removeFromAgent()
}
}

void DatabaseWidget::flushSSHAgent()
void DatabaseWidget::clearSSHAgent()
{
SSHAgent* agent = SSHAgent::instance();
if (!agent->flushAllAgentIdentities()) {
if (!agent->clearAllAgentIdentities()) {
showMessage(agent->errorString(), MessageWidget::Error);
} else {
showMessage(agent->errorString(), MessageWidget::Positive);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public slots:
#ifdef WITH_XC_SSHAGENT
void addToAgent();
void removeFromAgent();
void flushSSHAgent();
void clearSSHAgent();
#endif
void performAutoType(const QString& sequence = {});
void performAutoTypeUsername();
Expand Down
18 changes: 9 additions & 9 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ MainWindow::MainWindow()
connect(sshAgent(), SIGNAL(enabledChanged(bool)), this, SLOT(agentEnabled(bool)));
m_ui->settingsWidget->addSettingsPage(new AgentSettingsPage());
if (!sshAgent()->isEnabled()) {
m_ui->actionFlushSSHAgent->setEnabled(false);
m_ui->actionFlushSSHAgent->setVisible(false);
m_ui->actionClearSSHAgent->setEnabled(false);
m_ui->actionClearSSHAgent->setVisible(false);
}
#else
m_ui->actionFlushSSHAgent->setVisible(false);
m_ui->actionFlushSSHAgent->setEnabled(false);
m_ui->actionClearSSHAgent->setVisible(false);
m_ui->actionClearSSHAgent->setEnabled(false);
#endif

#if defined(WITH_XC_KEESHARE)
Expand Down Expand Up @@ -427,7 +427,7 @@ MainWindow::MainWindow()

m_ui->actionSettings->setIcon(icons()->icon("configure"));
#ifdef WITH_XC_SSHAGENT
m_ui->actionFlushSSHAgent->setIcon(icons()->icon("utilities-terminal"));
m_ui->actionClearSSHAgent->setIcon(icons()->icon("utilities-terminal"));
#endif
m_ui->actionPasswordGenerator->setIcon(icons()->icon("password-generator"));

Expand Down Expand Up @@ -543,7 +543,7 @@ MainWindow::MainWindow()
#ifdef WITH_XC_SSHAGENT
m_actionMultiplexer.connect(m_ui->actionEntryAddToAgent, SIGNAL(triggered()), SLOT(addToAgent()));
m_actionMultiplexer.connect(m_ui->actionEntryRemoveFromAgent, SIGNAL(triggered()), SLOT(removeFromAgent()));
m_actionMultiplexer.connect(m_ui->actionFlushSSHAgent, SIGNAL(triggered()), SLOT(flushSSHAgent()));
m_actionMultiplexer.connect(m_ui->actionClearSSHAgent, SIGNAL(triggered()), SLOT(clearSSHAgent()));
#endif

m_actionMultiplexer.connect(m_ui->actionGroupNew, SIGNAL(triggered()), SLOT(createGroup()));
Expand Down Expand Up @@ -1674,8 +1674,8 @@ void MainWindow::agentEnabled(bool enabled)
{
m_ui->actionEntryAddToAgent->setVisible(enabled);
m_ui->actionEntryRemoveFromAgent->setVisible(enabled);
m_ui->actionFlushSSHAgent->setEnabled(enabled);
m_ui->actionFlushSSHAgent->setVisible(enabled);
m_ui->actionClearSSHAgent->setEnabled(enabled);
m_ui->actionClearSSHAgent->setVisible(enabled);
}

void MainWindow::showEntryContextMenu(const QPoint& globalPos)
Expand Down Expand Up @@ -2161,7 +2161,7 @@ void MainWindow::initActionCollection()
// Tools Menu
m_ui->actionPasswordGenerator,
#ifdef WITH_XC_SSHAGENT
m_ui->actionFlushSSHAgent,
m_ui->actionClearSSHAgent,
#endif
m_ui->actionSettings,
// View Menu
Expand Down
8 changes: 4 additions & 4 deletions src/gui/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
<string>&amp;Tools</string>
</property>
<addaction name="actionPasswordGenerator"/>
<addaction name="actionFlushSSHAgent"/>
<addaction name="actionClearSSHAgent"/>
<addaction name="actionSettings"/>
</widget>
<widget class="QMenu" name="menuView">
Expand Down Expand Up @@ -1395,12 +1395,12 @@
<string>Import…</string>
</property>
</action>
<action name="actionFlushSSHAgent">
<action name="actionClearSSHAgent">
<property name="text">
<string>Flush SSH Agent</string>
<string>Clear SSH Agent</string>
</property>
<property name="toolTip">
<string>Flush identities like ssh-add -D</string>
<string>Clear all identities like ssh-add -D</string>
</property>
<property name="menuRole">
<enum>QAction::TextHeuristicRole</enum>
Expand Down
8 changes: 4 additions & 4 deletions src/gui/entry/EditEntryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void EditEntryWidget::setupSSHAgent()
connect(m_sshAgentUi->browseButton, &QPushButton::clicked, this, &EditEntryWidget::browsePrivateKey);
connect(m_sshAgentUi->addToAgentButton, &QPushButton::clicked, this, &EditEntryWidget::addKeyToAgent);
connect(m_sshAgentUi->removeFromAgentButton, &QPushButton::clicked, this, &EditEntryWidget::removeKeyFromAgent);
connect(m_sshAgentUi->flushAgentButton, &QPushButton::clicked, this, &EditEntryWidget::flushAgent);
connect(m_sshAgentUi->clearAgentButton, &QPushButton::clicked, this, &EditEntryWidget::clearAgent);
connect(m_sshAgentUi->decryptButton, &QPushButton::clicked, this, &EditEntryWidget::decryptPrivateKey);
connect(m_sshAgentUi->copyToClipboardButton, &QPushButton::clicked, this, &EditEntryWidget::copyPublicKey);
connect(m_sshAgentUi->generateButton, &QPushButton::clicked, this, &EditEntryWidget::generatePrivateKey);
Expand Down Expand Up @@ -679,7 +679,7 @@ void EditEntryWidget::updateSSHAgentKeyInfo()
if (sshAgent()->isAgentRunning()) {
m_sshAgentUi->addToAgentButton->setEnabled(true);
m_sshAgentUi->removeFromAgentButton->setEnabled(true);
m_sshAgentUi->flushAgentButton->setEnabled(true);
m_sshAgentUi->clearAgentButton->setEnabled(true);

sshAgent()->setAutoRemoveOnLock(key, m_sshAgentUi->removeKeyFromAgentCheckBox->isChecked());
}
Expand Down Expand Up @@ -782,9 +782,9 @@ void EditEntryWidget::removeKeyFromAgent()
}
}

void EditEntryWidget::flushAgent()
void EditEntryWidget::clearAgent()
{
if (!sshAgent()->flushAllAgentIdentities()) {
if (!sshAgent()->clearAllAgentIdentities()) {
showMessage(sshAgent()->errorString(), MessageWidget::Error);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/entry/EditEntryWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private slots:
void browsePrivateKey();
void addKeyToAgent();
void removeKeyFromAgent();
void flushAgent();
void clearAgent();
void decryptPrivateKey();
void copyPublicKey();
void generatePrivateKey();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/entry/EditEntryWidgetSSHAgent.ui
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="flushAgentButton">
<widget class="QPushButton" name="clearAgentButton">
<property name="text">
<string>Flush agent</string>
<string>Clear agent</string>
</property>
</widget>
</item>
Expand Down
12 changes: 6 additions & 6 deletions src/sshagent/SSHAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,15 @@ bool SSHAgent::removeIdentity(OpenSSHKey& key)
}

/**
* Flush all identities from the SSH agent.
* Remove all identities from the SSH agent.
*
* Since the agent might be forwarded, old or non-OpenSSH, when asked
* to remove all keys, attempt to remove both protocol v.1 and v.2
* keys.
*
* @return true on success
*/
bool SSHAgent::flushAllAgentIdentities()
bool SSHAgent::clearAllAgentIdentities()
{
if (!isAgentRunning()) {
m_error = tr("No agent running, cannot remove identity.");
Expand All @@ -385,7 +385,7 @@ bool SSHAgent::flushAllAgentIdentities()
BinaryStream request(&requestData);

// Same request order as OpenBSD ssh-add: useful?
request.write(SSH2_AGENTC_REMOVE_ALL_IDENTITIES);
request.write(SSH2_AGENTC_REMOVE_ALL_IDENTITIES);

if (!sendMessage(requestData, responseData)) {
m_error = tr("Failed to remove all SSH identities from agent.");
Expand All @@ -396,10 +396,10 @@ bool SSHAgent::flushAllAgentIdentities()
responseData.clear();

// Same request order as OpenBSD ssh-add: useful?
request.write(SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES);
request.write(SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES);

// ignore error-code for ssh1
sendMessage(requestData, responseData);
sendMessage(requestData, responseData);

m_error = tr("All SSH identities removed from agent.");
return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/sshagent/SSHAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SSHAgent : public QObject
bool checkIdentity(const OpenSSHKey& key, bool& loaded);
bool removeIdentity(OpenSSHKey& key);
void removeAllIdentities();
bool flushAllAgentIdentities();
bool clearAllAgentIdentities();
void setAutoRemoveOnLock(const OpenSSHKey& key, bool autoRemove);

signals:
Expand Down

0 comments on commit ee37774

Please sign in to comment.