[Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`?

2016-11-04 Thread David Bremner
--- Begin Message ---
Package: notmuch
Version: 0.23.1-1
Severity: normal

Last night I got this error from my `notmuch new --quiet` cron job. The
file that the error message complains about is now in the cur directory
of the maildir at the following path.

/path/to/mail/cur/1478190211.H80553P18378.chianamo:2,

I wonder if this some kind of race condition in `notmuch new` processing.
Perhaps it should be using inotify to find out about file movements?

Unexpected error with file /path/to/mail/new/1478190211.H80553P18378.chianamo
add_file: Something went wrong trying to read or write a file
Error opening /path/to/mail/new/1478190211.H80553P18378.chianamo: No such file 
or directory
Note: A fatal error was encountered: Something went wrong trying to read or 
write a file

-- System Information:
Debian Release: stretch/sid
  APT prefers testing-debug
  APT policy: (900, 'testing-debug'), (900, 'testing'), (800, 
'unstable-debug'), (800, 'unstable'), (790, 'buildd-unstable'), (700, 
'experimental-debug'), (700, 'experimental'), (690, 'buildd-experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.7.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_AU.utf8, LC_CTYPE=en_AU.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages notmuch depends on:
ii  libc6   2.24-5
ii  libglib2.0-02.50.1-1
ii  libgmime-2.6-0  2.6.20-8
ii  libnotmuch4 0.23.1-1
ii  libtalloc2  2.1.8-1
ii  zlib1g  1:1.2.8.dfsg-2+b3

Versions of packages notmuch recommends:
ii  alot   0.3.6-1
ii  gnupg-agent2.1.15-4
pn  gpgsm  
ii  notmuch-emacs  0.23.1-1
ii  notmuch-mutt   0.23.1-1

notmuch suggests no packages.

-- no debconf information

-- 
bye,
pabs

https://wiki.debian.org/PaulWise


signature.asc
Description: This is a digitally signed message part
--- End Message ---
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v4] emacs: add notmuch-address-post-completion-hook

2016-11-04 Thread David Bremner
David Bremner  writes:

> This hook can be used to update the message based on the results of
> address completion. For example using message-templ or gnus-alias to set
> the From address based on the To address just completed.
>
> The post-completion command is added to the notmuch-company backend to
> ensure that the hook is also called company completion is started
> without going through notmuch-address-expand-name. See the docstring of
> `company-backends' for more information.

pushed to master

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`?

2016-11-04 Thread David Bremner

Paul Wise wrote:

> Last night I got this error from my `notmuch new --quiet` cron job. The
> file that the error message complains about is now in the cur directory
> of the maildir at the following path.
>
> /path/to/mail/cur/1478190211.H80553P18378.chianamo:2,
>
> I wonder if this some kind of race condition in `notmuch new` processing.
> Perhaps it should be using inotify to find out about file movements?
>
> Unexpected error with file /path/to/mail/new/1478190211.H80553P18378.chianamo
> add_file: Something went wrong trying to read or write a file
> Error opening /path/to/mail/new/1478190211.H80553P18378.chianamo: No such 
> file or directory
> Note: A fatal error was encountered: Something went wrong trying to read or 
> write a file

I agree it looks like a race condition. inotify sounds a bit
overcomplicated and perhaps non-portable? It should probably just
tolerate disappearing files better, consider that a warning.

As a workaround, if you can replace background use of notmuch-new with
notmuch-insert (and I understand this doesn't work for everyone), you
will eliminate this kind of race condition.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: mua: add a pre-send-check-hook

2016-11-04 Thread Mark Walters
This add a pre-send hook for any checks the user wants to run before
sending the message. If any function in the hook returns nil then the
send will abort.

One use would be to check that the from address is appropriate for the
recipients (i.e., test From: based on To: and Cc:), but many other
uses are possible: checking spelling, checking that the message is set
to be encrypted etc.
---

bremner and I were discussing the address-completion-hook on irc, and
before he implemented that I suggested an alternative of adding a
pre-send-check-hook. The idea is that functions in this hook can force
abort sending (or at least get confirmation from the user) based on
the message.

For example I would be quite likely to use something like the
following in the hook.

(lambda ()
  (save-excursion
(save-restriction
  (let ((to (message-fetch-field "To"))
(from (message-fetch-field "From"))
(case-fold-search t))
(or (not (string-match "work-domain-address" to))
(string= from "my-work-address")
(yes-or-no-p "Message to work but not from work address. Really 
send? "))

I think this is reasonably orthogonal to the
notmuch-address-completion-hook. Setting the from address based on the
to addresses makes a lot of sense, but checking on send also does --
if the from is correct then the check is silent, and if the user types
in the To: without using completion then the check will catch it.


Best wishes

Mark


emacs/notmuch-mua.el | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index f333655..78130e6 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -36,6 +36,15 @@
 
 ;;
 
+(defcustom notmuch-mua-pre-send-check-hook nil
+  "Hook of checks run before sending messages.
+
+If any of the functions in the hook return nil then the send will
+be aborted."
+  :type 'hook
+  :group 'notmuch-send
+  :group 'notmuch-hooks)
+
 (defcustom notmuch-mua-send-hook '(notmuch-mua-message-send-hook)
   "Hook run before sending messages."
   :type 'hook
@@ -538,7 +547,8 @@ unencrypted.  Really send? "
 
 (defun notmuch-mua-send-common (arg &optional exit)
   (interactive "P")
-  (when (and (notmuch-mua-check-no-misplaced-secure-tag)
+  (when (and (run-hook-with-args-until-failure 
'notmuch-mua-pre-send-check-hook)
+(notmuch-mua-check-no-misplaced-secure-tag)
 (notmuch-mua-check-secure-tag-has-newline))
 (letf (((symbol-function 'message-do-fcc) 
#'notmuch-maildir-message-do-fcc))
  (if exit
-- 
2.1.4

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Is there a separate git repo for the notmuch website?

2016-11-04 Thread Matt Armstrong
I noticed that https://notmuchmail.org/emacstips/#index21h2 is stale
(the patch it mentions is now part of notmuch).  Is there a git
repository for the website that I can suggest patches against?
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Is there a separate git repo for the notmuch website?

2016-11-04 Thread Jani Nikula
On Fri, 04 Nov 2016, Matt Armstrong  wrote:
> I noticed that https://notmuchmail.org/emacstips/#index21h2 is stale
> (the patch it mentions is now part of notmuch).  Is there a git
> repository for the website that I can suggest patches against?

Please see https://notmuchmail.org/wikiwriteaccess/

BR,
Jani.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`?

2016-11-04 Thread Jani Nikula
On Fri, 04 Nov 2016, David Bremner  wrote:
> I wonder if this some kind of race condition in `notmuch new`
> processing.

Do you have some other software modifying your mail store while you're
running notmuch new?

BR,
Jani.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: rfc for notmuch remote access script

2016-11-04 Thread Jani Nikula
On Sun, 30 Oct 2016, David Bremner  wrote:
> I'm not using remote access, and I don't really have opinions about the
> best way to do it. I do have 2 concerns about the overall idea
>
> 1. I worry about the maintenance burden of extra code ./configure
> 2. I worry about promoting remote-notmuch for non-experts when the
>situation with gpg seems quite broken, at least for people not
>willing to store private key material on the server.

Both are valid concerns, I think especially the second one. And even the
gpg case is not that simple; personally I'd prefer not storing private
key material on the client... ymmv.

BR,
Jani.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 1/2] emacs: tree: remove binding for pressing button in message pane

