From 7b14a41ef4ce64ad323fb6325533a6acbe354fa8 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 27 Feb 2013 09:40:38 +0200 Subject: [PATCH] [PATCH] cli: crypto: tell gmime to use gpg-agent --- 59/9fb633b79fc69c45a3c46b6353ceb6866e8e31 | 106 ++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 59/9fb633b79fc69c45a3c46b6353ceb6866e8e31 diff --git a/59/9fb633b79fc69c45a3c46b6353ceb6866e8e31 b/59/9fb633b79fc69c45a3c46b6353ceb6866e8e31 new file mode 100644 index 000000000..62c74d464 --- /dev/null +++ b/59/9fb633b79fc69c45a3c46b6353ceb6866e8e31 @@ -0,0 +1,106 @@ +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 13F50431FB6 + for ; Tue, 26 Feb 2013 23:40:45 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 3M5rX3iSgsz1 for ; + Tue, 26 Feb 2013 23:40:42 -0800 (PST) +Received: from mail-la0-f49.google.com (mail-la0-f49.google.com + [209.85.215.49]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 952E7431FAF + for ; Tue, 26 Feb 2013 23:40:42 -0800 (PST) +Received: by mail-la0-f49.google.com with SMTP id fs13so238240lab.22 + for ; Tue, 26 Feb 2013 23:40:41 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=x-received:from:to:cc:subject:date:message-id:x-mailer + :x-gm-message-state; + bh=Pnq6QqfTGumUqVTA7gVHUOCbgSILN8gWFD3l82XncYM=; + b=P67uL4UCaXmkMGg1/E7n3pp2W5Pr9QjZ3AjRXsKBb+fSYS7QnhMZr5ja/p+AgHxCCb + 4QzxFqyqypxV23BuWrW/fBP4vE8dcBo6XFx7LzOO7X17rUrOMCC9FEGPsYMAHa7ye2lN + BY6tzjSO4YjHKM+dp0nrdSyR6o0XXT/8Yd/Gpuyuti4GUESIjSCe7cDqfcvnJ9cfMNPH + wZwpNqagu8Vqa324cA+70a7Y5O1W3GaRY83B5FBGUm/QtBEA21mD997L9Jybg32Hcb1p + IefgpuXsJbDpqWfGtdreJ58jIp/gjOu9X80DgBu8fPXZ33nz8rMhvD4wVMWjDzcgN1RZ + mC3g== +X-Received: by 10.152.134.164 with SMTP id pl4mr1025475lab.54.1361950839666; + Tue, 26 Feb 2013 23:40:39 -0800 (PST) +Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi. + [80.223.81.27]) + by mx.google.com with ESMTPS id hk10sm2100199lab.4.2013.02.26.23.40.35 + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Tue, 26 Feb 2013 23:40:37 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH] cli: crypto: tell gmime to use gpg-agent +Date: Wed, 27 Feb 2013 09:40:38 +0200 +Message-Id: <1361950838-22919-1-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 1.7.10.4 +X-Gm-Message-State: + ALoCoQnNLiOnZEn2DdHQUwi+l4xEFSpqWE/7bj5b5CIG7EDIOoLfJmh421EMT8FiVgQMT+ybYCRG +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 07:40:45 -0000 + +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. + +[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 + -- 2.26.2