aboutsummaryrefslogtreecommitdiff
path: root/lib/message.cc
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2017-12-08 01:24:00 -0500
committerDavid Bremner <david@tethera.net>2017-12-08 08:08:47 -0400
commit6a9626a2fdddf6115bcf97982fd10053bf48e942 (patch)
tree3c9170eb6a5ee966a9f348abcf60f1678364b778 /lib/message.cc
parent076f86025d519522cde5787def6c03fc308e8ebc (diff)
cli/reindex: destroy stashed session keys when --decrypt=false
There are some situations where the user wants to get rid of the cleartext index of a message. For example, if they're indexing encrypted messages normally, but suddenly they run across a message that they really don't want any trace of in their index. In that case, the natural thing to do is: notmuch reindex --decrypt=false id:whatever@example.biz But of course, clearing the cleartext index without clearing the stashed session key is just silly. So we do the expected thing and also destroy any stashed session keys while we're destroying the index of the cleartext. Note that stashed session keys are stored in the xapian database, but xapian does not currently allow safe deletion (see https://trac.xapian.org/ticket/742). As a workaround, after removing session keys and cleartext material from the database, the user probably should do something like "notmuch compact" to try to purge whatever recoverable data is left in the xapian freelist. This problem really needs to be addressed within xapian, though, if we want it fixed right.
Diffstat (limited to 'lib/message.cc')
-rw-r--r--lib/message.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/message.cc b/lib/message.cc
index 12743460..d5db89b6 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -2002,6 +2002,11 @@ notmuch_message_reindex (notmuch_message_t *message,
ret = notmuch_message_remove_all_properties_with_prefix (message, "index.");
if (ret)
goto DONE; /* XXX TODO: distinguish from other error returns above? */
+ if (indexopts && notmuch_indexopts_get_decrypt_policy (indexopts) == NOTMUCH_DECRYPT_FALSE) {
+ ret = notmuch_message_remove_all_properties (message, "session-key");
+ if (ret)
+ goto DONE;
+ }
/* re-add the filenames with the associated indexopts */
for (; notmuch_filenames_valid (orig_filenames);