From ba7b42fdcaec95be21a25d2da49b760de31487e7 Mon Sep 17 00:00:00 2001 From: Alexandre Petit <62973006+AlexpFr@users.noreply.github.com> Date: Sat, 27 Apr 2024 23:54:08 +0200 Subject: [PATCH] SSH Agent: Replace all occurrences of 'flush' with 'clear' (#8346) --- share/translations/keepassxc_en.ts | 20 ++++++++++++++++++++ src/gui/DatabaseWidget.cpp | 4 ++-- src/gui/DatabaseWidget.h | 2 +- src/gui/MainWindow.cpp | 18 +++++++++--------- src/gui/MainWindow.ui | 8 ++++---- src/gui/entry/EditEntryWidget.cpp | 8 ++++---- src/gui/entry/EditEntryWidget.h | 2 +- src/gui/entry/EditEntryWidgetSSHAgent.ui | 4 ++-- src/sshagent/SSHAgent.cpp | 12 ++++++------ src/sshagent/SSHAgent.h | 2 +- 10 files changed, 50 insertions(+), 30 deletions(-) diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts index a2cc594a5..4040c2f23 100644 --- a/share/translations/keepassxc_en.ts +++ b/share/translations/keepassxc_en.ts @@ -3267,6 +3267,10 @@ Would you like to correct it? seconds + + Clear agent + + EditGroupWidget @@ -6047,6 +6051,14 @@ Expect some bugs and minor issues, this version is meant for testing purposes.Setup Remote Sync… + + Clear SSH Agent + + + + Clear all identities like ssh-add -D + + ManageDatabase @@ -9484,6 +9496,14 @@ This option is deprecated, use --set-key-file instead. No agent running, cannot list identities. + + Failed to remove all SSH identities from agent. + + + + All SSH identities removed from agent. + + SearchHelpWidget diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 59955e242..58ae12f8d 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -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); diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index fb32edf3e..4ec828742 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -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(); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index beecc6d9b..a746b56ae 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -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) @@ -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")); @@ -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())); @@ -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) @@ -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 diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index d9d4df923..dbad58713 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -372,7 +372,7 @@ &Tools - + @@ -1395,12 +1395,12 @@ Import… - + - Flush SSH Agent + Clear SSH Agent - Flush identities like ssh-add -D + Clear all identities like ssh-add -D QAction::TextHeuristicRole diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index e25b2951d..1c21eb99b 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -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); @@ -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()); } @@ -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; } diff --git a/src/gui/entry/EditEntryWidget.h b/src/gui/entry/EditEntryWidget.h index 050eea7a2..d25391f5d 100644 --- a/src/gui/entry/EditEntryWidget.h +++ b/src/gui/entry/EditEntryWidget.h @@ -122,7 +122,7 @@ private slots: void browsePrivateKey(); void addKeyToAgent(); void removeKeyFromAgent(); - void flushAgent(); + void clearAgent(); void decryptPrivateKey(); void copyPublicKey(); void generatePrivateKey(); diff --git a/src/gui/entry/EditEntryWidgetSSHAgent.ui b/src/gui/entry/EditEntryWidgetSSHAgent.ui index faa6d62ef..3215c1a27 100644 --- a/src/gui/entry/EditEntryWidgetSSHAgent.ui +++ b/src/gui/entry/EditEntryWidgetSSHAgent.ui @@ -155,9 +155,9 @@ - + - Flush agent + Clear agent diff --git a/src/sshagent/SSHAgent.cpp b/src/sshagent/SSHAgent.cpp index 5e8514c41..6590d33f9 100644 --- a/src/sshagent/SSHAgent.cpp +++ b/src/sshagent/SSHAgent.cpp @@ -364,7 +364,7 @@ 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 @@ -372,7 +372,7 @@ bool SSHAgent::removeIdentity(OpenSSHKey& key) * * @return true on success */ -bool SSHAgent::flushAllAgentIdentities() +bool SSHAgent::clearAllAgentIdentities() { if (!isAgentRunning()) { m_error = tr("No agent running, cannot remove identity."); @@ -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."); @@ -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; diff --git a/src/sshagent/SSHAgent.h b/src/sshagent/SSHAgent.h index eeb3bda10..d3eeb4ebc 100644 --- a/src/sshagent/SSHAgent.h +++ b/src/sshagent/SSHAgent.h @@ -56,7 +56,7 @@ public: 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: