]> git.notmuchmail.org Git - notmuch/log
notmuch
6 years agocli: use the negating boolean support for new and insert --no-hooks
Jani Nikula [Sat, 14 Oct 2017 13:16:07 +0000 (16:16 +0300)]
cli: use the negating boolean support for new and insert --no-hooks

This lets us use the positive hooks variable in code, increasing
clarity.

6 years agocli: add support for --no- prefixed boolean and keyword flag arguments
Jani Nikula [Sat, 14 Oct 2017 13:16:06 +0000 (16:16 +0300)]
cli: add support for --no- prefixed boolean and keyword flag arguments

Add transparent support for negating boolean and keyword flag
arguments using --no-argument style on the command line. That is, if
the option description contains a boolean or a keyword flag argument
named "argument", --no-argument will match and negate it.

For boolean arguments this obviously means the logical NOT. For
keyword flag arguments this means bitwise AND of the bitwise NOT,
i.e. masking out the specified bits instead of OR'ing them in.

For example, you can use --no-exclude instead of --exclude=false in
notmuch show. If we had keyword flag arguments with some flags
defaulting to on, say --include=tags in notmuch dump/restore, this
would allow --no-include=tags to switch that off while not affecting
other flags.

As a curiosity, you should be able to warp your brain using
--no-exclude=true meaning false and --no-exclude=false meaning true if
you wish.

Specifying both "argument" and "no-argument" style arguments in the
same option description should be avoided. In this case, --no-argument
would match whichever is specified first, and --argument would only
match "argument".

6 years agoStandards-Version: bumped to 4.1.2 (no changes needed)
Daniel Kahn Gillmor [Mon, 11 Dec 2017 23:45:14 +0000 (18:45 -0500)]
Standards-Version: bumped to 4.1.2 (no changes needed)

6 years agocli/help,completion: added pointers to notmuch-properties(7)
Daniel Kahn Gillmor [Thu, 26 Oct 2017 21:28:12 +0000 (17:28 -0400)]
cli/help,completion: added pointers to notmuch-properties(7)

6 years agonmbug: Auto-checkout in clone if it wouldn't clobber
W. Trevor King [Tue, 10 Oct 2017 22:49:51 +0000 (15:49 -0700)]
nmbug: Auto-checkout in clone if it wouldn't clobber

We currently auto-checkout after pull and merge to make those more
convenient.  They're guarded against data-loss with a leading
_insist_committed().  This commit adds the same convenience to clone,
since in most cases users will have no NMBPREFIX-prefixed tags in
their database when they clone.  Users that *do* have
NMBPREFIX-prefixed tags will get a warning (and I've bumped the
default log level to warning so folks who don't set --log-level will
see it) like:

  $ nmbug clone http://nmbug.notmuchmail.org/git/nmbug-tags.git
  Cloning into '/tmp/nmbug-clone.g9dvd0tv'...
  Checking connectivity: 16674, done.
  Branch config set up to track remote branch config from origin.
  Not checking out to avoid clobbering existing tags: notmuch::0.25, ...

6 years agonmbug: Accept failures to unset core.worktree in clone
W. Trevor King [Tue, 10 Oct 2017 22:49:50 +0000 (15:49 -0700)]
nmbug: Accept failures to unset core.worktree in clone

Since 6311cfaf (init: do not set unnecessary core.worktree,
2016-09-25, 2.11.0 [1]), Git has no longer set core.worktree when
--separate-git-dir is used.  This broke clone with:

  $ nmbug clone http://nmbug.notmuchmail.org/git/nmbug-tags.git
  Cloning into '/tmp/nmbug-clone.33gg442e'...
  Checking connectivity: 16674, done.
  ['git', '--git-dir', '/home/wking/.nmbug', 'config', '--unset', 'core.worktree'] exited with 5
  $ echo $?
  1

The initial discussion that lead to the Git change is in [2], and
there is some more discussion around this specific change in [3].
There is some useful background on working trees in this 2009 message
[4].  There is also a git-worktree(1) since df0b6cfb (worktree: new
place for "git prune --worktrees", 2015-06-29, 2.5.0 [5]) which grew
the ability to add new worktrees in 799767cc (Merge branch
'es/worktree-add', 2015-07-13, 2.5.0 [6]).  Folks relying on
core.worktree in the --separate-git-dir case fall into the "former
case" in [4], and as Junio pointed out in that message, Git
operations like 'add' don't really work there.

In nmbug we don't want core.worktree, because our effective working
tree is the notmuch database.  By accepting failed core.worktree
unsets, clone will work with Gits older and younger than 2.11.0.

[1]: https://github.com/git/git/commit/6311cfaf93716bcc43dd1151cb1763e3f80d8099
[2]: https://public-inbox.org/git/CALqjkKZO_y0DNcRJjooyZ7Eso7yBMGhvZ6fE92oO4Su7JeCeng@mail.gmail.com/
[3]: https://public-inbox.org/git/87h94d8cwi.fsf@kyleam.com/
[4]: https://public-inbox.org/git/7viqbsw2vn.fsf@alter.siamese.dyndns.org/
[5]: https://github.com/git/git/commit/df0b6cfbda88144714541664fb501146d6465a82
[6]: https://github.com/git/git/commit/799767cc98b2f8e6f82d0de4bef9b5e8fcc16e97

