1 Return-Path: <tomi.ollila@iki.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 4CD1E6DE0A9A
\r
6 for <notmuch@notmuchmail.org>; Fri, 11 Dec 2015 14:02:24 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.699 tagged_above=-999 required=5 tests=[AWL=0.047,
\r
12 SPF_NEUTRAL=0.652] autolearn=disabled
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id lVfFyy-93Ylm for <notmuch@notmuchmail.org>;
\r
16 Fri, 11 Dec 2015 14:02:22 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by arlo.cworth.org (Postfix) with ESMTP id 85A476DE005F
\r
19 for <notmuch@notmuchmail.org>; Fri, 11 Dec 2015 14:02:22 -0800 (PST)
\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])
\r
21 by guru.guru-group.fi (Postfix) with ESMTP id 234BB100218;
\r
22 Sat, 12 Dec 2015 00:02:33 +0200 (EET)
\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
24 To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,
\r
25 Notmuch Mail <notmuch@notmuchmail.org>
\r
26 Subject: Re: [PATCH 7/9] add a gpg_path value for notmuch_database_t
\r
27 In-Reply-To: <1449718786-28000-8-git-send-email-dkg@fifthhorseman.net>
\r
28 References: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>
\r
29 <1449718786-28000-8-git-send-email-dkg@fifthhorseman.net>
\r
30 User-Agent: Notmuch/0.21+32~g73439f8 (http://notmuchmail.org) Emacs/24.3.1
\r
31 (x86_64-unknown-linux-gnu)
\r
32 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
33 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
34 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
35 Date: Sat, 12 Dec 2015 00:02:33 +0200
\r
36 Message-ID: <m21tas7ifa.fsf@guru.guru-group.fi>
\r
38 Content-Type: text/plain
\r
39 X-BeenThere: notmuch@notmuchmail.org
\r
40 X-Mailman-Version: 2.1.20
\r
42 List-Id: "Use and development of the notmuch mail system."
\r
43 <notmuch.notmuchmail.org>
\r
44 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
47 List-Post: <mailto:notmuch@notmuchmail.org>
\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
49 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
51 X-List-Received-Date: Fri, 11 Dec 2015 22:02:24 -0000
\r
53 On Thu, Dec 10 2015, Daniel Kahn Gillmor <dkg@fifthhorseman.net> wrote:
\r
55 > Exposing this to the user of the library lets the user point to
\r
56 > arbitrary gpg executables when trying to decrypt.
\r
58 > lib/database-private.h | 3 ++
\r
59 > lib/database.cc | 93 +++++++++++++++++++++++++++++++++++++++++++-------
\r
60 > lib/notmuch.h | 31 +++++++++++++++++
\r
61 > 3 files changed, 115 insertions(+), 12 deletions(-)
\r
66 > +static notmuch_bool_t
\r
67 > +_find_in_path(const char* path)
\r
69 > + char *c = NULL, *save = NULL, *tok;
\r
72 > + notmuch_bool_t ret = FALSE;
\r
74 > + n = confstr(_CS_PATH, NULL, 0);
\r
75 > + c = (char*)talloc_size(NULL, n);
\r
78 > + confstr(_CS_PATH, c, n);
\r
80 > + tok = strtok_r(c, ":", &save);
\r
82 > + dfd = open(tok, O_DIRECTORY | O_RDONLY);
\r
83 > + if (dfd != -1) {
\r
84 > + if (!faccessat(dfd, path, X_OK, 0)) {
\r
90 > + tok = strtok_r(NULL, ":", &save);
\r
93 The above code finds gpg/gpg2 (when called w/ these args) from
\r
94 _CS_PATH (seems to be /bin:/usr/bin by default in linux (tried to
\r
95 look how this set in *BSD -- initially it looks like /usr/local/bin
\r
96 not included but... maybe we let them to complain if this is the case
\r
98 ... anyway, the full found path is not set anywhere -- how is it found
\r
99 when used (exec*p() using $PATH? :O)
\r
105 > + talloc_free(c);
\r
109 > +notmuch_status_t
\r
110 > +notmuch_database_set_gpg_path (notmuch_database_t *notmuch, const char* path)
\r
112 > + /* return success if this matches what is already configured */
\r
113 > + if ((!path && !notmuch->gpg_path) ||
\r
114 > + (path && notmuch->gpg_path && 0 == strcmp(path, notmuch->gpg_path)))
\r
115 > + return NOTMUCH_STATUS_SUCCESS;
\r
117 > + if (!path && !_find_in_path(path))
\r
118 > + return NOTMUCH_STATUS_FILE_ERROR;
\r
120 > + /* clear any existing gpg_crypto_ctx, since things are changing */
\r
121 > + if (notmuch->gpg_crypto_ctx) {
\r
122 > + g_object_unref (notmuch->gpg_crypto_ctx);
\r
123 > + notmuch->gpg_crypto_ctx = NULL;
\r
126 > + if (notmuch->gpg_path) {
\r
127 > + talloc_free(notmuch->gpg_path);
\r
128 > + notmuch->gpg_path = NULL;
\r
132 > + notmuch->gpg_path = talloc_strdup (notmuch, path);
\r
134 > + return NOTMUCH_STATUS_SUCCESS;
\r
138 > +notmuch_database_get_gpg_path (const notmuch_database_t *notmuch)
\r
140 > + if (notmuch->gpg_path)
\r
141 > + return notmuch->gpg_path;
\r
143 > +#define try_gpg_path(z) if (_find_in_path(z)) return z
\r
144 > + try_gpg_path("gpg2");
\r
145 > + try_gpg_path("gpg");
\r