From: Pierre Habouzit Date: Tue, 3 Apr 2007 00:42:55 +0000 (+0200) Subject: workaround X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=a6352753715bbffc5c11af249756af7cbb135856;p=apps%2Fmadmutt.git workaround Signed-off-by: Pierre Habouzit --- diff --git a/lib-crypt/crypt-gpgme.c b/lib-crypt/crypt-gpgme.c index c6142af..caba821 100644 --- a/lib-crypt/crypt-gpgme.c +++ b/lib-crypt/crypt-gpgme.c @@ -487,6 +487,34 @@ static char *data_object_to_tempfile (gpgme_data_t data, FILE ** ret_fp) } +/* FIXME: stolen from gpgme to avoid "ambiguous identity" errors */ +static gpgme_error_t +gpgme_get_key2 (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key, + int secret) +{ + gpgme_ctx_t listctx; + gpgme_error_t err; + gpgme_key_t key; + + if (!ctx || !r_key || !fpr) + return gpg_error (GPG_ERR_INV_VALUE); + + if (strlen (fpr) < 8) /* We have at least a key ID. */ + return gpg_error (GPG_ERR_INV_VALUE); + + /* FIXME: We use our own context because we have to avoid the user's + I/O callback handlers. */ + err = gpgme_new (&listctx); + if (err) + return err; + gpgme_set_protocol (listctx, gpgme_get_protocol (ctx)); + err = gpgme_op_keylist_start (listctx, fpr, secret); + if (!err) + err = gpgme_op_keylist_next (listctx, r_key); + gpgme_release (listctx); + return err; +} + /* Create a GpgmeRecipientSet from the keys in the string KEYLIST. The keys must be space delimited. */ static gpgme_key_t *create_recipient_set (const char *keylist, @@ -519,13 +547,13 @@ static gpgme_key_t *create_recipient_set (const char *keylist, key. */ buf[i - 1] = 0; - err = gpgme_get_key (context, buf, &key, 0); + err = gpgme_get_key2 (context, buf, &key, 0); if (!err) key->uids->validity = GPGME_VALIDITY_FULL; buf[i - 1] = '!'; } else - err = gpgme_get_key (context, buf, &key, 0); + err = gpgme_get_key2 (context, buf, &key, 0); if (!err) { p_realloc(&rset, rset_n + 1); @@ -1115,7 +1143,7 @@ static int show_one_sig_status (gpgme_ctx_t ctx, int idx, STATE * s) if (gpg_err_code (sig->status) != GPG_ERR_NO_ERROR) anybad = 1; - err = gpgme_get_key (ctx, fpr, &key, 0); /* secret key? */ + err = gpgme_get_key2 (ctx, fpr, &key, 0); /* secret key? */ if (!err) { uid = (key->uids && key->uids->uid) ? key->uids->uid : "[?]"; if (!signature_key)