Reported-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
6 years agonmbug: Respect 'expect' in _spawn(..., wait=True)
W. Trevor King [Tue, 10 Oct 2017 22:49:49 +0000 (15:49 -0700)]
nmbug: Respect 'expect' in _spawn(..., wait=True)

Fixing a bug from 7f2cb3be (nmbug: Translate to Python, 2014-10-03).
The bug had no direct impact though, because none of the wait=True
callers were setting expect.

Also add expected codes to the debug messages, to help log readers
understand why nonzero exits are occasionally accepted.

6 years agoMerge branch 'release'
David Bremner [Sat, 9 Dec 2017 02:19:06 +0000 (22:19 -0400)]
Merge branch 'release'

Conflicts:
        NEWS

Add in NEWS from point release

6 years agodebian: add changelog stanza for 0.25.3-1 0.25.3
David Bremner [Sat, 9 Dec 2017 01:08:21 +0000 (21:08 -0400)]
debian: add changelog stanza for 0.25.3-1

6 years agodebian: disable gdb on alpha
David Bremner [Sat, 9 Dec 2017 01:05:25 +0000 (21:05 -0400)]
debian: disable gdb on alpha

gdb seems to be broken on more architectures than it works :(.

6 years agoINSTALL: suggest gmime-3.x
David Bremner [Sat, 9 Dec 2017 01:01:17 +0000 (21:01 -0400)]
INSTALL: suggest gmime-3.x

Since we deprecated support for GMime 2.6...

6 years agodebian: add versioned depends on libgmime
David Bremner [Sat, 9 Dec 2017 00:59:45 +0000 (20:59 -0400)]
debian: add versioned depends on libgmime

6 years agoNEWS: news for 0.25.3
David Bremner [Sat, 9 Dec 2017 00:56:02 +0000 (20:56 -0400)]
NEWS: news for 0.25.3

6 years agoversion: bump to 0.25.3
David Bremner [Sat, 9 Dec 2017 00:47:25 +0000 (20:47 -0400)]
version: bump to 0.25.3

6 years agotest/emacs: add exploit mitigation test
David Bremner [Wed, 6 Dec 2017 01:17:58 +0000 (21:17 -0400)]
test/emacs: add exploit mitigation test

This test will pass if either the notmuch show mitigation code is
working correctly, or upstream emacs mime handling code has it's own
fix for https://bugs.gnu.org/28350.

6 years agoemacs: letf enriched-decode-display-prop for text/enriched display
Tomi Ollila [Wed, 6 Dec 2017 01:17:57 +0000 (21:17 -0400)]
emacs: letf enriched-decode-display-prop for text/enriched display

Dynamically bind enriched-decode-display-prop when inserting
text/enriched part. This complements commit 9b0582383833 for
emacs versions before 24.4 which do not have advice-add
functionality.

Since emacs 25.3 this particular bug is fixed.

6 years agocrypto: signature verification reports valid User IDs
Daniel Kahn Gillmor [Fri, 8 Dec 2017 20:09:46 +0000 (15:09 -0500)]
crypto: signature verification reports valid User IDs

When i'm trying to understand a message signature, i care that i know
who it came from (the "validity" of the identity associated with the
key), *not* whether i'm willing to accept the keyholder's other
identity assertions (the "trust" associated with the certificate).

We've been reporting User ID information based on the "trust"
associated with the certificate, because GMime didn't clearly expose
the validity of the User IDs.

This change relies on fixes made in GMime 3.0.3 and later which
include https://github.com/jstedfast/gmime/pull/18.

6 years agodocs: clean up documentation about decryption policies
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:24:03 +0000 (01:24 -0500)]
docs: clean up documentation about decryption policies

Now that the range of sensible decryption policies has come into full
view, we take a bit of space to document the distinctions.

Most people will use either "auto" or "true" -- but we provide "false"
and "nostash" to handle use cases that might reasonably be requested.

Note also that these can be combined in sensible ways.  Like, if your
mail comes in regularly to a service that doesn't have access to your
secret keys, but does have access to your index, and you feel
comfortable adding selected encrypted messages to the index after
you've read them, you could stay in "auto" normally, and then when you
find yourself reading an indexable message (e.g. one you want to be
able to search for in the future, and that you don't mind exposing to
whatever entities have access to your inde), you can do:

    notmuch reindex --decrypt=true id:whatever@example.biz

That leaves your default the same (still "auto") but you get the
cleartext index and stashed session key benefits for that particular
message.

6 years agocrypto: add --decrypt=nostash to avoid stashing session keys
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:24:02 +0000 (01:24 -0500)]
crypto: add --decrypt=nostash to avoid stashing session keys

Here's the configuration choice for people who want a cleartext index,
but don't want stashed session keys.

Interestingly, this "nostash" decryption policy is actually the same
policy that should be used by "notmuch show" and "notmuch reply",
since they never modify the index or database when they are invoked
with --decrypt.

