diff options
author | defanor <defanor@uberspace.net> | 2021-02-07 17:04:57 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2021-02-07 17:04:57 +0300 |
commit | 110d11fac989d27d72486e4eb7cca46b28f46ce2 (patch) | |
tree | 227c93b486db229cc6d55ff5e9f6c049623474e1 | |
parent | adc336685e0167a9ba0919d48854b13137bb4055 (diff) |
Add the rexmpp_openpgp_set_home_dir utility function
-rw-r--r-- | src/rexmpp_openpgp.c | 19 | ||||
-rw-r--r-- | src/rexmpp_openpgp.h | 10 |
2 files changed, 25 insertions, 4 deletions
diff --git a/src/rexmpp_openpgp.c b/src/rexmpp_openpgp.c index 8065aa7..3c584d5 100644 --- a/src/rexmpp_openpgp.c +++ b/src/rexmpp_openpgp.c @@ -33,10 +33,6 @@ Possible future improvements: automatically, encrypt messages opportunistically (as the XEP suggests). -- Optionally use a separate (possibly per-JID) keyring (though it can - be set by a client application already, right after rexmpp - initialisation). - - Upload keys signed with other keys (instead of exporting with `GPGME_EXPORT_MODE_MINIMAL`): for key rollover, for helping to extend trust to all the keys once some of them are verified in @@ -711,3 +707,18 @@ char *rexmpp_openpgp_encrypt_sign (rexmpp_t *s, return cipher_base64; } + +rexmpp_err_t rexmpp_openpgp_set_home_dir (rexmpp_t *s, const char *home_dir) { + gpgme_engine_info_t engine_info; + gpgme_error_t err; + engine_info = gpgme_ctx_get_engine_info(s->pgp_ctx); + err = gpgme_ctx_set_engine_info(s->pgp_ctx, engine_info->protocol, + engine_info->file_name, + home_dir); + if (gpg_err_code(err) != GPG_ERR_NO_ERROR) { + rexmpp_log(s, LOG_ERR, "Failed to set home directory: %s", + gpgme_strerror(err)); + return REXMPP_E_PGP; + } + return REXMPP_SUCCESS; +} diff --git a/src/rexmpp_openpgp.h b/src/rexmpp_openpgp.h index 13b80f7..1835de7 100644 --- a/src/rexmpp_openpgp.h +++ b/src/rexmpp_openpgp.h @@ -30,4 +30,14 @@ char *rexmpp_openpgp_encrypt_sign (rexmpp_t *s, xmlNodePtr payload, const char **recipients); +/** + @brief An utility function for setting GPG home directory. An + appropriate time to call it is right after rexmpp_init. + @param[in] s ::rexmpp + @param[in] home_dir Path to the home directory. + @returns ::REXMPP_E_PGP or ::REXMPP_SUCCESS +*/ +rexmpp_err_t rexmpp_openpgp_set_home_dir (rexmpp_t *s, const char *home_dir); + + #endif |