1 Return-Path: <dkg@fifthhorseman.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 569B66DE1601
\r
6 for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 19:40:16 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.032 tagged_above=-999 required=5
\r
12 tests=[AWL=-0.032] autolearn=disabled
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 7jL3-B0Ubn2n for <notmuch@notmuchmail.org>;
\r
16 Wed, 9 Dec 2015 19:40:14 -0800 (PST)
\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])
\r
18 by arlo.cworth.org (Postfix) with ESMTP id B3AC06DE18F2
\r
19 for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 19:40:06 -0800 (PST)
\r
20 Received: from fifthhorseman.net (unknown [38.109.115.130])
\r
21 by che.mayfirst.org (Postfix) with ESMTPSA id 833C9F991
\r
22 for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 22:40:04 -0500 (EST)
\r
23 Received: by fifthhorseman.net (Postfix, from userid 1000)
\r
24 id C1626212D1; Wed, 9 Dec 2015 22:40:03 -0500 (EST)
\r
25 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
\r
26 To: Notmuch Mail <notmuch@notmuchmail.org>
\r
27 Subject: [PATCH 8/9] add --try-decrypt to notmuch insert
\r
28 Date: Wed, 9 Dec 2015 22:39:45 -0500
\r
29 Message-Id: <1449718786-28000-9-git-send-email-dkg@fifthhorseman.net>
\r
30 X-Mailer: git-send-email 2.6.2
\r
31 In-Reply-To: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>
\r
32 References: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>
\r
33 X-BeenThere: notmuch@notmuchmail.org
\r
34 X-Mailman-Version: 2.1.20
\r
36 List-Id: "Use and development of the notmuch mail system."
\r
37 <notmuch.notmuchmail.org>
\r
38 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
39 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
41 List-Post: <mailto:notmuch@notmuchmail.org>
\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
43 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
45 X-List-Received-Date: Thu, 10 Dec 2015 03:40:16 -0000
\r
47 allow an incoming message to be delivered while indexing the
\r
50 This requires the secret keys for the message to be available. For
\r
51 the moment, the most functional approach is to ensure that gpg-agent
\r
52 is running and knows about any secret keys that might be useful to
\r
53 decrypt incoming mail.
\r
55 Any additional recommendations for how to phrase the caveat for this
\r
58 If ~/.notmuch-config contains crypto.gpg_path, pass it into the
\r
61 completion/notmuch-completion.bash | 2 +-
\r
62 doc/man1/notmuch-insert.rst | 11 +++++++++++
\r
63 notmuch-insert.c | 21 ++++++++++++++++++---
\r
64 3 files changed, 30 insertions(+), 4 deletions(-)
\r
66 diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash
\r
67 index cc58392..4bc9040 100644
\r
68 --- a/completion/notmuch-completion.bash
\r
69 +++ b/completion/notmuch-completion.bash
\r
70 @@ -224,7 +224,7 @@ _notmuch_insert()
\r
74 - local options="--create-folder --folder= --keep --no-hooks ${_notmuch_shared_options}"
\r
75 + local options="--create-folder --folder= --keep --no-hooks --try-decrypt ${_notmuch_shared_options}"
\r
77 COMPREPLY=( $(compgen -W "$options" -- ${cur}) )
\r
79 diff --git a/doc/man1/notmuch-insert.rst b/doc/man1/notmuch-insert.rst
\r
80 index 2c9c0d0..9c76b30 100644
\r
81 --- a/doc/man1/notmuch-insert.rst
\r
82 +++ b/doc/man1/notmuch-insert.rst
\r
83 @@ -50,6 +50,17 @@ Supported options for **insert** include
\r
85 Prevent hooks from being run.
\r
89 + If the message is encrypted, try to decrypt the message while
\r
90 + indexing. If decryption is successful, index the cleartext
\r
91 + itself. The message is stored to disk in its original form
\r
92 + (ciphertext). Be aware that the index is likely sufficient to
\r
93 + reconstruct the cleartext of the message itself, so please
\r
94 + ensure that the notmuch message index is adequately
\r
95 + protected. DO NOT USE THIS FLAG without considering the
\r
96 + security of your index.
\r
101 diff --git a/notmuch-insert.c b/notmuch-insert.c
\r
102 index 5205c17..9742574 100644
\r
103 --- a/notmuch-insert.c
\r
104 +++ b/notmuch-insert.c
\r
105 @@ -378,12 +378,15 @@ FAIL:
\r
107 static notmuch_status_t
\r
108 add_file (notmuch_database_t *notmuch, const char *path, tag_op_list_t *tag_ops,
\r
109 - notmuch_bool_t synchronize_flags, notmuch_bool_t keep)
\r
110 + notmuch_bool_t synchronize_flags, notmuch_bool_t keep, notmuch_bool_t try_decrypt)
\r
112 notmuch_message_t *message;
\r
113 notmuch_status_t status;
\r
115 - status = notmuch_database_add_message (notmuch, path, &message);
\r
117 + status = notmuch_database_add_message_try_decrypt (notmuch, path, &message);
\r
119 + status = notmuch_database_add_message (notmuch, path, &message);
\r
120 if (status == NOTMUCH_STATUS_SUCCESS) {
\r
121 status = tag_op_list_apply (message, tag_ops, 0);
\r
123 @@ -455,6 +458,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
\r
124 notmuch_bool_t create_folder = FALSE;
\r
125 notmuch_bool_t keep = FALSE;
\r
126 notmuch_bool_t no_hooks = FALSE;
\r
127 + notmuch_bool_t try_decrypt = FALSE;
\r
128 notmuch_bool_t synchronize_flags;
\r
129 const char *maildir;
\r
131 @@ -466,6 +470,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
\r
132 { NOTMUCH_OPT_BOOLEAN, &create_folder, "create-folder", 0, 0 },
\r
133 { NOTMUCH_OPT_BOOLEAN, &keep, "keep", 0, 0 },
\r
134 { NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 },
\r
135 + { NOTMUCH_OPT_BOOLEAN, &try_decrypt, "try-decrypt", 0, 0 },
\r
136 { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
\r
137 { NOTMUCH_OPT_END, 0, 0, 0, 0 }
\r
139 @@ -545,8 +550,18 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
\r
140 return EXIT_FAILURE;
\r
143 + if (try_decrypt) {
\r
144 + const char* gpg_path = notmuch_config_get_crypto_gpg_path (config);
\r
145 + status = notmuch_database_set_gpg_path(notmuch, gpg_path);
\r
147 + fprintf (stderr, "Warning: failed to set database gpg_path to '%s' (%s)\n",
\r
148 + gpg_path ? gpg_path : "(NULL)",
\r
149 + notmuch_status_to_string (status));
\r
153 /* Index the message. */
\r
154 - status = add_file (notmuch, newpath, tag_ops, synchronize_flags, keep);
\r
155 + status = add_file (notmuch, newpath, tag_ops, synchronize_flags, keep, try_decrypt);
\r
157 /* Commit changes. */
\r
158 close_status = notmuch_database_destroy (notmuch);
\r