We take advantage of this parallel to tune the behavior of those
programs so that we're not requesting session keys from GnuPG during
"show" and "reply" that we would then otherwise just throw away.

6 years agocrypto: actually stash session keys when decrypt=true
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:24:01 +0000 (01:24 -0500)]
crypto: actually stash session keys when decrypt=true

If you're going to store the cleartext index of an encrypted message,
in most situations you might just as well store the session key.
Doing this storage has efficiency and recoverability advantages.

Combined with a schedule of regular OpenPGP subkey rotation and
destruction, this can also offer security benefits, like "deletable
e-mail", which is the store-and-forward analog to "forward secrecy".

But wait, i hear you saying, i have a special need to store cleartext
indexes but it's really bad for me to store session keys!  Maybe
(let's imagine) i get lots of e-mails with incriminating photos
attached, and i want to be able to search for them by the text in the
e-mail, but i don't want someone with access to the index to be
actually able to see the photos themselves.

Fret not, the next patch in this series will support your wacky
uncommon use case.

6 years agocli/reindex: destroy stashed session keys when --decrypt=false
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:24:00 +0000 (01:24 -0500)]
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.

6 years agocli/new, insert, reindex: change index.decrypt to "auto" by default
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:23:59 +0000 (01:23 -0500)]
cli/new, insert, reindex: change index.decrypt to "auto" by default

The new "auto" decryption policy is not only good for "notmuch show"
and "notmuch reindex".  It's also useful for indexing messages --
there's no good reason to not try to go ahead and index the cleartext
of a message that we have a stashed session key for.

This change updates the defaults and tunes the test suite to make sure
that they have taken effect.

6 years agocrypto: record whether an actual decryption attempt happened
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:23:58 +0000 (01:23 -0500)]
crypto: record whether an actual decryption attempt happened

In our consolidation of _notmuch_crypto_decrypt, the callers lost
track a little bit of whether any actual decryption was attempted.

Now that we have the more-subtle "auto" policy, it's possible that
_notmuch_crypto_decrypt could be called without having any actual
decryption take place.

This change lets the callers be a little bit smarter about whether or
not any decryption was actually attempted.

6 years agocli/new, insert, reindex: update documentation for --decrypt=auto
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:23:57 +0000 (01:23 -0500)]
cli/new, insert, reindex: update documentation for --decrypt=auto

we also include --decrypt=auto in the tab completion.

6 years agocli/show, reply: document use of stashed session keys in notmuch-properties
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:23:56 +0000 (01:23 -0500)]
cli/show, reply: document use of stashed session keys in notmuch-properties

The stashed session keys are stored internally as notmuch properties.
So a user or developer who is reading about those properties might
want to understand how they fit into the bigger picture.

Note here that decrypting with a stored session key no longer needs
-decrypt for "notmuch show" and "notmuch reply".

6 years agocli/show: use decryption policy "auto" by default.
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:23:55 +0000 (01:23 -0500)]
cli/show: use decryption policy "auto" by default.

When showing a message, if the user doesn't specify --decrypt= at all,
but a stashed session key is known to notmuch, notmuch should just go
ahead and try to decrypt the message with the session key (without
bothering the user for access to their asymmetric secret key).

The user can disable this at the command line with --decrypt=false if
they really don't want to look at the e-mail that they've asked
notmuch to show them.

and of course, "notmuch show --decrypt" still works for accessing the
user's secret keys if necessary.

6 years agocli/reply: use decryption policy "auto" by default.
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:23:54 +0000 (01:23 -0500)]
cli/reply: use decryption policy "auto" by default.

If the user doesn't specify --decrypt= at all, but a stashed session
key is known to notmuch, when replying to an encrypted message,
notmuch should just go ahead and decrypt.

The user can disable this at the command line with --decrypt=false,
though it's not clear why they would ever want to do that.

6 years agocrypto: new decryption policy "auto"
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:23:53 +0000 (01:23 -0500)]
crypto: new decryption policy "auto"

This new automatic decryption policy should make it possible to
decrypt messages that we have stashed session keys for, without
incurring a call to the user's asymmetric keys.

6 years agolib: convert notmuch decryption policy to an enum
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:23:52 +0000 (01:23 -0500)]
lib: convert notmuch decryption policy to an enum

Future patches in this series will introduce new policies; this merely
readies the way for them.

We also convert --try-decrypt to a keyword argument instead of a boolean.

6 years agoindexopts: change _try_decrypt to _decrypt_policy
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:23:51 +0000 (01:23 -0500)]
indexopts: change _try_decrypt to _decrypt_policy

This terminology makes it clearer what's going on at the API layer,
and paves the way for future changesets that offer more nuanced
decryption policy.

6 years agoindexing: Change from try_decrypt to decrypt
Daniel Kahn Gillmor [Fri, 8 Dec 2017 06:23:50 +0000 (01:23 -0500)]
indexing: Change from try_decrypt to decrypt

the command-line interface for indexing (reindex, new, insert) used
--try-decrypt; and the configuration records used index.try_decrypt.
But by comparison with "show" and "reply", there doesn't seem to be
any reason for the "try" prefix.

