Commit 2914efb4 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Fix enable state of commands that need access to the secret key data

Introduce a new restriction flag for commands that need the secret key
data. Use this new flag instead of the NeedSecretKey flag for the
commands for creating a backup of a secret key on paper or on disk.

GnuPG-bug-id: 5956
parent 396629a2
Pipeline #172203 passed with stage
in 2 minutes and 28 seconds
......@@ -62,6 +62,8 @@ public:
MustBeTrustedRoot = 0x0400 | MustBeRoot,
MustBeUntrustedRoot = 0x0800 | MustBeRoot,
NeedSecretKeyData = 0x1000,
_AllRestrictions_Helper,
AllRestrictions = 2 * (_AllRestrictions_Helper - 1) - 1
};
......
......@@ -32,7 +32,7 @@ public:
static Restrictions restrictions()
{
return OnlyOneKey | NeedSecretKey | MustBeOpenPGP;
return OnlyOneKey | NeedSecretKeyData | MustBeOpenPGP;
}
protected Q_SLOTS:
......
......@@ -27,7 +27,7 @@ public:
/* reimp */ static Restrictions restrictions()
{
return OnlyOneKey | NeedSecretKey;
return OnlyOneKey | NeedSecretKeyData;
}
private:
......
......@@ -68,6 +68,7 @@
#include <QAction>
#include <algorithm>
#include <iterator>
using namespace Kleo;
using namespace Kleo::Commands;
......@@ -764,6 +765,10 @@ Command::Restrictions KeyListController::Private::calculateRestrictionsMask(cons
result |= Command::MustNotBeSecretKey;
}
if (std::all_of(std::begin(keys), std::end(keys), [](const auto &k) { return k.subkey(0).isSecret() && !k.subkey(0).isCardKey(); })) {
result |= Command::NeedSecretKeyData;
}
if (std::all_of(keys.cbegin(), keys.cend(), [](const Key &key) { return key.protocol() == OpenPGP; })) {
result |= Command::MustBeOpenPGP;
} else if (std::all_of(keys.cbegin(), keys.cend(), [](const Key &key) { return key.protocol() == CMS; })) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment