diff options
Diffstat (limited to 'src/core/GpgContext.cpp')
-rw-r--r-- | src/core/GpgContext.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/GpgContext.cpp b/src/core/GpgContext.cpp index 28857d32..7ebd9fa9 100644 --- a/src/core/GpgContext.cpp +++ b/src/core/GpgContext.cpp @@ -102,6 +102,9 @@ GpgContext::GpgContext(const GpgContextInitArgs &args) : args_(args) { find_openpgp = true; info_.AppPath = engine_info->file_name; info_.GnupgVersion = engine_info->version; + info_.DatabasePath = std::string(engine_info->home_dir == nullptr + ? "default" + : engine_info->home_dir); break; case GPGME_PROTOCOL_CMS: find_cms = true; @@ -128,6 +131,16 @@ GpgContext::GpgContext(const GpgContextInitArgs &args) : args_(args) { engine_info = engine_info->next; } + // set custom key db path + if (!args.db_path.empty()) { + info_.DatabasePath = args.db_path; + auto err = gpgme_ctx_set_engine_info(_ctx_ref.get(), GPGME_PROTOCOL_OpenPGP, + info_.AppPath.c_str(), + info_.DatabasePath.c_str()); + LOG(INFO) << "ctx set custom key db path:" << info_.DatabasePath; + assert(check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR); + } + // conditional check if ((info_.GnupgVersion >= "2.0.0" && find_gpgconf && find_openpgp && find_cms) || |