This changeset adjusts the command-line interface and the
configuration interface.

For the moment, i've left indexopts_{set,get}_try_decrypt alone.  The
subsequent changeset will address those.

6 years agocli/help: give a hint about notmuch-emacs-mua
Daniel Kahn Gillmor [Mon, 4 Dec 2017 18:43:10 +0000 (13:43 -0500)]
cli/help: give a hint about notmuch-emacs-mua

"notmuch help" doesn't mention "notmuch-emacs-mua" even though we
support it through the try_external_command() mechanism.

In addition, "notmuch help emacs-mua" doesn't work, even though we
ship the appropriate manpage.

This changeset fixes both of these problems.

6 years agodebian/control: build-depend on python3-sphinx instead of python-sphinx
Daniel Kahn Gillmor [Wed, 6 Dec 2017 01:46:55 +0000 (20:46 -0500)]
debian/control: build-depend on python3-sphinx instead of python-sphinx

python2 is going to be deprecated, and python3-sphinx is available all
the way back to oldoldstable.  let's use the more modern version.

To make this work and still ship the manpages, tell ./configure to
prefer python3 over python, if it exists.

6 years agotest: session keys are known broken without session key support
Daniel Kahn Gillmor [Tue, 5 Dec 2017 18:40:27 +0000 (13:40 -0500)]
test: session keys are known broken without session key support

If the version of GMime we're building against doesn't support session
key extraction or re-use, mark the tests that rely on session key
capabilities as known-broken.

This should resolve test suite failures on ubuntu trusty and debian
jessie and earlier, which have GMime 2.6.20 -- session key support was
introduced in GMime 2.6.21.

6 years agocrypto: Test restore of cleartext index from stashed session keys
Daniel Kahn Gillmor [Thu, 30 Nov 2017 08:59:31 +0000 (03:59 -0500)]
crypto: Test restore of cleartext index from stashed session keys

If you've got a notmuch dump that includes stashed session keys for
every decrypted message, and you've got your message archive, you
should be able to get back to the same index that you had before.

Here we add a simple test that give some flavor of how that works.

6 years agotest/corpora: add an encrypted message for index decryption tests
Daniel Kahn Gillmor [Thu, 30 Nov 2017 08:59:30 +0000 (03:59 -0500)]
test/corpora: add an encrypted message for index decryption tests

6 years agocrypto: use stashed session-key properties for decryption, if available
Daniel Kahn Gillmor [Thu, 30 Nov 2017 08:59:29 +0000 (03:59 -0500)]
crypto: use stashed session-key properties for decryption, if available

When doing any decryption, if the notmuch database knows of any
session keys associated with the message in question, try them before
defaulting to using default symmetric crypto.

This changeset does the primary work in _notmuch_crypto_decrypt, which
grows some new parameters to handle it.

The primary advantage this patch offers is a significant speedup when
rendering large encrypted threads ("notmuch show") if session keys
happen to be cached.

Additionally, it permits message composition without access to
asymmetric secret keys ("notmuch reply"); and it permits recovering a
cleartext index when reindexing after a "notmuch restore" for those
messages that already have a session key stored.

Note that we may try multiple decryptions here (e.g. if there are
multiple session keys in the database), but we will ignore and throw
away all the GMime errors except for those that come from last
decryption attempt.  Since we don't necessarily know at the time of
the decryption that this *is* the last decryption attempt, we'll ask
for the errors each time anyway.

This does nothing if no session keys are stashed in the database,
which is fine.  Actually stashing session keys in the database will
come as a subsequent patch.

6 years agoconfigure: session key handling in gmime maps to built_with("session_key")
Daniel Kahn Gillmor [Thu, 30 Nov 2017 08:59:28 +0000 (03:59 -0500)]
configure: session key handling in gmime maps to built_with("session_key")

This flag should make it easier to write the code for session-key
handling.

Note that this only works for GMime 2.6.21 and later (the session key
interface wasn't available before then).  It should be fine to build
the rest of notmuch if this functionality isn't available.

Note that this also adds the "session_key" built_with() aspect to
libnotmuch.

6 years agocrypto: add _notmuch_crypto_decrypt wrapper function
Daniel Kahn Gillmor [Thu, 30 Nov 2017 08:59:27 +0000 (03:59 -0500)]
crypto: add _notmuch_crypto_decrypt wrapper function

We will use this centralized function to consolidate the awkward
behavior around different gmime versions.

It's only invoked from two places: mime-node.c's
node_decrypt_and_verify() and lib/index.cc's
_index_encrypted_mime_part().

However, those two places have some markedly distinct logic, so the
interface for this _notmuch_crypto_decrypt function is going to get a
little bit clunky.  It's worthwhile, though, for the sake of keeping
these #if directives reasonably well-contained.

6 years agomime-node: handle decrypt_result more safely
Daniel Kahn Gillmor [Thu, 30 Nov 2017 08:59:26 +0000 (03:59 -0500)]
mime-node: handle decrypt_result more safely

If (for whatever reason) we don't get a decrypt_result back, or it's
not structured the way we expect it to be, we shouldn't choke on it.

6 years agodebian: bump Standards-Version to 4.1.1
Daniel Kahn Gillmor [Thu, 30 Nov 2017 09:40:42 +0000 (04:40 -0500)]
debian: bump Standards-Version to 4.1.1

No minor changes were necessary to become compliant with Debian policy
version 4.1.1, so this is basically a freebie.

6 years agodebian/control: Priority: extra is deprecated
Daniel Kahn Gillmor [Thu, 30 Nov 2017 09:40:41 +0000 (04:40 -0500)]
debian/control: Priority: extra is deprecated

Move transitional package to to "oldlibs/optional"

This resolves two lintian warnings:

W: notmuch-emacs: transitional-package-should-be-oldlibs-optional oldlibs/extra
W: notmuch-emacs: priority-extra-is-replaced-by-priority-optional

6 years agodebian/changelog: remove trailing whitespace
Daniel Kahn Gillmor [Thu, 30 Nov 2017 09:40:40 +0000 (04:40 -0500)]
debian/changelog: remove trailing whitespace

6 years agotest: unbreak performance tests
David Bremner [Sat, 2 Dec 2017 12:53:04 +0000 (08:53 -0400)]
test: unbreak performance tests

In 8e7fb88237aedea22 Jani replaced the use of $(pwd -P) to find the
TEST_DIRECTORY in order to better support out of tree
builds. Unfortunately the performance-tests need a different value for
the variable and were thus broken.

This commit splits out the setting of this variable for the two sets
of tests.  Performance tests still don't work out of tree, because
the handling of the downloaded corpus needs to be updated.

6 years agotest: test notmuch insert --folder=""
Jani Nikula [Thu, 2 Nov 2017 19:08:57 +0000 (21:08 +0200)]
test: test notmuch insert --folder=""

Test insert into top level folder.

6 years agocli: allow empty strings for notmuch insert --folder argument
Jani Nikula [Sat, 14 Oct 2017 13:15:43 +0000 (16:15 +0300)]
cli: allow empty strings for notmuch insert --folder argument

Now that it's easy to add argument specific modifiers in opt
descriptions, add a new .allow_empty field to allow empty strings for
individual string arguments while retaining strict checks
elsewhere. Use this for notmuch insert --folder, where the empty
string means top level folder.

6 years agoMerge branch 'release'
David Bremner [Mon, 6 Nov 2017 00:25:54 +0000 (20:25 -0400)]
Merge branch 'release'

Changes from 0.25.2 release

6 years agodebian: changelog for 0.25.2-1 0.25.2 debian/0.25.2-1
David Bremner [Mon, 6 Nov 2017 00:06:23 +0000 (20:06 -0400)]
debian: changelog for 0.25.2-1

6 years agoversion: bump to 0.25.2
David Bremner [Sun, 5 Nov 2017 23:59:30 +0000 (19:59 -0400)]
version: bump to 0.25.2

6 years agoNEWS for 0.25.2
David Bremner [Sun, 5 Nov 2017 23:54:40 +0000 (19:54 -0400)]
NEWS for 0.25.2

6 years agocli/crypto: fix segfault on failed gmime2 crypto context creation
Jani Nikula [Mon, 16 Oct 2017 15:40:44 +0000 (18:40 +0300)]
cli/crypto: fix segfault on failed gmime2 crypto context creation

Commit 1fdc08d0ffab ("cli/crypto: treat failure to create a crypto
context as fatal.") started treating crypto context creation failures
"as fatal", returning NULL from _mime_node_create().

Unfortunately, we do not have NULL checks for _mime_node_create()
failures. The only caller, mime_node_child(), could check and return
NULL (as it's documented to do on errors) but none of the several call
sites have NULL checks either. And none of them really have a trivial
but feasible and graceful way of recovery.

So while the right thing to do would be to handle NULL returns
properly all over the place, and we have other scenarios that do
return NULL from above mentioned functions, the crypto context
creation failure is something that does seem to show up regularly in
some scenarios, revert back to the functionality before commit
1fdc08d0ffab as an interim fix.

6 years agotest: fix test database backup/restore location
Jani Nikula [Tue, 24 Oct 2017 18:36:11 +0000 (21:36 +0300)]
test: fix test database backup/restore location

backup_database() and restore_database() used to store the backups in
the test specific temporary directory, through the current working
directory being there. Commit 8e7fb88237ae ("test: use source and
build paths in test-lib-common.sh") started using a test specific
backup directories under the build tree test directory. This was in
error. Switch back to the old location, but using paths to the
location instead of relying on current working directory.

Reported by Daniel Kahn Gillmor <dkg@fifthhorseman.net>.

6 years agoNEWS: cleartext indexing
Daniel Kahn Gillmor [Sun, 22 Oct 2017 15:36:34 +0000 (11:36 -0400)]
NEWS: cleartext indexing

give a short summary of cleartext indexing of encrypted e-mail
messages.

6 years agoNEWS: test suite out-of-tree builds
Jani Nikula [Sat, 21 Oct 2017 19:53:28 +0000 (22:53 +0300)]
NEWS: test suite out-of-tree builds

Out-of-tree builds now work and supersede --root option.

6 years agocli/reindex: add --try-decrypt=(true|false)
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:48 +0000 (22:25 -0400)]
cli/reindex: add --try-decrypt=(true|false)

Enable override of the index.try_decrypt setting on a per-run basis
when invoking "notmuch reindex".  This allows the possibility of (for
example) an emacs keybinding that adds the cleartext of the currently
shown decrypted message to the index, making it searchable in the
future.

It also enables one-time indexing of all messages matching some query,
like so:

    notmuch reindex tag:encrypted and\
       not property:index.decryption=success and\
       from:alice@example.org

We also update the documentation and tab completion, and add a few
more tests.

6 years agocli/insert: add --try-decrypt=(true|false)
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:47 +0000 (22:25 -0400)]
cli/insert: add --try-decrypt=(true|false)

Enable override of the index.try_decrypt setting on a per-message
basis when invoking "notmuch insert".

We also update the documentation and tab completion, and add more tests.

6 years agocli/new: add --try-decrypt=(true|false)
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:46 +0000 (22:25 -0400)]
cli/new: add --try-decrypt=(true|false)

Enable override of the index.try_decrypt setting during "notmuch new"
on a per-invocation basis.

We update the documentation and tab completion, and also add a test.

6 years agotests: emacs_fcc_message: allow passing --arguments to notmuch new
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:45 +0000 (22:25 -0400)]
tests: emacs_fcc_message: allow passing --arguments to notmuch new

