SSH Agent: Replace all occurrences of 'flush' with 'clear' (#8346)

This commit is contained in:
Alexandre Petit 2024-04-27 23:54:08 +02:00
parent 4bc8685a96
commit ba7b42fdca
No known key found for this signature in database
10 changed files with 50 additions and 30 deletions

View File

@ -3267,6 +3267,10 @@ Would you like to correct it?</source>
<source> seconds</source> <source> seconds</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Clear agent</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>EditGroupWidget</name> <name>EditGroupWidget</name>
@ -6047,6 +6051,14 @@ Expect some bugs and minor issues, this version is meant for testing purposes.</
<source>Setup Remote Sync</source> <source>Setup Remote Sync</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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>
<context> <context>
<name>ManageDatabase</name> <name>ManageDatabase</name>
@ -9484,6 +9496,14 @@ This option is deprecated, use --set-key-file instead.</source>
<source>No agent running, cannot list identities.</source> <source>No agent running, cannot list identities.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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>
<context> <context>
<name>SearchHelpWidget</name> <name>SearchHelpWidget</name>

View File

@ -832,10 +832,10 @@ void DatabaseWidget::removeFromAgent()
} }
} }
void DatabaseWidget::flushSSHAgent() void DatabaseWidget::clearSSHAgent()
{ {
SSHAgent* agent = SSHAgent::instance(); SSHAgent* agent = SSHAgent::instance();
if (!agent->flushAllAgentIdentities()) { if (!agent->clearAllAgentIdentities()) {
showMessage(agent->errorString(), MessageWidget::Error); showMessage(agent->errorString(), MessageWidget::Error);
} else { } else {
showMessage(agent->errorString(), MessageWidget::Positive); showMessage(agent->errorString(), MessageWidget::Positive);

View File

@ -200,7 +200,7 @@ public slots:
#ifdef WITH_XC_SSHAGENT #ifdef WITH_XC_SSHAGENT
void addToAgent(); void addToAgent();
void removeFromAgent(); void removeFromAgent();
void flushSSHAgent(); void clearSSHAgent();
#endif #endif
void performAutoType(const QString& sequence = {}); void performAutoType(const QString& sequence = {});
void performAutoTypeUsername(); void performAutoTypeUsername();

View File

@ -230,12 +230,12 @@ MainWindow::MainWindow()
connect(sshAgent(), SIGNAL(enabledChanged(bool)), this, SLOT(agentEnabled(bool))); connect(sshAgent(), SIGNAL(enabledChanged(bool)), this, SLOT(agentEnabled(bool)));
m_ui->settingsWidget->addSettingsPage(new AgentSettingsPage()); m_ui->settingsWidget->addSettingsPage(new AgentSettingsPage());
if (!sshAgent()->isEnabled()) { if (!sshAgent()->isEnabled()) {
m_ui->actionFlushSSHAgent->setEnabled(false); m_ui->actionClearSSHAgent->setEnabled(false);
m_ui->actionFlushSSHAgent->setVisible(false); m_ui->actionClearSSHAgent->setVisible(false);
} }
#else #else
m_ui->actionFlushSSHAgent->setVisible(false); m_ui->actionClearSSHAgent->setVisible(false);
m_ui->actionFlushSSHAgent->setEnabled(false); m_ui->actionClearSSHAgent->setEnabled(false);
#endif #endif
#if defined(WITH_XC_KEESHARE) #if defined(WITH_XC_KEESHARE)
@ -427,7 +427,7 @@ MainWindow::MainWindow()
m_ui->actionSettings->setIcon(icons()->icon("configure")); m_ui->actionSettings->setIcon(icons()->icon("configure"));
#ifdef WITH_XC_SSHAGENT #ifdef WITH_XC_SSHAGENT
m_ui->actionFlushSSHAgent->setIcon(icons()->icon("utilities-terminal")); m_ui->actionClearSSHAgent->setIcon(icons()->icon("utilities-terminal"));
#endif #endif
m_ui->actionPasswordGenerator->setIcon(icons()->icon("password-generator")); m_ui->actionPasswordGenerator->setIcon(icons()->icon("password-generator"));
@ -543,7 +543,7 @@ MainWindow::MainWindow()
#ifdef WITH_XC_SSHAGENT #ifdef WITH_XC_SSHAGENT
m_actionMultiplexer.connect(m_ui->actionEntryAddToAgent, SIGNAL(triggered()), SLOT(addToAgent())); 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->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 #endif
m_actionMultiplexer.connect(m_ui->actionGroupNew, SIGNAL(triggered()), SLOT(createGroup())); 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->actionEntryAddToAgent->setVisible(enabled);
m_ui->actionEntryRemoveFromAgent->setVisible(enabled); m_ui->actionEntryRemoveFromAgent->setVisible(enabled);
m_ui->actionFlushSSHAgent->setEnabled(enabled); m_ui->actionClearSSHAgent->setEnabled(enabled);
m_ui->actionFlushSSHAgent->setVisible(enabled); m_ui->actionClearSSHAgent->setVisible(enabled);
} }
void MainWindow::showEntryContextMenu(const QPoint& globalPos) void MainWindow::showEntryContextMenu(const QPoint& globalPos)
@ -2161,7 +2161,7 @@ void MainWindow::initActionCollection()
// Tools Menu // Tools Menu
m_ui->actionPasswordGenerator, m_ui->actionPasswordGenerator,
#ifdef WITH_XC_SSHAGENT #ifdef WITH_XC_SSHAGENT
m_ui->actionFlushSSHAgent, m_ui->actionClearSSHAgent,
#endif #endif
m_ui->actionSettings, m_ui->actionSettings,
// View Menu // View Menu

View File

@ -372,7 +372,7 @@
<string>&amp;Tools</string> <string>&amp;Tools</string>
</property> </property>
<addaction name="actionPasswordGenerator"/> <addaction name="actionPasswordGenerator"/>
<addaction name="actionFlushSSHAgent"/> <addaction name="actionClearSSHAgent"/>
<addaction name="actionSettings"/> <addaction name="actionSettings"/>
</widget> </widget>
<widget class="QMenu" name="menuView"> <widget class="QMenu" name="menuView">
@ -1395,12 +1395,12 @@
<string>Import…</string> <string>Import…</string>
</property> </property>
</action> </action>
<action name="actionFlushSSHAgent"> <action name="actionClearSSHAgent">
<property name="text"> <property name="text">
<string>Flush SSH Agent</string> <string>Clear SSH Agent</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Flush identities like ssh-add -D</string> <string>Clear all identities like ssh-add -D</string>
</property> </property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::TextHeuristicRole</enum> <enum>QAction::TextHeuristicRole</enum>

View File

@ -565,7 +565,7 @@ void EditEntryWidget::setupSSHAgent()
connect(m_sshAgentUi->browseButton, &QPushButton::clicked, this, &EditEntryWidget::browsePrivateKey); connect(m_sshAgentUi->browseButton, &QPushButton::clicked, this, &EditEntryWidget::browsePrivateKey);
connect(m_sshAgentUi->addToAgentButton, &QPushButton::clicked, this, &EditEntryWidget::addKeyToAgent); connect(m_sshAgentUi->addToAgentButton, &QPushButton::clicked, this, &EditEntryWidget::addKeyToAgent);
connect(m_sshAgentUi->removeFromAgentButton, &QPushButton::clicked, this, &EditEntryWidget::removeKeyFromAgent); 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->decryptButton, &QPushButton::clicked, this, &EditEntryWidget::decryptPrivateKey);
connect(m_sshAgentUi->copyToClipboardButton, &QPushButton::clicked, this, &EditEntryWidget::copyPublicKey); connect(m_sshAgentUi->copyToClipboardButton, &QPushButton::clicked, this, &EditEntryWidget::copyPublicKey);
connect(m_sshAgentUi->generateButton, &QPushButton::clicked, this, &EditEntryWidget::generatePrivateKey); connect(m_sshAgentUi->generateButton, &QPushButton::clicked, this, &EditEntryWidget::generatePrivateKey);
@ -679,7 +679,7 @@ void EditEntryWidget::updateSSHAgentKeyInfo()
if (sshAgent()->isAgentRunning()) { if (sshAgent()->isAgentRunning()) {
m_sshAgentUi->addToAgentButton->setEnabled(true); m_sshAgentUi->addToAgentButton->setEnabled(true);
m_sshAgentUi->removeFromAgentButton->setEnabled(true); m_sshAgentUi->removeFromAgentButton->setEnabled(true);
m_sshAgentUi->flushAgentButton->setEnabled(true); m_sshAgentUi->clearAgentButton->setEnabled(true);
sshAgent()->setAutoRemoveOnLock(key, m_sshAgentUi->removeKeyFromAgentCheckBox->isChecked()); 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); showMessage(sshAgent()->errorString(), MessageWidget::Error);
return; return;
} }

