[PATCH] cli: crypto: tell gmime to use gpg-agent
authorJani Nikula <jani@nikula.org>
Wed, 27 Feb 2013 07:40:38 +0000 (09:40 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:46 +0000 (09:53 -0800)
59/9fb633b79fc69c45a3c46b6353ceb6866e8e31 [new file with mode: 0644]

diff --git a/59/9fb633b79fc69c45a3c46b6353ceb6866e8e31 b/59/9fb633b79fc69c45a3c46b6353ceb6866e8e31
new file mode 100644 (file)
index 0000000..62c74d4
--- /dev/null
@@ -0,0 +1,106 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 13F50431FB6\r
+       for <notmuch@notmuchmail.org>; Tue, 26 Feb 2013 23:40:45 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 3M5rX3iSgsz1 for <notmuch@notmuchmail.org>;\r
+       Tue, 26 Feb 2013 23:40:42 -0800 (PST)\r
+Received: from mail-la0-f49.google.com (mail-la0-f49.google.com\r
+       [209.85.215.49]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 952E7431FAF\r
+       for <notmuch@notmuchmail.org>; Tue, 26 Feb 2013 23:40:42 -0800 (PST)\r
+Received: by mail-la0-f49.google.com with SMTP id fs13so238240lab.22\r
+       for <notmuch@notmuchmail.org>; Tue, 26 Feb 2013 23:40:41 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=x-received:from:to:cc:subject:date:message-id:x-mailer\r
+       :x-gm-message-state;\r
+       bh=Pnq6QqfTGumUqVTA7gVHUOCbgSILN8gWFD3l82XncYM=;\r
+       b=P67uL4UCaXmkMGg1/E7n3pp2W5Pr9QjZ3AjRXsKBb+fSYS7QnhMZr5ja/p+AgHxCCb\r
+       4QzxFqyqypxV23BuWrW/fBP4vE8dcBo6XFx7LzOO7X17rUrOMCC9FEGPsYMAHa7ye2lN\r
+       BY6tzjSO4YjHKM+dp0nrdSyR6o0XXT/8Yd/Gpuyuti4GUESIjSCe7cDqfcvnJ9cfMNPH\r
+       wZwpNqagu8Vqa324cA+70a7Y5O1W3GaRY83B5FBGUm/QtBEA21mD997L9Jybg32Hcb1p\r
+       IefgpuXsJbDpqWfGtdreJ58jIp/gjOu9X80DgBu8fPXZ33nz8rMhvD4wVMWjDzcgN1RZ\r
+       mC3g==\r
+X-Received: by 10.152.134.164 with SMTP id pl4mr1025475lab.54.1361950839666;\r
+       Tue, 26 Feb 2013 23:40:39 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.\r
+       [80.223.81.27])\r
+       by mx.google.com with ESMTPS id hk10sm2100199lab.4.2013.02.26.23.40.35\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Tue, 26 Feb 2013 23:40:37 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] cli: crypto: tell gmime to use gpg-agent\r
+Date: Wed, 27 Feb 2013 09:40:38 +0200\r
+Message-Id: <1361950838-22919-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.10.4\r
+X-Gm-Message-State:\r
+ ALoCoQnNLiOnZEn2DdHQUwi+l4xEFSpqWE/7bj5b5CIG7EDIOoLfJmh421EMT8FiVgQMT+ybYCRG\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 27 Feb 2013 07:40:45 -0000\r
+\r
+For decryption, we expect there to be a functioning gpg-agent, and we\r
+want gpg to talk to it for any needed credentials. There's a gmime\r
+function to declare that: g_mime_gpg_context_set_use_agent() [1], [2].\r
+Start using it.\r
+\r
+I had gpg-agent running, but gpg "use-agent" configuration option\r
+disabled. This resulted in an error message from 'notmuch show':\r
+\r
+  Failed to decrypt part: Canceled.\r
+\r
+and json had this:\r
+\r
+  "encstatus" : [ { "status" : "bad" } ]\r
+\r
+One could argue the "use-agent" option should be enabled, but I'd like\r
+to use the agent only as a last resort. I think that's irrelevant\r
+though. There's a gmime function to declare what we expect, so we\r
+should use it. Conveniently it also fixes the problem in a user\r
+friendly way.\r
+\r
+[1] http://git.gnome.org/browse/gmime/commit/?id=ed985397843a9da3745a8b5de3d1d652acd24724\r
+[2] https://bugzilla.gnome.org/show_bug.cgi?id=651826\r
+---\r
+ crypto.c |    3 +++\r
+ 1 file changed, 3 insertions(+)\r
+\r
+diff --git a/crypto.c b/crypto.c\r
+index fbe5aeb..cb361e1 100644\r
+--- a/crypto.c\r
++++ b/crypto.c\r
+@@ -45,6 +45,9 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)\r
+           g_object_unref (session);\r
+ #endif\r
+           if (crypto->gpgctx) {\r
++#ifdef GMIME_ATLEAST_26\r
++              g_mime_gpg_context_set_use_agent ((GMimeGpgContext*) crypto->gpgctx, TRUE);\r
++#endif\r
+               g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) crypto->gpgctx, FALSE);\r
+           } else {\r
+               fprintf (stderr, "Failed to construct gpg context.\n");\r
+-- \r
+1.7.10.4\r
+\r