2016-11-04 Thread David Bremner
Mark Walters  writes:

> We want to use "e" for editting postponed messages in show, and in
> tree view, so remove the binding for the function which does
>

This needs rebasing. I did the merge by hand and I think it works out,
but other recent changes to notmuch-tree.el conflict. Also editing is
mispeled.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: add check for encryption before saving.

2016-11-04 Thread David Bremner
This is intended to decrease the chance of people ending up with a bunch
of plaintext drafts of encrypted messages without knowing it.

The check is intentionally overcautious; I think the false positive of
misplaced #secure tag is probably OK here.
---

This is somewhat RFC. The regex needs to be double checked, and the
variable name is not ideal. However it does solve reduce a worry I
have about this code saving drafts of sensitive messages in plaintext
that are effectively invisible because they are tagged deleted.

 emacs/notmuch-message.el | 25 +
 1 file changed, 25 insertions(+)

diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index a503296..a2b079d 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -80,6 +80,12 @@ postponing and resuming a message."
   :type '(repeat string)
   :group 'notmuch-send)
 
+(defcustom notmuch-message-warn-encryption t
+  "Warn if the user postpones or saves a message with an mml encryption tag in 
it"
+  :type 'boolean
+  :group 'notmuch-send
+  :group 'notmuch-crypto)
+
 (defvar notmuch-message-draft-id nil
   "Message-id of the most recent saved draft of this message")
 (make-variable-buffer-local 'notmuch-message-draft-id)
@@ -140,6 +146,22 @@ Used when a new version is saved, or the message is sent."
   (when secure-tag
(insert secure-tag "\n")
 
+(defun notmuch-message-check-encryption ()
+  "Query user if there an mml tag that looks like it might indicate encryption.
+
+Returns t if there is no such tag, or the user confirms they mean
+it."
+  (save-excursion
+(message-goto-body)
+  (or
+   ;; We fine if there is no secure tag, and no #part encryption
+   (not (re-search-forward "<#\\(part 
encrypt\\|secure.*mode=.*encrypt>\\)" nil 't))
+   ;; The user confirms they means it.
+   (yes-or-no-p "\
+This message contains mml tags that suggest it is intended to be encrypted.
+Really save and index an unencrypted copy?
+(Customize `notmuch-message-warn-encrypted' to avoid this warning)"
+
 (defun notmuch-message-save-draft ()
   "Save the current draft message in the notmuch database.
 
@@ -147,6 +169,9 @@ This saves the current message in the database with tags
 `notmuch-message-draft-tags` (in addition to any default tags
 applied to newly inserted messages)."
   (interactive)
+  (when (and notmuch-message-warn-encryption
+(not (notmuch-message-check-encryption))
+(error "Save aborted")))
   (let (;; We need the message id as we need it for tagging. Note
;; message-make-message-id gives the id inside a "<" ">" pair,
;; but notmuch doesn't want that form, so remove them.
-- 
2.10.1

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch