[PATCH 3/3] doc: add some documentation about duplicate files.

2022-07-30 Thread David Bremner
This is mainly motivated by the new emacs-UI features to select
duplicates, but hopefully it will help demystify things for users of
the CLI as well.
---
 doc/man1/notmuch.rst  | 17 +
 doc/notmuch-emacs.rst | 25 +
 2 files changed, 42 insertions(+)

diff --git a/doc/man1/notmuch.rst b/doc/man1/notmuch.rst
index 1fec4ee5..4b146e41 100644
--- a/doc/man1/notmuch.rst
+++ b/doc/man1/notmuch.rst
@@ -155,6 +155,23 @@ equivalent:
notmuch --config:alt-config config get user.name
notmuch --config alt-config config get user.name
 
+.. _duplicate-files:
+
+DUPLICATE MESSAGE FILES
+===
+
+Notmuch considers the :mailheader:`Message-ID` to be the primary
+identifier of message. Per :rfc:`5322` the :mailheader:`Message-ID` is
+supposed to be globally unique, but this fails in two distinct
+ways. When you receive copies of a message via a mechanism like
+:mailheader:`Cc` or via a mailing list, the copies are typically
+interchangeable. In the case of some broken mail sending software, the
+same :mailheader:`Message-ID` is used for completely unrelated
+messages. The options :option:`search --duplicate` and :option:`show
+--duplicate` options provide the user with control over which message
+file is displayed. Front ends will need to provide their own
+interface, see e.g. :any:`emacs-show-duplicates`.
+
 ENVIRONMENT
 ===
 
diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst
index e69bd23d..162f62a4 100644
--- a/doc/notmuch-emacs.rst
+++ b/doc/notmuch-emacs.rst
@@ -431,6 +431,31 @@ in :ref:`notmuch-search`.
 ``c ?``
 Show all available copying commands
 
+.. _emacs-show-duplicates:
+
+Dealing with duplicates
+---
+
+If there are are multiple files with the same :mailheader:`Message-ID`
+(see :any:`duplicate-files`), then :any:`notmuch-show` displays the
+number of duplicates and identifies the current duplicate. In the
+following example duplicate 3 of 5 is displayed.
+
+.. code-block::
+   :emphasize-lines: 1
+
+M. Mustermann  (Sat, 30 Jul 2022 10:33:10 -0300) (inbox 
signed)  3/5
+Subject: Re: Multiple files per message in emacs
+To: notmuch@notmuchmail.org
+
+To display a different message file with the same
+:mailheader:`Message-ID`, the user can run the command
+:emacscmd:`notmuch-show-choose-duplicate`, by default bound to `%`.
+
+.. emacscmd:: notmuch-show-choose-duplicate
+
+   |docstring::notmuch-show-choose-duplicate|
+
 .. _notmuch-tree:
 
 notmuch-tree
-- 
2.35.2

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 1/3] doc/notmuch: merge two sections on external commands.

2022-07-30 Thread David Bremner
When adding the description of the propagation of NOTMUCH_CONFIG, I
missed that there was already a section on external commands, with a
different title.
---
 doc/man1/notmuch.rst | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/doc/man1/notmuch.rst b/doc/man1/notmuch.rst
index e0892e01..1fec4ee5 100644
--- a/doc/man1/notmuch.rst
+++ b/doc/man1/notmuch.rst
@@ -130,14 +130,16 @@ and to restore from that dump.
 The :any:`notmuch-config(1)` command can be used to get or set
 settings in the notmuch configuration file.
 
-CUSTOM COMMANDS

+EXTERNAL COMMANDS
+-
 
 If the given command is not known to notmuch, notmuch tries to execute
 the external **notmuch-** in :envvar:`PATH` instead. This
 allows users to have their own notmuch related tools to be run via the
 notmuch command. By design, this does not allow notmuch's own commands
-to be overridden using external commands.
+to be overridden using external commands.  The environment variable
+:envvar:`NOTMUCH_CONFIG` will be set according to :option:`--config`,
+if the latter is present.
 
 OPTION SYNTAX
 -
