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 8FCB36DE0941 for ; Mon, 11 Dec 2017 23:18:23 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.027 X-Spam-Level: X-Spam-Status: No, score=-0.027 tagged_above=-999 required=5 tests=[AWL=-0.027] 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 S1g0nP-ttk7C for ; Mon, 11 Dec 2017 23:18:21 -0800 (PST) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id D88556DE0962 for ; Mon, 11 Dec 2017 23:18:16 -0800 (PST) Received: from fifthhorseman.net (unknown [38.109.115.130]) by che.mayfirst.org (Postfix) with ESMTPSA id 7AE8BF99E for ; Tue, 12 Dec 2017 02:18:16 -0500 (EST) Received: by fifthhorseman.net (Postfix, from userid 1000) id 5988E20E83; Tue, 12 Dec 2017 02:18:13 -0500 (EST) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH 4/5] index: _index_encrypted_mime_part returns success or failure Date: Tue, 12 Dec 2017 02:15:52 -0500 Message-Id: <20171212071553.6440-5-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171212071553.6440-1-dkg@fifthhorseman.net> References: <20171212071553.6440-1-dkg@fifthhorseman.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 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: Tue, 12 Dec 2017 07:18:23 -0000 This change prepares us to know whether or not _index_encrypted_mime_part succeeded or not on a given MIME part. We don't currently make use of the information, but we will in subsequent changes. --- lib/index.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/index.cc b/lib/index.cc index e03f5230..29ede685 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -364,7 +364,7 @@ _index_content_type (notmuch_message_t *message, GMimeObject *part) } } -static void +static bool _index_encrypted_mime_part (notmuch_message_t *message, notmuch_indexopts_t *indexopts, GMimeContentType *content_type, GMimeObject *part); @@ -419,6 +419,8 @@ _index_mime_part (notmuch_message_t *message, _index_content_type (message, g_mime_multipart_get_part (multipart, i)); if (i == GMIME_MULTIPART_ENCRYPTED_CONTENT) { + /* deliberately ignore return value here: if it fails to decrypt, + we have nothing else to try */ _index_encrypted_mime_part(message, indexopts, content_type, part); @@ -519,8 +521,9 @@ _index_mime_part (notmuch_message_t *message, } /* descend (if desired) into the cleartext part of an encrypted MIME - * part while indexing. */ -static void + * part while indexing. Returns true if there was a successful + * decryption, false if there was not.*/ +static bool _index_encrypted_mime_part (notmuch_message_t *message, notmuch_indexopts_t *indexopts, g_mime_3_unused(GMimeContentType *content_type), @@ -532,7 +535,7 @@ _index_encrypted_mime_part (notmuch_message_t *message, GMimeObject *clear = NULL; if (!indexopts || (notmuch_indexopts_get_decrypt_policy (indexopts) == NOTMUCH_DECRYPT_FALSE)) - return; + return false; notmuch = notmuch_message_get_database (message); @@ -550,7 +553,7 @@ _index_encrypted_mime_part (notmuch_message_t *message, if (status) _notmuch_database_log_append (notmuch, "failed to add index.decryption " "property (%d)\n", status); - return; + return false; } } #endif @@ -560,7 +563,7 @@ _index_encrypted_mime_part (notmuch_message_t *message, clear = _notmuch_crypto_decrypt (&attempted, notmuch_indexopts_get_decrypt_policy (indexopts), message, crypto_ctx, encrypted_data, get_sk ? &decrypt_result : NULL, &err); if (!attempted) - return; + return false; if (err || !clear) { if (decrypt_result) g_object_unref (decrypt_result); @@ -576,7 +579,7 @@ _index_encrypted_mime_part (notmuch_message_t *message, if (status) _notmuch_database_log_append (notmuch, "failed to add index.decryption " "property (%d)\n", status); - return; + return false; } if (decrypt_result) { #if HAVE_GMIME_SESSION_KEYS @@ -597,7 +600,7 @@ _index_encrypted_mime_part (notmuch_message_t *message, if (status) _notmuch_database_log (notmuch, "failed to add index.decryption " "property (%d)\n", status); - + return true; } notmuch_status_t -- 2.15.1