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