1 Return-Path: <dkg@fifthhorseman.net>
\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 1B5C16DE0FF1
\r
6 for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 19:40:09 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.035 tagged_above=-999 required=5
\r
12 tests=[AWL=-0.035] 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 5UbXq0YuG3Ap for <notmuch@notmuchmail.org>;
\r
16 Wed, 9 Dec 2015 19:40:05 -0800 (PST)
\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])
\r
18 by arlo.cworth.org (Postfix) with ESMTP id D46A36DE005F
\r
19 for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 19:40:04 -0800 (PST)
\r
20 Received: from fifthhorseman.net (unknown [38.109.115.130])
\r
21 by che.mayfirst.org (Postfix) with ESMTPSA id 09188F985
\r
22 for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 22:40:03 -0500 (EST)
\r
23 Received: by fifthhorseman.net (Postfix, from userid 1000)
\r
24 id AC13120CF1; Wed, 9 Dec 2015 22:40:03 -0500 (EST)
\r
25 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
\r
26 To: Notmuch Mail <notmuch@notmuchmail.org>
\r
27 Subject: [PATCH 3/9] index encrypted parts when the message is flagged
\r
29 Date: Wed, 9 Dec 2015 22:39:40 -0500
\r
30 Message-Id: <1449718786-28000-4-git-send-email-dkg@fifthhorseman.net>
\r
31 X-Mailer: git-send-email 2.6.2
\r
32 In-Reply-To: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>
\r
33 References: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.20
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Thu, 10 Dec 2015 03:40:09 -0000
\r
48 We add a new message flag that indicates desire for indexing the
\r
49 cleartext of a given message.
\r
51 If that flag is set while indexing, we'll try to descend into it.
\r
53 If we can decrypt, we tag the message with index-decrypted.
\r
55 If we can't decrypt (or recognize the encrypted type of mail), we tag
\r
56 with decryption-failed.
\r
58 Note that a single message may be tagged with "encrypted" and
\r
59 "index-decrypted" and "decryption-failed". For example, consider a
\r
60 message that includes multiple layers of encryption. It is
\r
61 automatically tagged with "encrypted". If we decrypt the outer layer
\r
62 ("index-decrypted"), but fail on the inner layer
\r
63 ("decryption-failed").
\r
65 lib/index.cc | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
\r
66 lib/notmuch.h | 5 +++++
\r
67 2 files changed, 56 insertions(+), 1 deletion(-)
\r
69 diff --git a/lib/index.cc b/lib/index.cc
\r
70 index 2fa6616..bd028cb 100644
\r
73 @@ -300,6 +300,10 @@ _index_address_list (notmuch_message_t *message,
\r
78 +_index_encrypted_mime_part (notmuch_message_t *message, GMimeContentType *content_type,
\r
79 + GMimeMultipartEncrypted *part);
\r
81 /* Callback to generate terms for each mime part of a message. */
\r
83 _index_mime_part (notmuch_message_t *message,
\r
84 @@ -346,7 +350,10 @@ _index_mime_part (notmuch_message_t *message,
\r
85 _notmuch_database_log (_notmuch_message_database (message),
\r
86 "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n");
\r
87 } else if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {
\r
88 - /* Don't index encrypted parts */
\r
89 + _notmuch_message_add_term (message, "tag", "encrypted");
\r
90 + if (notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_INDEX_DECRYPTED)) {
\r
91 + _index_encrypted_mime_part(message, content_type, GMIME_MULTIPART_ENCRYPTED (part));
\r
94 for (i = 0; i < g_mime_multipart_get_count (multipart); i++) {
\r
95 _index_mime_part (message,
\r
96 @@ -431,6 +438,49 @@ _index_mime_part (notmuch_message_t *message,
\r
100 +/* descend (if possible) into the cleartext part of an encrypted MIME
\r
101 + * part while indexing. */
\r
103 +_index_encrypted_mime_part (notmuch_message_t *message,
\r
104 + GMimeContentType *content_type,
\r
105 + GMimeMultipartEncrypted *encrypted_data)
\r
107 + notmuch_private_status_t status;
\r
108 + GMimeCryptoContext* crypto_ctx = NULL;
\r
109 + const char *protocol = g_mime_content_type_get_parameter (content_type, "protocol");
\r
110 + GError *err = NULL;
\r
111 + notmuch_database_t * notmuch = _notmuch_message_database (message);
\r
112 + GMimeObject *clear = NULL;
\r
114 + status = _notmuch_database_get_crypto_for_protocol (notmuch, protocol,
\r
117 + _notmuch_database_log (notmuch, "Warning: setup failed for decrypting "
\r
118 + "during indexing. (%d)\n", status);
\r
119 + _notmuch_message_add_term (message, "tag", "index-decryption-failed");
\r
123 + /* we don't need the GMimeDecryptResult, because we're not looking
\r
124 + * at validating signatures, and we don't care about indexing who
\r
125 + * the message was ostensibly encrypted to.
\r
127 + clear = g_mime_multipart_encrypted_decrypt(encrypted_data, crypto_ctx,
\r
130 + _notmuch_database_log (notmuch, "Failed to decrypt during indexing. (%d:%d) [%s]\n",
\r
131 + err->domain, err->code, err->message);
\r
132 + g_error_free(err);
\r
133 + /* Indicate that we failed to decrypt during indexing */
\r
134 + _notmuch_message_add_term (message, "tag", "index-decryption-failed");
\r
137 + _index_mime_part (message, clear);
\r
138 + g_object_unref (clear);
\r
140 + _notmuch_message_add_term (message, "tag", "index-decrypted");
\r
144 _notmuch_message_index_file (notmuch_message_t *message,
\r
145 notmuch_message_file_t *message_file)
\r
146 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
147 index 310a8b8..e7085b7 100644
\r
148 --- a/lib/notmuch.h
\r
149 +++ b/lib/notmuch.h
\r
150 @@ -1357,6 +1357,11 @@ typedef enum _notmuch_message_flag {
\r
153 NOTMUCH_MESSAGE_FLAG_GHOST,
\r
155 + /* Some part(s) of this message is encrypted, but the message is
\r
156 + * indexed in the clear.
\r
158 + NOTMUCH_MESSAGE_FLAG_INDEX_DECRYPTED
\r
159 } notmuch_message_flag_t;
\r