Subsequent patches may want to send GNU-style --long-arguments to
notmuch new in the test suite, in particular when invoking
emacs_fcc_message.  This changeset makes that possible.

6 years agocli: set up shared command-line arguments for indexing
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:44 +0000 (22:25 -0400)]
cli: set up shared command-line arguments for indexing

We have an indexopts structure for manipulating indexing in different
ways, but we also have three command-line invocations that can trigger
indexing: new, insert, and reindex.

This changeset prepares a common parser that these subcommands can
share.

Note: if the deprecated crypto.gpg_path configuration option is set to
anything other than "gpg", we ignore it (and print a warning on
stderr, if built against gmime < 3.0).

At the moment, it's just --try-decrypt, but others will likely follow.

6 years agoconfig: define new option index.try_decrypt
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:43 +0000 (22:25 -0400)]
config: define new option index.try_decrypt

By default, notmuch won't try to decrypt on indexing.  With this
patch, we make it possible to indicate a per-database preference using
the config variable "index.try_decrypt", which by default will be
false.

At indexing time, the database needs some way to know its internal
defaults for how to index encrypted parts.  It shouldn't be contingent
on an external config file (since that can't be retrieved from the
database object itself), so we store it in the database.

This behaves similarly to the query.* configurations, which are also
stored in the database itself, so we're not introducing any new
dependencies by requiring that it be stored in the database.

6 years agoconfig: test whether an item is stored in the database by name
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:42 +0000 (22:25 -0400)]
config: test whether an item is stored in the database by name

QUERY_STRING was only used in two places, both to test whether a
variable should be stored in (or retrieved from) the database.

Since other configuration variables might be stored in the database in
the future, consolidate that test into a single function.

We also document that these configuration options should not be placed
in the config file.

6 years agocrypto: index encrypted parts when indexopts try_decrypt is set.
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:41 +0000 (22:25 -0400)]
crypto: index encrypted parts when indexopts try_decrypt is set.

If we see index options that ask us to decrypt when indexing a
message, and we encounter an encrypted part, we'll try to descend into
it.

If we can decrypt, we add the property index.decryption=success.

If we can't decrypt (or recognize the encrypted type of mail), we add
the property index.decryption=failure.

Note that a single message may have both values of the
"index.decryption" property: "success" and "failure".  For example,
consider a message that includes multiple layers of encryption.  If we
manage to decrypt the outer layer ("index.decryption=success"), but
fail on the inner layer ("index.decryption=failure").

Because of the property name, this will be automatically cleared (and
possibly re-set) during re-indexing.  This means it will subsequently
correspond to the actual semantics of the stored index.

6 years agoreindex: drop all properties named with prefix "index."
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:40 +0000 (22:25 -0400)]
reindex: drop all properties named with prefix "index."

This allows us to create new properties that will be automatically set
during indexing, and cleared during re-indexing, just by choice of
property name.

6 years agodoc: add notmuch-properties(7)
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:39 +0000 (22:25 -0400)]
doc: add notmuch-properties(7)

We will want a user-facing place to record details about the use of
notmuch properties shortly.  This establishes a new manual page for
that purpose.

6 years agoindex: implement notmuch_indexopts_t with try_decrypt
Daniel Kahn Gillmor [Sat, 21 Oct 2017 02:25:38 +0000 (22:25 -0400)]
index: implement notmuch_indexopts_t with try_decrypt

This is currently mostly a wrapper around _notmuch_crypto_t that keeps
its internals private and doesn't expose any of the GMime API.
However, non-crypto indexing options might also be added later
(e.g. filters or other transformations).