View File

@ -122,7 +122,7 @@ private slots:
void browsePrivateKey(); void browsePrivateKey();
void addKeyToAgent(); void addKeyToAgent();
void removeKeyFromAgent(); void removeKeyFromAgent();
void flushAgent(); void clearAgent();
void decryptPrivateKey(); void decryptPrivateKey();
void copyPublicKey(); void copyPublicKey();
void generatePrivateKey(); void generatePrivateKey();

View File

@ -155,9 +155,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="flushAgentButton"> <widget class="QPushButton" name="clearAgentButton">
<property name="text"> <property name="text">
<string>Flush agent</string> <string>Clear agent</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -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 * 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 * 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 * @return true on success
*/ */
bool SSHAgent::flushAllAgentIdentities() bool SSHAgent::clearAllAgentIdentities()
{ {
if (!isAgentRunning()) { if (!isAgentRunning()) {
m_error = tr("No agent running, cannot remove identity."); m_error = tr("No agent running, cannot remove identity.");
@ -385,7 +385,7 @@ bool SSHAgent::flushAllAgentIdentities()
BinaryStream request(&requestData); BinaryStream request(&requestData);
// Same request order as OpenBSD ssh-add: useful? // 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)) { if (!sendMessage(requestData, responseData)) {
m_error = tr("Failed to remove all SSH identities from agent."); m_error = tr("Failed to remove all SSH identities from agent.");
@ -396,10 +396,10 @@ bool SSHAgent::flushAllAgentIdentities()
responseData.clear(); responseData.clear();
// Same request order as OpenBSD ssh-add: useful? // 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 // ignore error-code for ssh1
sendMessage(requestData, responseData); sendMessage(requestData, responseData);
m_error = tr("All SSH identities removed from agent."); m_error = tr("All SSH identities removed from agent.");
return ret; return ret;

View File

@ -56,7 +56,7 @@ public:
bool checkIdentity(const OpenSSHKey& key, bool& loaded); bool checkIdentity(const OpenSSHKey& key, bool& loaded);
bool removeIdentity(OpenSSHKey& key); bool removeIdentity(OpenSSHKey& key);
void removeAllIdentities(); void removeAllIdentities();
bool flushAllAgentIdentities(); bool clearAllAgentIdentities();
void setAutoRemoveOnLock(const OpenSSHKey& key, bool autoRemove); void setAutoRemoveOnLock(const OpenSSHKey& key, bool autoRemove);
signals: signals: