Re: [PATCH 18/20] indexing: record protected subject when indexing cleartext

2018-06-02 Thread Jameson Graef Rollins
On Fri, May 11 2018, Daniel Kahn Gillmor  wrote:
> When indexing the cleartext of an encrypted message, record any
> protected subject in the database, which should make it findable and
> visible in search.
> ---
>  lib/index.cc   | 42 ++
...
> diff --git a/lib/index.cc b/lib/index.cc
> index 0ad683fa..db16b6f8 100644
> --- a/lib/index.cc
> +++ b/lib/index.cc
...
> @@ -430,8 +435,13 @@ _index_mime_part (notmuch_message_t *message,
>   }
>   continue;
>   }
> - _index_mime_part (message, indexopts,
> -   g_mime_multipart_get_part (multipart, i));
> + child = g_mime_multipart_get_part (multipart, i);
> + status = _notmuch_message_crypto_potential_payload (msg_crypto, 
> child, part, i);
> + if (status)
> + _notmuch_database_log (_notmuch_message_database (message),
> +"Warning: failed to mark the potential 
> cryptographic payload (%s).\n",
> +notmuch_status_to_string (status));
> + _index_mime_part (message, indexopts, child, msg_crypto);
>   }
>   return;
>  }

In 9088db76d89264b733f6b45e776d8952da237921 _notmuch_message_database
was exposed as notmuch_message_get_database, so this patch needs to be
updated:

diff --git a/lib/index.cc b/lib/index.cc
index 74e1ba43..18e712b1 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -438,7 +438,7 @@ _index_mime_part (notmuch_message_t *message,
child = g_mime_multipart_get_part (multipart, i);
status = _notmuch_message_crypto_potential_payload (msg_crypto, 
child, part, i);
if (status)
-   _notmuch_database_log (_notmuch_message_database (message),
+   _notmuch_database_log (notmuch_message_get_database (message),
   "Warning: failed to mark the potential 
cryptographic payload (%s).\n",
   notmuch_status_to_string (status));
_index_mime_part (message, indexopts, child, msg_crypto);

This fix doesn't affect any of the subsequent patches in this series.

jamie.


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 18/20] indexing: record protected subject when indexing cleartext

2018-05-10 Thread Daniel Kahn Gillmor
When indexing the cleartext of an encrypted message, record any
protected subject in the database, which should make it findable and
visible in search.
---
 lib/index.cc   | 42 ++
 lib/message.cc |  8 +++
 lib/notmuch-private.h  |  4 
 test/T356-protected-headers.sh | 20 
 4 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/lib/index.cc b/lib/index.cc
index 0ad683fa..db16b6f8 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -367,13 +367,15 @@ _index_content_type (notmuch_message_t *message, 
GMimeObject *part)
 static void
 _index_encrypted_mime_part (notmuch_message_t *message, notmuch_indexopts_t 
*indexopts,
GMimeContentType *content_type,
-   GMimeMultipartEncrypted *part);
+   GMimeMultipartEncrypted *part,
+   _notmuch_message_crypto_t *msg_crypto);
 
 /* Callback to generate terms for each mime part of a message. */
 static void
 _index_mime_part (notmuch_message_t *message,
  notmuch_indexopts_t *indexopts,
- GMimeObject *part)
+ GMimeObject *part,
+ _notmuch_message_crypto_t *msg_crypto)
 {
 GMimeStream *stream, *filter;
 GMimeFilter *discard_non_term_filter;
@@ -404,6 +406,8 @@ _index_mime_part (notmuch_message_t *message,
  _notmuch_message_add_term (message, "tag", "encrypted");
 
for (i = 0; i < g_mime_multipart_get_count (multipart); i++) {
+   notmuch_status_t status;
+   GMimeObject *child;
if (GMIME_IS_MULTIPART_SIGNED (multipart)) {
/* Don't index the signature, but index its content type. */
if (i == GMIME_MULTIPART_SIGNED_SIGNATURE) {
@@ -421,7 +425,8 @@ _index_mime_part (notmuch_message_t *message,
if (i == GMIME_MULTIPART_ENCRYPTED_CONTENT) {
_index_encrypted_mime_part(message, indexopts,
   content_type,
-  GMIME_MULTIPART_ENCRYPTED 
(part));
+  GMIME_MULTIPART_ENCRYPTED (part),
+  msg_crypto);
} else {
if (i != GMIME_MULTIPART_ENCRYPTED_VERSION) {
_notmuch_database_log (_notmuch_message_database 
(message),
@@ -430,8 +435,13 @@ _index_mime_part (notmuch_message_t *message,
}
continue;
}
-   _index_mime_part (message, indexopts,
- g_mime_multipart_get_part (multipart, i));
+   child = g_mime_multipart_get_part (multipart, i);
+   status = _notmuch_message_crypto_potential_payload (msg_crypto, 
child, part, i);
+   if (status)
+   _notmuch_database_log (_notmuch_message_database (message),
+  "Warning: failed to mark the potential 
cryptographic payload (%s).\n",
+  notmuch_status_to_string (status));
+   _index_mime_part (message, indexopts, child, msg_crypto);
}
return;
 }
@@ -441,7 +451,7 @@ _index_mime_part (notmuch_message_t *message,
 
mime_message = g_mime_message_part_get_message (GMIME_MESSAGE_PART 
(part));
 
-   _index_mime_part (message, indexopts, g_mime_message_get_mime_part 
(mime_message));
+   _index_mime_part (message, indexopts, g_mime_message_get_mime_part 
(mime_message), msg_crypto);
 
return;
 }
@@ -518,7 +528,8 @@ static void
 _index_encrypted_mime_part (notmuch_message_t *message,
notmuch_indexopts_t *indexopts,
g_mime_3_unused(GMimeContentType *content_type),
-   GMimeMultipartEncrypted *encrypted_data)
+   GMimeMultipartEncrypted *encrypted_data,
+   _notmuch_message_crypto_t *msg_crypto)
 {
 notmuch_status_t status;
 GError *err = NULL;
@@ -573,6 +584,10 @@ _index_encrypted_mime_part (notmuch_message_t *message,
return;
 }
 if (decrypt_result) {
+   status = _notmuch_message_crypto_successful_decryption (msg_crypto);
+   if (status)
+   _notmuch_database_log_append (notmuch, "failed to mark the message 
as decrypted (%s)\n",
+ notmuch_status_to_string (status));
 #if HAVE_GMIME_SESSION_KEYS
if (get_sk) {
status = notmuch_message_add_property (message, "session-key",
@@ -584,7 +599,8 @@ _index_encrypted_mime_part (notmuch_message_t *message,
 #endif
g_object_unref (decrypt_result);
 }
-_index_mime_part (message, indexopts, clear);
+status = _notmuch_message_crypto_potential_payload (msg_crypto, clear, 
GMIME_OBJECT (encrypted_data),