6 years agobuild: don't copy the test directory for out-of-tree builds
Jani Nikula [Mon, 25 Sep 2017 20:38:39 +0000 (23:38 +0300)]
build: don't copy the test directory for out-of-tree builds

It should now work without.

6 years agotest: use source path in add_gnupg_home
Jani Nikula [Sat, 21 Oct 2017 19:21:41 +0000 (22:21 +0300)]
test: use source path in add_gnupg_home

Make a distinction between source and build directories.

6 years agotest: remove --root option and fix TMP_DIRECTORY cleanup
Jani Nikula [Sat, 21 Oct 2017 11:58:02 +0000 (14:58 +0300)]
test: remove --root option and fix TMP_DIRECTORY cleanup

The primary motivation here is to fix TMP_DIRECTORY cleanup prior to
running each test when the current working directory is not the test
subdirectory. Tests with failures would leave their TMP_DIRECTORY
directory behind for debugging, and repeated out-of-tree test runs
would have old temp directories. (This lead to e.g. T310-emacs.sh
hanging because emacs would prompt for overwriting files.)

We remove the likely anyway defunct --root test option while at it,
just to be on the safe side when doing 'rm -rf' on the TMP_DIRECTORY.

6 years agotest: use source and build paths in T590-thread-breakage.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:38 +0000 (23:38 +0300)]
test: use source and build paths in T590-thread-breakage.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in T480-hex-escaping.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:37 +0000 (23:38 +0300)]
test: use source and build paths in T480-hex-escaping.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in T4?0-emacs-*.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:36 +0000 (23:38 +0300)]
test: use source and build paths in T4?0-emacs-*.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in T380-atomicity.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:35 +0000 (23:38 +0300)]
test: use source and build paths in T380-atomicity.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in T360-symbol-hiding.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:34 +0000 (23:38 +0300)]
test: use source and build paths in T360-symbol-hiding.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in T355-smime.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:33 +0000 (23:38 +0300)]
test: use source and build paths in T355-smime.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in T310-emacs.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:31 +0000 (23:38 +0300)]
test: use source and build paths in T310-emacs.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in T260-thread-order.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:30 +0000 (23:38 +0300)]
test: use source and build paths in T260-thread-order.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in T160-json.sh and T170-sexp.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:29 +0000 (23:38 +0300)]
test: use source and build paths in T160-json.sh and T170-sexp.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in T000-basic.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:28 +0000 (23:38 +0300)]
test: use source and build paths in T000-basic.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in notmuch-test
Jani Nikula [Mon, 25 Sep 2017 20:38:27 +0000 (23:38 +0300)]
test: use source and build paths in notmuch-test

Make a distinction between source and build directories.

6 years agotest: mkdir and cd to $TMP_DIRECTORY instead of $test for testing
Jani Nikula [Mon, 25 Sep 2017 20:38:26 +0000 (23:38 +0300)]
test: mkdir and cd to $TMP_DIRECTORY instead of $test for testing

$TMP_DIRECTORY is a full path, while $test is not.

6 years agotest: use source and build paths in test-lib-common.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:25 +0000 (23:38 +0300)]
test: use source and build paths in test-lib-common.sh

Make a distinction between source and build directories.

The expectation is that anyone sourcing test-lib-common.sh has sourced
export-dirs.sh.

6 years agoperf-test: use source and build paths in perf-test-lib.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:24 +0000 (23:38 +0300)]
perf-test: use source and build paths in perf-test-lib.sh

Make a distinction between source and build directories.

6 years agotest: use source and build paths in test-lib.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:23 +0000 (23:38 +0300)]
test: use source and build paths in test-lib.sh

Make a distinction between source and build directories.

6 years agotest: add a script to figure out source and build directories
Jani Nikula [Mon, 25 Sep 2017 20:38:22 +0000 (23:38 +0300)]
test: add a script to figure out source and build directories

Expect the tests to be run somewhere in the build directory
hierarchy. Allow for source and build directories to be passed through
the environment.

6 years agotest: check for notmuch binary in test-lib.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:21 +0000 (23:38 +0300)]
test: check for notmuch binary in test-lib.sh

Move notmuch executable check into common code. Redundant for
notmuch-test runs, but works also for individual tests.

6 years agoperf-test: use $(dirname "$0") for sourcing perf-test-lib.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:20 +0000 (23:38 +0300)]
perf-test: use $(dirname "$0") for sourcing perf-test-lib.sh

Don't assume the tests are always run from within the source tree.

6 years agotest: use $(dirname "$0") for sourcing test-lib.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:19 +0000 (23:38 +0300)]
test: use $(dirname "$0") for sourcing test-lib.sh

Don't assume the tests are always run from within the source tree.

6 years agobuild: use NOTMUCH_SRCDIR for referencing notmuch-test
Jani Nikula [Mon, 25 Sep 2017 20:38:18 +0000 (23:38 +0300)]
build: use NOTMUCH_SRCDIR for referencing notmuch-test

Don't assume the tests are always run from within the source tree.

