From: Tomi Ollila Date: Wed, 27 Feb 2013 08:45:28 +0000 (+0200) Subject: Re: [PATCH] cli: crypto: tell gmime to use gpg-agent X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=67fed4ffd9ff9412ef88977481a1ef22bff46fda;p=notmuch-archives.git Re: [PATCH] cli: crypto: tell gmime to use gpg-agent --- diff --git a/21/5b42cff5ad6366bc411a6f581d212ef0027a8f b/21/5b42cff5ad6366bc411a6f581d212ef0027a8f new file mode 100644 index 000000000..9a28a513a --- /dev/null +++ b/21/5b42cff5ad6366bc411a6f581d212ef0027a8f @@ -0,0 +1,99 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 3A2E1431FB6 + for ; Wed, 27 Feb 2013 00:45:43 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id Yw73fe-1ICYf for ; + Wed, 27 Feb 2013 00:45:41 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id C40EE431FAF + for ; Wed, 27 Feb 2013 00:45:41 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 15572100044; + Wed, 27 Feb 2013 10:45:29 +0200 (EET) +From: Tomi Ollila +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [PATCH] cli: crypto: tell gmime to use gpg-agent +In-Reply-To: <1361950838-22919-1-git-send-email-jani@nikula.org> +References: <1361950838-22919-1-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.15.2+45~g5d28a00 (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 27 Feb 2013 08:45:43 -0000 + +On Wed, Feb 27 2013, Jani Nikula wrote: + +> For decryption, we expect there to be a functioning gpg-agent, and we +> want gpg to talk to it for any needed credentials. There's a gmime +> function to declare that: g_mime_gpg_context_set_use_agent() [1], [2]. +> Start using it. +> +> I had gpg-agent running, but gpg "use-agent" configuration option +> disabled. This resulted in an error message from 'notmuch show': +> +> Failed to decrypt part: Canceled. +> +> and json had this: +> +> "encstatus" : [ { "status" : "bad" } ] +> +> One could argue the "use-agent" option should be enabled, but I'd like +> to use the agent only as a last resort. I think that's irrelevant +> though. There's a gmime function to declare what we expect, so we +> should use it. Conveniently it also fixes the problem in a user +> friendly way. + +I agree fully. The code looks good to me. + +Tomi + +> +> [1] http://git.gnome.org/browse/gmime/commit/?id=ed985397843a9da3745a8b5de3d1d652acd24724 +> [2] https://bugzilla.gnome.org/show_bug.cgi?id=651826 +> --- +> crypto.c | 3 +++ +> 1 file changed, 3 insertions(+) +> +> diff --git a/crypto.c b/crypto.c +> index fbe5aeb..cb361e1 100644 +> --- a/crypto.c +> +++ b/crypto.c +> @@ -45,6 +45,9 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol) +> g_object_unref (session); +> #endif +> if (crypto->gpgctx) { +> +#ifdef GMIME_ATLEAST_26 +> + g_mime_gpg_context_set_use_agent ((GMimeGpgContext*) crypto->gpgctx, TRUE); +> +#endif +> g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) crypto->gpgctx, FALSE); +> } else { +> fprintf (stderr, "Failed to construct gpg context.\n"); +> -- +> 1.7.10.4