unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
To: Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH 4/5] index: _index_encrypted_mime_part returns success or failure
Date: Tue, 12 Dec 2017 02:15:52 -0500	[thread overview]
Message-ID: <20171212071553.6440-5-dkg@fifthhorseman.net> (raw)
In-Reply-To: <20171212071553.6440-1-dkg@fifthhorseman.net>

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

  parent reply	other threads:[~2017-12-12  7:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-12  7:15 cope with inline PGP encrypted messages Daniel Kahn Gillmor
2017-12-12  7:15 ` [PATCH 1/5] crypto: prepare for decryption of " Daniel Kahn Gillmor
2018-04-30 11:24   ` David Bremner
2018-04-30 11:42     ` David Bremner
2018-05-01 17:42       ` Daniel Kahn Gillmor
2018-05-03 21:34   ` David Bremner
2017-12-12  7:15 ` [PATCH 2/5] cli/{show, reply}: try to decrypt " Daniel Kahn Gillmor
2017-12-12  7:15 ` [PATCH 3/5] index: tag text parts with inline PGP encryption as "encrypted" Daniel Kahn Gillmor
2017-12-12  7:15 ` Daniel Kahn Gillmor [this message]
2017-12-12  7:15 ` [PATCH 5/5] index: try indexing the cleartext of inline PGP encrypted text parts Daniel Kahn Gillmor
2018-05-09 21:53 ` cope with inline PGP encrypted messages Daniel Kahn Gillmor
2018-05-10 12:39   ` David Bremner
2018-05-11 17:42     ` Daniel Kahn Gillmor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171212071553.6440-5-dkg@fifthhorseman.net \
    --to=dkg@fifthhorseman.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).