aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg/GpgContext.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-01-17 11:39:47 +0000
committersaturneric <[email protected]>2024-01-17 11:39:47 +0000
commite352e8e6b8d03a24ef5d52eef3e4d370807b5bbd (patch)
tree9a59f0b573a845644afe4b8857a89c4b28bdcc0d /src/core/function/gpg/GpgContext.cpp
parentfix: solve the gnupg tab options info not shown issue (diff)
downloadGpgFrontend-e352e8e6b8d03a24ef5d52eef3e4d370807b5bbd.tar.gz
GpgFrontend-e352e8e6b8d03a24ef5d52eef3e4d370807b5bbd.zip
fix: find and slove some bugs
Diffstat (limited to 'src/core/function/gpg/GpgContext.cpp')
-rw-r--r--src/core/function/gpg/GpgContext.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp
index 0849f240..104e254f 100644
--- a/src/core/function/gpg/GpgContext.cpp
+++ b/src/core/function/gpg/GpgContext.cpp
@@ -38,8 +38,9 @@
#include "core/function/basic/GpgFunctionObject.h"
#include "core/model/GpgPassphraseContext.h"
#include "core/module/ModuleManager.h"
+#include "core/utils/CacheUtils.h"
#include "core/utils/GpgUtils.h"
-#include "utils/MemoryUtils.h"
+#include "core/utils/MemoryUtils.h"
#ifdef _WIN32
#include <windows.h>
@@ -108,11 +109,13 @@ class GpgContext::Impl {
static auto CustomPassphraseCb(void *hook, const char *uid_hint,
const char *passphrase_info, int prev_was_bad,
int fd) -> gpgme_error_t {
+ auto context_cache = GetCacheValue("PinentryContext");
+ bool ask_for_new = context_cache == "NEW_PASSPHRASE";
auto context =
QSharedPointer<GpgPassphraseContext>(new GpgPassphraseContext(
uid_hint != nullptr ? uid_hint : "",
passphrase_info != nullptr ? passphrase_info : "",
- prev_was_bad != 0));
+ prev_was_bad != 0, ask_for_new));
GF_CORE_LOG_DEBUG(
"custom passphrase cb called, uid: {}, info: {}, last_was_bad: {}",
@@ -129,6 +132,7 @@ class GpgContext::Impl {
context);
looper.exec();
+ ResetCacheValue("PinentryContext");
auto passphrase = context->GetPassphrase().toStdString();
auto passpahrase_size = passphrase.size();
GF_CORE_LOG_DEBUG("get passphrase from pinentry size: {}",