diff options
author | Saturneric <[email protected]> | 2023-02-06 13:24:14 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2023-02-06 13:24:14 +0000 |
commit | c8cf22bebe27f344d958950a682f7df8452ee78c (patch) | |
tree | 0a2df141212f7763fdc17ec0f7030c08e7d66b07 | |
parent | fix: continue to solve a compile issue (diff) | |
download | GpgFrontend-c8cf22bebe27f344d958950a682f7df8452ee78c.tar.gz GpgFrontend-c8cf22bebe27f344d958950a682f7df8452ee78c.zip |
feat: add a custom pinentry hook for sandbox mode in macOS
-rw-r--r-- | src/core/GpgContext.cpp | 22 | ||||
-rw-r--r-- | src/core/GpgContext.h | 14 |
2 files changed, 33 insertions, 3 deletions
diff --git a/src/core/GpgContext.cpp b/src/core/GpgContext.cpp index bfc5b556..82e9394d 100644 --- a/src/core/GpgContext.cpp +++ b/src/core/GpgContext.cpp @@ -197,6 +197,11 @@ void GpgContext::init_ctx() { if (info_.GnupgVersion >= "2.1.0") SetPassphraseCb(test_passphrase_cb); gpgme_set_status_cb(*this, test_status_cb, nullptr); } + +#if defined(RELEASE) && defined(MACOS) + // running in sandbox + SetPassphraseCb(custom_passphrase_cb); +#endif } bool GpgContext::good() const { return good_; } @@ -229,6 +234,14 @@ gpgme_error_t GpgContext::test_passphrase_cb(void *opaque, const char *uid_hint, return off == pass_len ? 0 : gpgme_error_from_errno(errno); } +gpgme_error_t GpgContext::custom_passphrase_cb(void *opaque, + const char *uid_hint, + const char *passphrase_info, + int last_was_bad, int fd) { + // TODO + return 0; +} + gpgme_error_t GpgContext::test_status_cb(void *hook, const char *keyword, const char *args) { SPDLOG_INFO("keyword {}", keyword); @@ -289,7 +302,8 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) { if (exit_code != 0) { SPDLOG_ERROR( - "gpgconf execute error, process stderr: {} process stdout: {}", + "gpgconf execute error, process stderr: {} process stdout: " + "{}", p_err, p_out); return; } @@ -328,7 +342,8 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) { if (exit_code != 0) { SPDLOG_ERROR( - "gpgconf execute error, process stderr: {} , process stdout:", + "gpgconf execute error, process stderr: {} , process " + "stdout:", p_err, p_out); return; } @@ -371,7 +386,8 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) { if (exit_code != 0) { SPDLOG_ERROR( - "gpgconf execute error, process stderr: {} , process stdout:", + "gpgconf execute error, process stderr: {} , process " + "stdout:", p_err, p_out); return; } diff --git a/src/core/GpgContext.h b/src/core/GpgContext.h index 12a0fe1c..bc4b615b 100644 --- a/src/core/GpgContext.h +++ b/src/core/GpgContext.h @@ -143,6 +143,20 @@ class GPGFRONTEND_CORE_EXPORT GpgContext /** * @brief * + * @param opaque + * @param uid_hint + * @param passphrase_info + * @param last_was_bad + * @param fd + * @return gpgme_error_t + */ + static gpgme_error_t custom_passphrase_cb(void* opaque, const char* uid_hint, + const char* passphrase_info, + int last_was_bad, int fd); + + /** + * @brief + * * @param hook * @param keyword * @param args |