mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-12-02 14:52:55 -08:00
Implement function to clear all ssh-agent identities (#10649)
Fixes #8346 --------- Co-authored-by: Jonathan White <[email protected]>
This commit is contained in:
9 files changed
+113
-2
No files matched your search
@@ -363,6 +363,48 @@ bool SSHAgent::removeIdentity(OpenSSHKey& key)
|
||||
return sendMessage(requestData, responseData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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::clearAllAgentIdentities()
|
||||
{
|
||||
if (!isAgentRunning()) {
|
||||
m_error = tr("No agent running, cannot remove identity.");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
QByteArray requestData;
|
||||
QByteArray responseData;
|
||||
BinaryStream request(&requestData);
|
||||
|
||||
// SSH2 Identity Removal
|
||||
request.write(SSH2_AGENTC_REMOVE_ALL_IDENTITIES);
|
||||
|
||||
if (!sendMessage(requestData, responseData)) {
|
||||
m_error = tr("Failed to remove all SSH identities from agent.");
|
||||
ret = false;
|
||||
}
|
||||
|
||||
request.flush();
|
||||
responseData.clear();
|
||||
|
||||
// SSH1 Identity Removal
|
||||
request.write(SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES);
|
||||
|
||||
// ignore error-code for ssh1
|
||||
sendMessage(requestData, responseData);
|
||||
|
||||
m_error = tr("All SSH identities removed from agent.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of identities from the SSH agent.
|
||||
*
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
bool checkIdentity(const OpenSSHKey& key, bool& loaded);
|
||||
bool removeIdentity(OpenSSHKey& key);
|
||||
void removeAllIdentities();
|
||||
bool clearAllAgentIdentities();
|
||||
void setAutoRemoveOnLock(const OpenSSHKey& key, bool autoRemove);
|
||||
|
||||
signals:
|
||||
@@ -74,6 +75,8 @@ private:
|
||||
const quint8 SSH_AGENTC_ADD_IDENTITY = 17;
|
||||
const quint8 SSH_AGENTC_REMOVE_IDENTITY = 18;
|
||||
const quint8 SSH_AGENTC_ADD_ID_CONSTRAINED = 25;
|
||||
const quint8 SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES = 9;
|
||||
const quint8 SSH2_AGENTC_REMOVE_ALL_IDENTITIES = 19;
|
||||
|
||||
const quint8 SSH_AGENT_CONSTRAIN_LIFETIME = 1;
|
||||
const quint8 SSH_AGENT_CONSTRAIN_CONFIRM = 2;
|
||||
|
||||
Reference in new issue
Block a user