Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouib <code@louib.net>2022-10-02 20:28:12 +0300
committerJonathan White <support@dmapps.us>2022-10-04 05:19:35 +0300
commit6cf9c7c90c86353b9142751c000928b6e5578415 (patch)
tree2cca52c554469d5fe546b1a3b546ddb05bac5fd9
parent087de27c3c5e8dc4472ca9cddc236b6601f32632 (diff)
Fix being unable to unset to just a ChallengeResponse keycli_db_edit
-rw-r--r--docs/man/keepassxc-cli.1.adoc4
-rw-r--r--src/cli/DatabaseEdit.cpp6
-rw-r--r--src/keys/CompositeKey.cpp10
-rw-r--r--src/keys/CompositeKey.h1
4 files changed, 16 insertions, 5 deletions
diff --git a/docs/man/keepassxc-cli.1.adoc b/docs/man/keepassxc-cli.1.adoc
index c3a5fa54e..f5a5ac55a 100644
--- a/docs/man/keepassxc-cli.1.adoc
+++ b/docs/man/keepassxc-cli.1.adoc
@@ -159,7 +159,7 @@ It provides the ability to query and modify the entries of a KeePass database, d
*--no-password*::
Deactivates the password key for the database.
-*-y*, *--yubikey* <__slot__>::
+*-y*, *--yubikey* <__slot[:serial]__>::
Specifies a yubikey slot for unlocking the database.
In a merge operation this option is used to specify the YubiKey slot for the first database.
@@ -182,7 +182,7 @@ It provides the ability to query and modify the entries of a KeePass database, d
*--no-password-from*::
Deactivates password key for the database to merge from.
-*--yubikey-from* <__slot__>::
+*--yubikey-from* <__slot[:serial]__>::
YubiKey slot for the second database.
*-s*, *--same-credentials*::
diff --git a/src/cli/DatabaseEdit.cpp b/src/cli/DatabaseEdit.cpp
index 1409bcf05..f5ca4ef2e 100644
--- a/src/cli/DatabaseEdit.cpp
+++ b/src/cli/DatabaseEdit.cpp
@@ -110,7 +110,7 @@ QSharedPointer<CompositeKey> DatabaseEdit::getNewDatabaseKey(QSharedPointer<Data
auto currentPasswordKey = database->key()->getKey(PasswordKey::UUID);
auto currentFileKey = database->key()->getKey(FileKey::UUID);
- auto currentChallengeResponseKey = database->key()->getKey(ChallengeResponseKey::UUID);
+ auto currentChallengeResponseKey = database->key()->getChallengeResponseKey(ChallengeResponseKey::UUID);
if (removePassword && currentPasswordKey.isNull()) {
err << QObject::tr("Cannot remove password: The database does not have a password.") << endl;
@@ -162,10 +162,10 @@ QSharedPointer<CompositeKey> DatabaseEdit::getNewDatabaseKey(QSharedPointer<Data
}
if (!currentChallengeResponseKey.isNull()) {
- newDatabaseKey->addKey(currentChallengeResponseKey);
+ newDatabaseKey->addChallengeResponseKey(currentChallengeResponseKey);
}
- if (newDatabaseKey->keys().isEmpty()) {
+ if (newDatabaseKey->keys().isEmpty() && newDatabaseKey->challengeResponseKeys().isEmpty()) {
err << QObject::tr("Cannot remove all the keys from a database.") << endl;
return {};
}
diff --git a/src/keys/CompositeKey.cpp b/src/keys/CompositeKey.cpp
index 34620b70d..705491667 100644
--- a/src/keys/CompositeKey.cpp
+++ b/src/keys/CompositeKey.cpp
@@ -181,6 +181,16 @@ QSharedPointer<Key> CompositeKey::getKey(const QUuid keyId) const
return key;
}
}
+ return {};
+}
+
+/**
+ * Get the \link ChallengeResponseKey with the specified ID.
+ *
+ * @param keyId the ID of the key to get.
+ */
+QSharedPointer<ChallengeResponseKey> CompositeKey::getChallengeResponseKey(const QUuid keyId) const
+{
for (const QSharedPointer<ChallengeResponseKey>& key : m_challengeResponseKeys) {
if (key->uuid() == keyId) {
return key;
diff --git a/src/keys/CompositeKey.h b/src/keys/CompositeKey.h
index a519885b3..451f88e4f 100644
--- a/src/keys/CompositeKey.h
+++ b/src/keys/CompositeKey.h
@@ -44,6 +44,7 @@ public:
void addKey(const QSharedPointer<Key>& key);
QSharedPointer<Key> getKey(const QUuid keyType) const;
+ QSharedPointer<ChallengeResponseKey> getChallengeResponseKey(const QUuid keyType) const;
const QList<QSharedPointer<Key>>& keys() const;
void addChallengeResponseKey(const QSharedPointer<ChallengeResponseKey>& key);