@@ -185,14 +187,6 @@ of notmuch.
If set to a non-empty value, the notmuch library will print (to
stderr) Xapian queries it constructs.
 
-EXTERNAL COMMANDS
-=
-
-When given a subcommand `foo` not recognized as built-in, notmuch will
-try to run the command (e.g. script) `notmuch-foo` in the user's
-path. The :envvar:`NOTMUCH_CONFIG` will be set according to
-:option:`--config`, if the latter is present.
-
 SEE ALSO
 
 
-- 
2.35.2

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 2/3] emacs: add docstring for notmuch-show-choose-duplicate

2022-07-30 Thread David Bremner
It should have one in any case, but in particular it is needed for the
manual.
---
 emacs/notmuch-show.el | 4 
 1 file changed, 4 insertions(+)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1bc3b319..a729ce77 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1135,6 +1135,10 @@ is t, hide the part initially and show the button."
 (make-variable-buffer-local 'notmuch-show-previous-subject)
 
 (defun notmuch-show-choose-duplicate (duplicate)
+  "Display message file DUPLICATE in place of the current one.
+
+The numbering is consistent with that used by the CLI. An error
+will be signaled if DUPLICATE is out of range."
   (interactive "Nduplicate: ")
   (let ((count (length (notmuch-show-get-prop :filename
 (when (or (> duplicate count)
-- 
2.35.2

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Sending mail succeeded but signaled failure

2022-07-30 Thread Justus Winter
David Bremner  writes:

> Justus Winter  writes:
>
>> Hello,
>>
>> I just embarrassed myself a little by sending the same mail over and
>> over again.  The reason for that is that notmuch-emacs signaled failure,
>> i.e. it displayed an error message in the status buffer and didn't close
>> the compose buffer, yet it did in fact send the mail.
>>
>> I suspect that my configuration has to do with that and someone is
>> trying to be helpful.  So I use msmtp with the authentication password
>> encrypted using OpenPGP.  Then, I use 'gpg --no-tty -q -d ...' as
>> msmtp's passwordeval function.  Now, my OpenPGP key has expired, but
>> that doesn't stop GnuPG from decrypting the secret, and in fact it
>> returns the status code 0.  It also prints
>>
>>   gpg: Note: secret key 08CC70F8D8CC765A expired at Mon 25 Jul 2022 05:31:26 
>> PM CEST
>>
>> to stderr, which is picked up by notmuch-emacs, it says
>>
>>   sending...failed to gpg: Note: secret key 08CC70F8D8CC765A expired at Mon 
>> 25 Jul 2022 05:31:26 PM CEST
>>
>> in the status buffer while the compose buffer stays open.
>>
>> I suspect that this is not notmuch's fault, but I don't know where else
>> to turn to with this bug report.
>
> I guess the first step is to see if you can duplicate the problem with
> plain M-x message-mode. The mechanics of sending should be identical in
> notmuch-message-mode unless (surprise!) I misremember something.

It does indeed happen with the plain message mode.  And I think I have
identified the code in emacs that turns any output, stdout and stderr,
into errors:

% cat -n emacs/lisp/mail/sendmail.el
[...]
  1343   (exit-value (apply #'call-process-region args)))
  1344  (cond ((or (null exit-value) (eq 0 exit-value)))
  1345((numberp exit-value)
  1346 (setq error t)
  1347 (error "Sending...failed with exit value %d" 
exit-value))
  1348((stringp exit-value)
  1349 (setq error t)
  1350 (error "Sending...terminated by signal: %s" 
exit-value))
  1351(t
  1352 (setq error t)
  1353 (error "SENDMAIL-SEND-IT -- fall through: %S" 
exit-value
  1354  (or fcc-was-found
  1355  (error "No recipients")))
  1356(if mail-interactive
  1357(with-current-buffer errbuf
  1358  (goto-char (point-min))
  1359  (while (re-search-forward "\n\n* *" nil t)
  1360(replace-match "; "))
  1361  (unless (zerop (buffer-size))
  1362(setq error t)
  1363(error "Sending...failed to %s"
  1364   (buffer-substring (point-min) (point-max)))

Apparently, that behavior goes back to the initial checkin of that
file.  I refuse to believe that Dan and me are the only ones having
problems with that in 30 years... I'll report it upstream.

Best,
Justus
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


release 0.37 is immanent

2022-07-30 Thread David Bremner

It has been a while, and there have been quite a few changes since
0.36. I propose feature freeze for 0.37 August 13, with a release around
a week after that.

d


signature.asc
Description: PGP signature
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Sending mail succeeded but signaled failure

2022-07-30 Thread Justus Winter
Hi Dan :)

Dan Čermák  writes:

> Hi Justus,
>
> Justus Winter  writes:
>
>> Hello,
>>
>> I just embarrassed myself a little by sending the same mail over and
>> over again.  The reason for that is that notmuch-emacs signaled failure,
>> i.e. it displayed an error message in the status buffer and didn't close
>> the compose buffer, yet it did in fact send the mail.
>>
>> I suspect that my configuration has to do with that and someone is
>> trying to be helpful.  So I use msmtp with the authentication password
>> encrypted using OpenPGP.  Then, I use 'gpg --no-tty -q -d ...' as
>> msmtp's passwordeval function.  Now, my OpenPGP key has expired, but
>> that doesn't stop GnuPG from decrypting the secret, and in fact it
>> returns the status code 0.  It also prints
>>
>>   gpg: Note: secret key 08CC70F8D8CC765A expired at Mon 25 Jul 2022 05:31:26 
>> PM CEST
>>
>> to stderr, which is picked up by notmuch-emacs, it says
>>
>>   sending...failed to gpg: Note: secret key 08CC70F8D8CC765A expired at Mon 
>> 25 Jul 2022 05:31:26 PM CEST
>>
>> in the status buffer while the compose buffer stays open.
>>
>> I suspect that this is not notmuch's fault, but I don't know where else
>> to turn to with this bug report.
>
> I think this is msmtp's "fault". Afaik if msmtp receives something on
> stderr for the passwordeval, then it considers that a failure, however
> it will still take the password and send your mail.
>
> I have run into exactly the same problem when gpg started to print
> --8<---cut here---start->8---
> gpg: all values passed to '--default-key' ignored
> --8<---cut here---end--->8---
> stderr and msmtp took that as failure.

Good lead, but I looked at msmtp, and it uses popen(3), so it doesn't
get to see what the invoked process writes to stderr.  Therefore, I
think emacs it at fault here.

> I have "fixed" that issue by adding a
> --8<---cut here---start->8---
> 2> /dev/null
> --8<---cut here---end--->8---
> at the end of each passwordeval in ~/.msmtprc.

Indeed, that is also the workaround I arrived at!

Best,
Justus
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: add new option notmuch-search-exclude

2022-07-30 Thread David Bremner
Mohsin Kaleem  writes:

> David Bremner  writes:
>
> Hi, firstly sorry for taking so long to come back to this. I honestly
> have tried to fix this multiple times since my last message but kept
> getting confused or misdirected by how the tests are setup so I gave up
> and decided to come back to it later. Today I finally just sped through
> everything and think I have everything ready.
>

I think the patch series needs a bit of cleanup still. The first two
patches occur twice and then a later patch is reverted (so presumably
those two can be dropped as well).

If possible, please use git send-email to send one-patch-per-message, it
makes reviewing in notmuch-emacs much easier for me.

You may also want to rebase against master before resending, since I
have just a applied some changes to the emacs UI code that might collide
with yours.

d
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Multiple files per message in emacs

2022-07-30 Thread David Bremner
Rafael Ávila de Espíndola  writes:

> Hi,
>
> I got a few emails which all have the same Message-ID:
>
> $ notmuch search subject:'"MB WAY"'
> thread:00089926 34 mins. ago [1/1(3)] MB WAY
>
> $ notmuch search --output=files subject:'"MB WAY"' | xargs grep -i Message-ID
> .../Inbox/cur/1654275120.5360_1.dell,U=16229:2,S:Message-ID: MB Way
> .../Inbox/cur/1654275303.6122_1.dell,U=16230:2,S:Message-ID: MB Way
> .../Inbox/cur/1654275508.11919_1.dell,U=16231:2,S:Message-ID: MB Way
>
> In emacs I only see the content of the first file, and there is no
> indication that others are present. I am using notmuch 0.36. Is that a
> known limitation?
>

If you can build from source, there is new support for viewing
duplicates in master.

d
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: a DoS vulnerability associated with conflated Message-IDs?

2022-07-30 Thread David Bremner
Daniel Kahn Gillmor  writes:

> On Fri 2017-08-04 16:42:54 -0400, David Bremner wrote:
>> Peter Wang  writes:
>>
>>> On Thu, 08 Mar 2012 11:37:09 -0500, Daniel Kahn Gillmor 
>>>  wrote:
 notmuch currently treats all messages with the same Message-ID as
 the same message.  I think this could be a vulnerability :(
 
 If two messages have the same Message-ID, is there a guarantee of which
 of these messages will be produced during a notmuch show?
 
 Either way, it seems to create a potential DoS attack on notmuch users.
>>>
>>> Yesterday I was expecting a confirmation message which, seemingly, never
>>> came.  It turns out my maildir already contained a message from the
>>> same system.  From three years ago.  With the same Message-ID.
>>>
>>> Malice has nothing on incompetence.
>>>
>>> Could we distinguish messages with identical Message-IDs based on
>>> some header fields, e.g. Date, From?
>>
>> I wouldn't say this problem is fixed, but we are making some
>> progress. In master all copies of the file are now indexed. It still
>> needs various UI work before we can consider the problem really fixed,
>> but it is now technically possible to detect such an attack (since the
>> "good terms" are also indexed).
>
> otoh, we now enable some additional (perhaps weirder) attacks, like:
>
>  * i can make someone else's mail show up in your mailbox with a search
>term of my choosing by sending you a new mail co-opting their
>message-id.
>
> we definitely need some UI for dealing with this, and perhaps some
> explicit de-duping logic or maintenance scripts would be useful too.
>
>--dkg

There is now a simple UI for dealing with duplicate messages in the
emacs UI (as of commit 1ef7c75111b84ea19af3186ddc12f2ba434c93de, which
should be part of 0.37). 
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [Emacs] Using notmuch-address with EUDC, and completion-at-point

2022-07-30 Thread David Bremner
Alexander Adolf  writes:

> As I wanted email address completion via completion-at-point in
> message-mode too, I implemented a new EUDC function to go into
> completion-at-point-functions [3].
>
> [1] https://company-mode.github.io
> [2] https://github.com/minad/corfu
> [3] https://github.com/emacs-mirror/emacs/blob/master/lisp/net/eudc-capf.el
>

I will have to leave to others to test this, since I'm personally still
running emacs 27 (and that is likely to continue for a while, at least
on some machines).

> To close the loop, I also wrote an EUDC back-end to get candidates from
> notmuch-address (which attached).

Is this something that you think should be included with notmuch? If so,
is it testable without requiring any extra packages?

d


___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 6/6] doc/emacs: add docstring for notmuch-unthreaded-result-format.

2022-07-30 Thread David Bremner
David Bremner  writes:

> The main change is actually updating cross references.

series applied to master.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 9/9] emacs/reply: reply to correct duplicate

2022-07-30 Thread David Bremner
David Bremner  writes:

> Essentially we just need to arrange to pass the right --duplicate
> argument to notmuch reply.
>
> As a side-effect, correct the previously unused value of EXPECTED in
> T453-emacs-reply.sh.

remainder of series applied to master.

d
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org