mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-10 03:38:33 -05:00
Prevent SSH Agent from using entries in the recycle bin
* Fixes #10516 * Also cleanup Group::isRecycled() code a little
This commit is contained in:
parent
8723b7f6a4
commit
d87f0030a3
@ -223,17 +223,17 @@ Entry* Group::lastTopVisibleEntry() const
|
|||||||
bool Group::isRecycled() const
|
bool Group::isRecycled() const
|
||||||
{
|
{
|
||||||
auto group = this;
|
auto group = this;
|
||||||
if (!group->database() || !group->m_db->metadata()) {
|
auto db = group->database();
|
||||||
return false;
|
if (db) {
|
||||||
|
auto recycleBin = db->metadata()->recycleBin();
|
||||||
|
do {
|
||||||
|
if (group == recycleBin) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
group = group->m_parent;
|
||||||
|
} while (group);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
|
||||||
if (group == group->m_db->metadata()->recycleBin()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
group = group->m_parent;
|
|
||||||
} while (group);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ void SSHAgent::setAutoRemoveOnLock(const OpenSSHKey& key, bool autoRemove)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSHAgent::databaseLocked(QSharedPointer<Database> db)
|
void SSHAgent::databaseLocked(const QSharedPointer<Database>& db)
|
||||||
{
|
{
|
||||||
if (!db) {
|
if (!db) {
|
||||||
return;
|
return;
|
||||||
@ -508,20 +508,20 @@ void SSHAgent::databaseLocked(QSharedPointer<Database> db)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSHAgent::databaseUnlocked(QSharedPointer<Database> db)
|
void SSHAgent::databaseUnlocked(const QSharedPointer<Database>& db)
|
||||||
{
|
{
|
||||||
if (!db || !isEnabled()) {
|
if (!db || !isEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry* e : db->rootGroup()->entriesRecursive()) {
|
for (auto entry : db->rootGroup()->entriesRecursive()) {
|
||||||
if (db->metadata()->recycleBinEnabled() && e->group() == db->metadata()->recycleBin()) {
|
if (entry->isRecycled()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeeAgentSettings settings;
|
KeeAgentSettings settings;
|
||||||
|
|
||||||
if (!settings.fromEntry(e)) {
|
if (!settings.fromEntry(entry)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,7 +531,7 @@ void SSHAgent::databaseUnlocked(QSharedPointer<Database> db)
|
|||||||
|
|
||||||
OpenSSHKey key;
|
OpenSSHKey key;
|
||||||
|
|
||||||
if (!settings.toOpenSSHKey(e, key, true)) {
|
if (!settings.toOpenSSHKey(entry, key, true)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +63,8 @@ signals:
|
|||||||
void enabledChanged(bool enabled);
|
void enabledChanged(bool enabled);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void databaseLocked(QSharedPointer<Database> db);
|
void databaseLocked(const QSharedPointer<Database>& db);
|
||||||
void databaseUnlocked(QSharedPointer<Database> db);
|
void databaseUnlocked(const QSharedPointer<Database>& db);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const quint8 SSH_AGENT_FAILURE = 5;
|
const quint8 SSH_AGENT_FAILURE = 5;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user