--- /dev/null
+Return-Path: <dkg@fifthhorseman.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 6D26A6DE1921\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 19:40:10 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.035\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.035 tagged_above=-999 required=5\r
+ tests=[AWL=-0.035] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Cnv3TRljKKiT for <notmuch@notmuchmail.org>;\r
+ Wed, 9 Dec 2015 19:40:07 -0800 (PST)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 476906DE1601\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 19:40:05 -0800 (PST)\r
+Received: from fifthhorseman.net (unknown [38.109.115.130])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 422D8F987\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 22:40:04 -0500 (EST)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id B8A64210BB; Wed, 9 Dec 2015 22:40:03 -0500 (EST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH 6/9] search for a reasonable gpg implementation\r
+Date: Wed, 9 Dec 2015 22:39:43 -0500\r
+Message-Id: <1449718786-28000-7-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.6.2\r
+In-Reply-To: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 10 Dec 2015 03:40:11 -0000\r
+\r
+When the notmuch database needs to find gpg, have it search reasonable\r
+paths first.\r
+---\r
+ lib/database.cc | 13 ++++++++++++-\r
+ 1 file changed, 12 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 62bc6d9..d0e8800 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -2393,6 +2393,17 @@ _notmuch_database_link_message (notmuch_database_t *notmuch,\r
+ return status;\r
+ }\r
+ \r
++static const char*\r
++_notmuch_database_get_gpg_path (notmuch_database_t *notmuch)\r
++{\r
++#define try_gpg_path(z) if (!access(z, X_OK)) return z\r
++ try_gpg_path("/usr/bin/gpg2");\r
++ try_gpg_path("/bin/gpg2");\r
++ try_gpg_path("/usr/bin/gpg");\r
++ try_gpg_path("/bin/gpg");\r
++ return NULL;\r
++}\r
++\r
+ notmuch_private_status_t\r
+ _notmuch_database_get_crypto_for_protocol (notmuch_database_t *notmuch,\r
+ const char *protocol,\r
+@@ -2414,7 +2425,7 @@ _notmuch_database_get_crypto_for_protocol (notmuch_database_t *notmuch,\r
+ * here? how would this config get into the library? Is\r
+ * this an option we can set on the database object? Or\r
+ * elsewhere? */\r
+- notmuch->gpg_crypto_ctx = g_mime_gpg_context_new (NULL, "gpg");\r
++ notmuch->gpg_crypto_ctx = g_mime_gpg_context_new (NULL, _notmuch_database_get_gpg_path(notmuch));\r
+ if (! notmuch->gpg_crypto_ctx)\r
+ return NOTMUCH_PRIVATE_STATUS_FAILED_CRYPTO_CONTEXT_CREATION;\r
+ \r
+-- \r
+2.6.2\r
+\r