Re: notmuch.el: controlling what does and doesn't get expanded in searches
[notmuch-archives.git] / db / 1e3702a36974680d4a496638611f27862750f4
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 olra.theworths.org (Postfix) with ESMTP id D4488429E35\r
6         for <notmuch@notmuchmail.org>; Sat, 17 Jan 2015 02:52:38 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 2.438\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id x1WBvNBePwsv for <notmuch@notmuchmail.org>;\r
16         Sat, 17 Jan 2015 02:52:36 -0800 (PST)\r
17 Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
18         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id A939B429E37\r
21         for <notmuch@notmuchmail.org>; Sat, 17 Jan 2015 02:52:21 -0800 (PST)\r
22 Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
23         (envelope-from <bremner@tesseract.cs.unb.ca>)\r
24         id 1YCQzN-0006C9-8y; Sat, 17 Jan 2015 06:52:21 -0400\r
25 Received: (nullmailer pid 14752 invoked by uid 1000); Sat, 17 Jan 2015\r
26         10:51:54 -0000\r
27 From: David Bremner <david@tethera.net>\r
28 To: Jameson Graef Rollins <jrollins@finestructure.net>, Notmuch Mail\r
29         <notmuch@notmuchmail.org>\r
30 Subject: [PATCH 2/4] cli: S/MIME verification/decryption support\r
31 Date: Sat, 17 Jan 2015 11:51:44 +0100\r
32 Message-Id: <1421491906-14542-3-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 2.1.4\r
34 In-Reply-To: <1421491906-14542-1-git-send-email-david@tethera.net>\r
35 References: <1395031944-15557-1-git-send-email-jrollins@finestructure.net>\r
36         <1421491906-14542-1-git-send-email-david@tethera.net>\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Sat, 17 Jan 2015 10:52:39 -0000\r
50 \r
51 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
52 \r
53 The notmuch-show flags --decrypt and --verify will now also process\r
54 S/MIME multiparts if encountered.  Requires gmime-2.6 and gpgsm.\r
55 ---\r
56  crypto.c         | 20 ++++++++++++++++++++\r
57  notmuch-client.h |  5 +++--\r
58  2 files changed, 23 insertions(+), 2 deletions(-)\r
59 \r
60 diff --git a/crypto.c b/crypto.c\r
61 index 6f4a6db..d66aa66 100644\r
62 --- a/crypto.c\r
63 +++ b/crypto.c\r
64 @@ -88,6 +88,21 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)\r
65                 fprintf (stderr, "Failed to construct gpg context.\n");\r
66         }\r
67         cryptoctx = crypto->gpgctx;\r
68 +#ifdef GMIME_ATLEAST_26\r
69 +    } else if ((strcasecmp (protocol, "application/pkcs7-signature") == 0)\r
70 +              || (strcasecmp (protocol, "application/x-pkcs7-signature") == 0)\r
71 +              || (strcasecmp (protocol, "application/pkcs7-encrypted") == 0)) {\r
72 +       if (! crypto->pkcs7ctx) {\r
73 +           /* TODO: GMimePasswordRequestFunc */\r
74 +           crypto->pkcs7ctx = g_mime_pkcs7_context_new (NULL);\r
75 +           if (crypto->pkcs7ctx) {\r
76 +               g_mime_pkcs7_context_set_always_trust ((GMimePkcs7Context*) crypto->pkcs7ctx, FALSE);\r
77 +           } else {\r
78 +               fprintf (stderr, "Failed to construct pkcs7 context.\n");\r
79 +           }\r
80 +       }\r
81 +       cryptoctx = crypto->pkcs7ctx;\r
82 +#endif\r
83      } else {\r
84         fprintf (stderr, "Unknown or unsupported cryptographic protocol.\n");\r
85      }\r
86 @@ -103,5 +118,10 @@ notmuch_crypto_cleanup (notmuch_crypto_t *crypto)\r
87         crypto->gpgctx = NULL;\r
88      }\r
89  \r
90 +    if (crypto->pkcs7ctx) {\r
91 +       g_object_unref (crypto->pkcs7ctx);\r
92 +       crypto->pkcs7ctx = NULL;\r
93 +    }\r
94 +\r
95      return 0;\r
96  }\r
97 diff --git a/notmuch-client.h b/notmuch-client.h\r
98 index 5e0d475..986f6cd 100644\r
99 --- a/notmuch-client.h\r
100 +++ b/notmuch-client.h\r
101 @@ -78,6 +78,7 @@ typedef struct notmuch_show_format {\r
102  \r
103  typedef struct notmuch_crypto {\r
104      notmuch_crypto_context_t* gpgctx;\r
105 +    notmuch_crypto_context_t* pkcs7ctx;\r
106      notmuch_bool_t verify;\r
107      notmuch_bool_t decrypt;\r
108  } notmuch_crypto_t;\r
109 @@ -414,8 +415,8 @@ struct mime_node {\r
110  /* Construct a new MIME node pointing to the root message part of\r
111   * message. If crypto->verify is true, signed child parts will be\r
112   * verified. If crypto->decrypt is true, encrypted child parts will be\r
113 - * decrypted.  If crypto->gpgctx is NULL, it will be lazily\r
114 - * initialized.\r
115 + * decrypted.  If the crypto contexts (crypto->gpgctx or\r
116 + * crypto->pkcs7) are NULL, they will be lazily initialized.\r
117   *\r
118   * Return value:\r
119   *\r
120 -- \r
121 2.1.4\r
122 \r