Re: notmuch and "mute" -- useful to anyone?
[notmuch-archives.git] / 26 / 0d0c0d6ebb8791709e8fe312941a631778abd1
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 2B3C76DE0B26\r
6  for <notmuch@notmuchmail.org>; Sun, 16 Aug 2015 08:34:24 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.129\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.129 tagged_above=-999 required=5 tests=[AWL=0.119, \r
12  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] 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 0VTWOAOrvhpZ for <notmuch@notmuchmail.org>;\r
16  Sun, 16 Aug 2015 08:34:21 -0700 (PDT)\r
17 Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
18  by arlo.cworth.org (Postfix) with ESMTPS id 5459C6DE01D3\r
19  for <notmuch@notmuchmail.org>; Sun, 16 Aug 2015 08:34:20 -0700 (PDT)\r
20 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
21  (envelope-from <bremner@tesseract.cs.unb.ca>)\r
22  id 1ZQzwI-0003E5-1s; Sun, 16 Aug 2015 15:33:38 +0000\r
23 Received: (nullmailer pid 11162 invoked by uid 1000); Sun, 16 Aug 2015\r
24  15:33:29 -0000\r
25 From: David Bremner <david@tethera.net>\r
26 To: notmuch@notmuchmail.org\r
27 Subject: [PATCH] cli/lib: remove support for GMime 2.4\r
28 Date: Sun, 16 Aug 2015 17:33:21 +0200\r
29 Message-Id: <1439739201-11068-1-git-send-email-david@tethera.net>\r
30 X-Mailer: git-send-email 2.5.0\r
31 X-BeenThere: notmuch@notmuchmail.org\r
32 X-Mailman-Version: 2.1.18\r
33 Precedence: list\r
34 List-Id: "Use and development of the notmuch mail system."\r
35  <notmuch.notmuchmail.org>\r
36 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
37  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
38 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
39 List-Post: <mailto:notmuch@notmuchmail.org>\r
40 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
41 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
42  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
43 X-List-Received-Date: Sun, 16 Aug 2015 15:34:24 -0000\r
44 \r
45 It's becoming a maintenance burden to do anything things with the\r
46 crypto glue code twice, once for 2.4 and once for 2.6. I don't have\r
47 any 2.4 version available to test on my development machine anymore,\r
48 so the 2.4 specific code paths are likely not very well tested.\r
49 ---\r
50 \r
51 I started to rebase the SMIME signature verification patches and got\r
52 aggravated at solving the same conflicts twice in every file.\r
53 \r
54 2.6.7 is from 2012, so that's a bit newer than some of our\r
55 requirements, but I think not so bad. YMMV.\r
56 \r
57  INSTALL        |  6 ++--\r
58  configure      | 49 ++++++++++-----------------------\r
59  crypto.c       | 25 -----------------\r
60  mime-node.c    | 83 -------------------------------------------------------\r
61  notmuch-show.c | 87 ----------------------------------------------------------\r
62  5 files changed, 17 insertions(+), 233 deletions(-)\r
63 \r
64 diff --git a/INSTALL b/INSTALL\r
65 index eaccd93..b1b9cd5 100644\r
66 --- a/INSTALL\r
67 +++ b/INSTALL\r
68 @@ -20,7 +20,7 @@ configure stage.\r
69  \r
70  Dependencies\r
71  ------------\r
72 -Notmuch depends on four libraries: Xapian, GMime 2.4 or 2.6,\r
73 +Notmuch depends on four libraries: Xapian, GMime 2.6,\r
74  Talloc, and zlib which are each described below:\r
75  \r
76         Xapian\r
77 @@ -39,8 +39,8 @@ Talloc, and zlib which are each described below:\r
78         reading mail while notmuch would wait for Xapian when removing\r
79         the "inbox" and "unread" tags from messages in a thread.\r
80  \r
81 -       GMime 2.4 or 2.6\r
82 -       ----------------\r
83 +       GMime  2.6\r
84 +       ----------\r
85         GMime provides decoding of MIME email messages for Notmuch.\r
86  \r
87         Without GMime, Notmuch would not be able to extract and index\r
88 diff --git a/configure b/configure\r
89 index d289880..440d678 100755\r
90 --- a/configure\r
91 +++ b/configure\r
92 @@ -71,16 +71,6 @@ WITH_BASH=1\r
93  WITH_RUBY=1\r
94  WITH_ZSH=1\r
95  \r
96 -# Compatible GMime versions (with constraints).\r
97 -# If using GMime 2.6, we need to have a version >= 2.6.5 to avoid a\r
98 -# crypto bug. We need 2.6.7 for permissive "From " header handling.\r
99 -GMIME_24_VERSION_CTR=''\r
100 -GMIME_24_VERSION="gmime-2.4 $GMIME_24_VERSION_CTR"\r
101 -GMIME_26_VERSION_CTR='>= 2.6.7'\r
102 -GMIME_26_VERSION="gmime-2.6 $GMIME_26_VERSION_CTR"\r
103 -\r
104 -WITH_GMIME_VERSIONS="$GMIME_26_VERSION;$GMIME_24_VERSION"\r
105 -\r
106  usage ()\r
107  {\r
108      cat <<EOF\r
109 @@ -140,10 +130,6 @@ Fine tuning of some installation directories is available:\r
110         --bashcompletiondir=DIR Bash completions files [SYSCONFDIR/bash_completion.d]\r
111         --zshcompletiondir=DIR  Zsh completions files [PREFIX/share/zsh/functions/Completion/Unix]\r
112  \r
113 -Some specific library versions can be specified (auto-detected otherwise):\r
114 -\r
115 -       --with-gmime-version=VERS       Specify GMIME version (2.4 or 2.6)\r
116 -\r
117  Some features can be disabled (--with-feature=no is equivalent to\r
118  --without-feature) :\r
119  \r
120 @@ -231,12 +217,6 @@ for option; do\r
121         fi\r
122      elif [ "${option}" = '--without-zsh-completion' ] ; then\r
123         WITH_ZSH=0\r
124 -    elif [ "${option%%=*}" = '--with-gmime-version' ] ; then\r
125 -       if [ "${option#*=}" = '2.4' ]; then\r
126 -            WITH_GMIME_VERSIONS=$GMIME_24_VERSION\r
127 -        elif [ "${option#*=}" = '2.6' ]; then\r
128 -            WITH_GMIME_VERSIONS=$GMIME_26_VERSION\r
129 -       fi\r
130      elif [ "${option%%=*}" = '--build' ] ; then\r
131         true\r
132      elif [ "${option%%=*}" = '--host' ] ; then\r
133 @@ -391,20 +371,19 @@ if [ ${have_xapian} = "1" ]; then\r
134      esac\r
135  fi\r
136  \r
137 +\r
138 +# we need to have a version >= 2.6.5 to avoid a crypto bug. We need\r
139 +# 2.6.7 for permissive "From " header handling.\r
140 +GMIME_MINVER=2.6.7\r
141 +\r
142  printf "Checking for GMime development files... "\r
143 -have_gmime=0\r
144 -IFS=';'\r
145 -for gmimepc in $WITH_GMIME_VERSIONS; do\r
146 -    if pkg-config --exists $gmimepc; then\r
147 -       printf "Yes ($gmimepc).\n"\r
148 -       have_gmime=1\r
149 -       gmime_cflags=$(pkg-config --cflags $gmimepc)\r
150 -       gmime_ldflags=$(pkg-config --libs $gmimepc)\r
151 -       break\r
152 -    fi\r
153 -done\r
154 -IFS=$DEFAULT_IFS\r
155 -if [ "$have_gmime" = "0" ]; then\r
156 +if pkg-config --exists "gmime-2.6 >= $GMIME_MINVER"; then\r
157 +    printf "Yes.\n"\r
158 +    have_gmime=1\r
159 +    gmime_cflags=$(pkg-config --cflags gmime-2.6)\r
160 +    gmime_ldflags=$(pkg-config --libs gmime-2.6)\r
161 +else\r
162 +    have_gmime=0\r
163      printf "No.\n"\r
164      errors=$((errors + 1))\r
165  fi\r
166 @@ -640,7 +619,7 @@ EOF\r
167         echo\r
168      fi\r
169      if [ $have_gmime -eq 0 ]; then\r
170 -       echo "  Either GMime 2.4 library" $GMIME_24_VERSION_CTR "or GMime 2.6 library" $GMIME_26_VERSION_CTR\r
171 +       echo "  GMime 2.6 library >= $GMIME_MINVER"\r
172         echo "  (including development files such as headers)"\r
173         echo "  http://spruce.sourceforge.net/gmime/"\r
174         echo\r
175 @@ -1026,7 +1005,7 @@ LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}\r
176  XAPIAN_CXXFLAGS = ${xapian_cxxflags}\r
177  XAPIAN_LDFLAGS = ${xapian_ldflags}\r
178  \r
179 -# Flags needed to compile and link against GMime-2.4\r
180 +# Flags needed to compile and link against GMime\r
181  GMIME_CFLAGS = ${gmime_cflags}\r
182  GMIME_LDFLAGS = ${gmime_ldflags}\r
183  \r
184 diff --git a/crypto.c b/crypto.c\r
185 index 026640f..a6eb27d 100644\r
186 --- a/crypto.c\r
187 +++ b/crypto.c\r
188 @@ -20,8 +20,6 @@\r
189  \r
190  #include "notmuch-client.h"\r
191  \r
192 -#ifdef GMIME_ATLEAST_26\r
193 -\r
194  /* Create a GPG context (GMime 2.6) */\r
195  static notmuch_crypto_context_t *\r
196  create_gpg_context (const char *gpgpath)\r
197 @@ -39,29 +37,6 @@ create_gpg_context (const char *gpgpath)\r
198      return gpgctx;\r
199  }\r
200  \r
201 -#else /* GMIME_ATLEAST_26 */\r
202 -\r
203 -/* Create a GPG context (GMime 2.4) */\r
204 -static notmuch_crypto_context_t *\r
205 -create_gpg_context (const char* gpgpath)\r
206 -{\r
207 -    GMimeSession *session;\r
208 -    notmuch_crypto_context_t *gpgctx;\r
209 -\r
210 -    session = g_object_new (g_mime_session_get_type (), NULL);\r
211 -    gpgctx = g_mime_gpg_context_new (session, gpgpath ? gpgpath : "gpg");\r
212 -    g_object_unref (session);\r
213 -\r
214 -    if (! gpgctx)\r
215 -       return NULL;\r
216 -\r
217 -    g_mime_gpg_context_set_always_trust ((GMimeGpgContext *) gpgctx, FALSE);\r
218 -\r
219 -    return gpgctx;\r
220 -}\r
221 -\r
222 -#endif /* GMIME_ATLEAST_26 */\r
223 -\r
224  /* for the specified protocol return the context pointer (initializing\r
225   * if needed) */\r
226  notmuch_crypto_context_t *\r
227 diff --git a/mime-node.c b/mime-node.c\r
228 index fd9e4a4..e96e663 100644\r
229 --- a/mime-node.c\r
230 +++ b/mime-node.c\r
231 @@ -129,8 +129,6 @@ DONE:\r
232      return status;\r
233  }\r
234  \r
235 -#ifdef GMIME_ATLEAST_26\r
236 -\r
237  /* Signature list destructor (GMime 2.6) */\r
238  static int\r
239  _signature_list_free (GMimeSignatureList **proxy)\r
240 @@ -205,87 +203,6 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part,\r
241         g_error_free (err);\r
242  }\r
243  \r
244 -#else /* GMIME_ATLEAST_26 */\r
245 -\r
246 -/* Signature validity destructor (GMime 2.4) */\r
247 -static int\r
248 -_signature_validity_free (GMimeSignatureValidity **proxy)\r
249 -{\r
250 -    g_mime_signature_validity_free (*proxy);\r
251 -    return 0;\r
252 -}\r
253 -\r
254 -/* Set up signature validity destructor (GMime 2.4) */\r
255 -static void\r
256 -set_signature_validity_destructor (mime_node_t *node,\r
257 -                                  GMimeSignatureValidity *sig_validity)\r
258 -{\r
259 -    GMimeSignatureValidity **proxy = talloc (node, GMimeSignatureValidity *);\r
260 -    if (proxy) {\r
261 -       *proxy = sig_validity;\r
262 -       talloc_set_destructor (proxy, _signature_validity_free);\r
263 -    }\r
264 -}\r
265 -\r
266 -/* Verify a signed mime node (GMime 2.4) */\r
267 -static void\r
268 -node_verify (mime_node_t *node, GMimeObject *part,\r
269 -            notmuch_crypto_context_t *cryptoctx)\r
270 -{\r
271 -    GError *err = NULL;\r
272 -    GMimeSignatureValidity *sig_validity;\r
273 -\r
274 -    node->verify_attempted = TRUE;\r
275 -    sig_validity = g_mime_multipart_signed_verify\r
276 -       (GMIME_MULTIPART_SIGNED (part), cryptoctx, &err);\r
277 -    node->sig_validity = sig_validity;\r
278 -    if (sig_validity) {\r
279 -       set_signature_validity_destructor (node, sig_validity);\r
280 -    } else {\r
281 -       fprintf (stderr, "Failed to verify signed part: %s\n",\r
282 -                err ? err->message : "no error explanation given");\r
283 -    }\r
284 -\r
285 -    if (err)\r
286 -       g_error_free (err);\r
287 -}\r
288 -\r
289 -/* Decrypt and optionally verify an encrypted mime node (GMime 2.4) */\r
290 -static void\r
291 -node_decrypt_and_verify (mime_node_t *node, GMimeObject *part,\r
292 -                        notmuch_crypto_context_t *cryptoctx)\r
293 -{\r
294 -    GError *err = NULL;\r
295 -    GMimeMultipartEncrypted *encrypteddata = GMIME_MULTIPART_ENCRYPTED (part);\r
296 -\r
297 -    node->decrypt_attempted = TRUE;\r
298 -    node->decrypted_child = g_mime_multipart_encrypted_decrypt\r
299 -       (encrypteddata, cryptoctx, &err);\r
300 -    if (! node->decrypted_child) {\r
301 -       fprintf (stderr, "Failed to decrypt part: %s\n",\r
302 -                err ? err->message : "no error explanation given");\r
303 -       goto DONE;\r
304 -    }\r
305 -\r
306 -    node->decrypt_success = TRUE;\r
307 -    node->verify_attempted = TRUE;\r
308 -\r
309 -    /* The GMimeSignatureValidity returned here is a const, unlike the\r
310 -     * one returned by g_mime_multipart_signed_verify() in\r
311 -     * node_verify() above, so the destructor is not needed.\r
312 -     */\r
313 -    node->sig_validity = g_mime_multipart_encrypted_get_signature_validity (encrypteddata);\r
314 -    if (! node->sig_validity)\r
315 -       fprintf (stderr, "Failed to verify encrypted signed part: %s\n",\r
316 -                err ? err->message : "no error explanation given");\r
317 -\r
318 - DONE:\r
319 -    if (err)\r
320 -       g_error_free (err);\r
321 -}\r
322 -\r
323 -#endif  /* GMIME_ATLEAST_26 */\r
324 -\r
325  static mime_node_t *\r
326  _mime_node_create (mime_node_t *parent, GMimeObject *part)\r
327  {\r
328 diff --git a/notmuch-show.c b/notmuch-show.c\r
329 index b80933a..21015fd 100644\r
330 --- a/notmuch-show.c\r
331 +++ b/notmuch-show.c\r
332 @@ -334,8 +334,6 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out,\r
333         g_object_unref(stream_filter);\r
334  }\r
335  \r
336 -#ifdef GMIME_ATLEAST_26\r
337 -\r
338  /* Get signature status string (GMime 2.6) */\r
339  static const char*\r
340  signature_status_to_string (GMimeSignatureStatus x)\r
341 @@ -427,91 +425,6 @@ format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)\r
342      sp->end (sp);\r
343  }\r
344  \r
345 -#else /* GMIME_ATLEAST_26 */\r
346 -\r
347 -/* Get signature status string (GMime 2.4) */\r
348 -static const char*\r
349 -signer_status_to_string (GMimeSignerStatus x)\r
350 -{\r
351 -    switch (x) {\r
352 -    case GMIME_SIGNER_STATUS_NONE:\r
353 -       return "none";\r
354 -    case GMIME_SIGNER_STATUS_GOOD:\r
355 -       return "good";\r
356 -    case GMIME_SIGNER_STATUS_BAD:\r
357 -       return "bad";\r
358 -    case GMIME_SIGNER_STATUS_ERROR:\r
359 -       return "error";\r
360 -    }\r
361 -    return "unknown";\r
362 -}\r
363 -\r
364 -/* Signature status sprinter (GMime 2.4) */\r
365 -static void\r
366 -format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)\r
367 -{\r
368 -    const GMimeSignatureValidity* validity = node->sig_validity;\r
369 -\r
370 -    sp->begin_list (sp);\r
371 -\r
372 -    if (!validity) {\r
373 -       sp->end (sp);\r
374 -       return;\r
375 -    }\r
376 -\r
377 -    const GMimeSigner *signer = g_mime_signature_validity_get_signers (validity);\r
378 -    while (signer) {\r
379 -       sp->begin_map (sp);\r
380 -\r
381 -       /* status */\r
382 -       sp->map_key (sp, "status");\r
383 -       sp->string (sp, signer_status_to_string (signer->status));\r
384 -\r
385 -       if (signer->status == GMIME_SIGNER_STATUS_GOOD)\r
386 -       {\r
387 -           if (signer->fingerprint) {\r
388 -               sp->map_key (sp, "fingerprint");\r
389 -               sp->string (sp, signer->fingerprint);\r
390 -           }\r
391 -           /* these dates are seconds since the epoch; should we\r
392 -            * provide a more human-readable format string? */\r
393 -           if (signer->created) {\r
394 -               sp->map_key (sp, "created");\r
395 -               sp->integer (sp, signer->created);\r
396 -           }\r
397 -           if (signer->expires) {\r
398 -               sp->map_key (sp, "expires");\r
399 -               sp->integer (sp, signer->expires);\r
400 -           }\r
401 -           /* output user id only if validity is FULL or ULTIMATE. */\r
402 -           /* note that gmime is using the term "trust" here, which\r
403 -            * is WRONG.  It's actually user id "validity". */\r
404 -           if ((signer->name) && (signer->trust)) {\r
405 -               if ((signer->trust == GMIME_SIGNER_TRUST_FULLY) || (signer->trust == GMIME_SIGNER_TRUST_ULTIMATE)) {\r
406 -                   sp->map_key (sp, "userid");\r
407 -                   sp->string (sp, signer->name);\r
408 -               }\r
409 -           }\r
410 -       } else {\r
411 -           if (signer->keyid) {\r
412 -              sp->map_key (sp, "keyid");\r
413 -              sp->string (sp, signer->keyid);\r
414 -          }\r
415 -       }\r
416 -       if (signer->errors != GMIME_SIGNER_ERROR_NONE) {\r
417 -          sp->map_key (sp, "errors");\r
418 -          sp->integer (sp, signer->errors);\r
419 -       }\r
420 -\r
421 -       sp->end (sp);\r
422 -       signer = signer->next;\r
423 -    }\r
424 -\r
425 -    sp->end (sp);\r
426 -}\r
427 -\r
428 -#endif /* GMIME_ATLEAST_26 */\r
429 -\r
430  static notmuch_status_t\r
431  format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
432                   int indent, const notmuch_show_params_t *params)\r
433 -- \r
434 2.5.0\r
435 \r