6 years agotest: use corpora/default not corpus in T480-hex-escaping.sh
Jani Nikula [Mon, 25 Sep 2017 20:38:17 +0000 (23:38 +0300)]
test: use corpora/default not corpus in T480-hex-escaping.sh

Turns out round trip tests didn't really round trip anything. Broken
by yours truly in 971cdc72cdb8 ("test: make it possible to have
multiple corpora"). Ooops.

6 years agoproperties: add notmuch_message_remove_all_properties_with_prefix()
Daniel Kahn Gillmor [Tue, 17 Oct 2017 19:09:59 +0000 (15:09 -0400)]
properties: add notmuch_message_remove_all_properties_with_prefix()

Subsequent patches will introduce a convention that properties whose
name starts with "index." will be stripped (and possibly re-added)
during re-indexing.  This patch lays the groundwork for doing that.

6 years agocrypto: make shared crypto code behave library-like
Daniel Kahn Gillmor [Tue, 17 Oct 2017 19:09:56 +0000 (15:09 -0400)]
crypto: make shared crypto code behave library-like

If we're going to reuse the crypto code across both the library and
the client, then it needs to report error states properly and not
write to stderr.

6 years agocrypto: move into libnotmuch_util
Daniel Kahn Gillmor [Tue, 17 Oct 2017 19:09:55 +0000 (15:09 -0400)]
crypto: move into libnotmuch_util

This prepares us for using the crypto object in both libnotmuch and
the client.

6 years agodoc: make SEE ALSO references one-per-line
Daniel Kahn Gillmor [Tue, 17 Oct 2017 16:57:21 +0000 (12:57 -0400)]
doc: make SEE ALSO references one-per-line

This will make future diffs cleaner, make it easier to keep them
alphabetical, and make it easier to scan and search the documentation
sources.

6 years agodoc: fix documentation typos and copy/paste-os
Daniel Kahn Gillmor [Tue, 17 Oct 2017 16:57:20 +0000 (12:57 -0400)]
doc: fix documentation typos and copy/paste-os

6 years agocli: make notmuch count --exclude a boolean argument
Jani Nikula [Sat, 14 Oct 2017 20:18:36 +0000 (23:18 +0300)]
cli: make notmuch count --exclude a boolean argument

Commit 0f314c0c99be ("cli: convert notmuch_bool_t to stdbool")
over-eagerly converted EXCLUDE_TRUE and EXCLUDE_FALSE to EXCLUDE_true
and EXCLUDE_false in notmuch-count.c. We could just fix the case back,
but convert the option to an actual boolean argument instead.

We've used a keyword argument rather than a boolean argument for
notmuch count --exclude for five years, since commit 785c1e497f05
("cli: move count to the new --exclude=(true|false|flag) naming
scheme."), "to allow future options to be added more easily". I think
we can conclude future options aren't coming any time soon.

6 years agogmime-extra: drop compat layer for g_mime_multipart_encrypted_decrypt
Daniel Kahn Gillmor [Tue, 10 Oct 2017 05:49:10 +0000 (01:49 -0400)]
gmime-extra: drop compat layer for g_mime_multipart_encrypted_decrypt

In practice, we're going to see this function invoked differently
depending on which gmime we build against.  The compatibility layer
forces our code into the lowest-common-denominator -- unable to make
use of new features even when built against a newer version.

Dropping the compatibility layer paves the way for clearer use of
features from GMime 3.0 in future commits.

6 years agotests: prepare for more crypto tests (using add_gnupg_home)
Daniel Kahn Gillmor [Tue, 10 Oct 2017 05:49:08 +0000 (01:49 -0400)]
tests: prepare for more crypto tests (using add_gnupg_home)

Move add_gnupg_home to test-lib.sh to prepare it for reuse.

6 years agogmime-extra: remove duplicate GMimeAddressType typedef
Daniel Kahn Gillmor [Tue, 10 Oct 2017 05:49:06 +0000 (01:49 -0400)]
gmime-extra: remove duplicate GMimeAddressType typedef

"typedef GMimeAddressType GMimeRecipientType" is already present
further down in the compatibility wrapper (with other typedefs).  We
don't need it twice.

6 years agocrypto: _notmuch_crypto_cleanup should return void
Daniel Kahn Gillmor [Tue, 10 Oct 2017 05:49:04 +0000 (01:49 -0400)]
crypto: _notmuch_crypto_cleanup should return void

There's no chance that _notmuch_crypto_cleanup() will ever return
anything other than 0, and no one ever checks its return value anyway.
So make it return void instead of int.

6 years agocrypto: drop pretense of notmuch_crypto_context_t
Daniel Kahn Gillmor [Tue, 10 Oct 2017 05:49:03 +0000 (01:49 -0400)]
crypto: drop pretense of notmuch_crypto_context_t

notmuch_crypto_context_t was introduced (i think) as some sort of
abstraction layer to make notmuch somewhat independent of GMime.  But
it isn't even useful for GMime 3.0 or later -- we can drop the
pretense that it's some sort of abstraction in this case, and just
call it what it is, GMimeCryptoContext, which is useful for building
against older versions of GMime.

This also renames _notmuch_crypto_get_context() to
_notmuch_crypto_get_gmime_context().