[git] GpgOL - branch, master, updated. gpgol-2.0.6-125-g7cb3fea

by Andre Heinecke cvs at cvs.gnupg.org
Tue Apr 10 15:54:03 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, master has been updated
       via  7cb3feaf64d3098a5bc56cad62576bb67e5d74bf (commit)
       via  11ed13c4ee60b5f2b6ed8c46591f60ce92125f0b (commit)
       via  be8a7af4db06f5f8c479b550a84f96145e239030 (commit)
       via  6219c5bb703e680eaff2b15e1f1cb262117b4927 (commit)
      from  1441f6710db976c76b5cb64073be05b318df84ce (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7cb3feaf64d3098a5bc56cad62576bb67e5d74bf
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Apr 10 15:49:21 2018 +0200

    Make S/MIME compatible with Exchange 2016 patched
    
    * src/oomhelp.h (PR_PIDNameContentType_DASL): New.
    * src/mimemaker.cpp (create_top_encryption_header): We no longer
    create the header ourself.
    * src/mail.cpp (Mail::update_crypt_oom): Here we set the header
    values now.
    * src/cryptcontroller.h (CryptController::get_protocol)
    (CryptController::is_encrypter): New accessors.
    * src/cryptcontroller.cpp (create_encrypt_attach): Write binary
    data for S/MIME. Outlook will do the base64 conversion.
    
    --
    This fixes a lot of interop issues. Otherwise we would
    either have weirdly structured mails or mails without smime-type
    header or mails where the pkcs7-mime part was doubly base64
    encoded with the inner encoding containing the headers.
    
    Hope this works with older Exchanges and Outlooks.
    
    GnuPG-Bug-Id: T3884

diff --git a/src/cryptcontroller.cpp b/src/cryptcontroller.cpp
index 1065f6e..5aa1022 100644
--- a/src/cryptcontroller.cpp
+++ b/src/cryptcontroller.cpp
@@ -838,15 +838,8 @@ create_encrypt_attach (sink_t sink, protocol_t protocol,
       return rc;
     }
 
-  if (protocol == PROTOCOL_OPENPGP)
-    {
-      rc = write_data (sink, encryptedData);
-    }
-  else
-    {
-      const auto encStr = encryptedData.toString();
-      rc = write_b64 (sink, encStr.c_str(), encStr.size());
-    }
+  rc = write_data (sink, encryptedData);
+
   if (rc)
     {
       log_error ("%s:%s: Failed to create top header.",
diff --git a/src/cryptcontroller.h b/src/cryptcontroller.h
index 67b67c4..8bcf1d4 100644
--- a/src/cryptcontroller.h
+++ b/src/cryptcontroller.h
@@ -64,6 +64,12 @@ public:
   /** @brief Get an inline body as std::string. */
   std::string get_inline_data ();
 
+  /** @brief Get the protocol. Valid after do_crypto. */
+  GpgME::Protocol get_protocol () const { return m_proto; }
+
+  /** @brief check weather something was encrypted. */
+  bool is_encrypter () const { return m_encrypt; }
+
 private:
   int resolve_keys ();
   int resolve_keys_cached ();
diff --git a/src/mail.cpp b/src/mail.cpp
index df7d0f2..ea2f65a 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -2613,6 +2613,21 @@ Mail::update_crypt_oom()
           return;
         }
     }
+
+  if (m_crypter->get_protocol () == GpgME::CMS && m_crypter->is_encrypter ())
+    {
+      /* We put the PIDNameContentType headers here for exchange
+         because this is the only way we found to inject the
+         smime-type. */
+      if (put_pa_string (m_mailitem,
+                         PR_PIDNameContentType_DASL,
+                         "application/pkcs7-mime;smime-type=\"enveloped-data\";name=smime.p7m"))
+        {
+          log_debug ("%s:%s: Failed to put PIDNameContentType for %p.",
+                     SRCNAME, __func__, this);
+        }
+    }
+
   /** When doing async update_crypt_mapi follows and needs
     the crypter. */
   if (async_crypt_disabled ())
diff --git a/src/mimemaker.cpp b/src/mimemaker.cpp
index a7e9959..ed961f7 100644
--- a/src/mimemaker.cpp
+++ b/src/mimemaker.cpp
@@ -1915,6 +1915,16 @@ create_top_encryption_header (sink_t sink, protocol_t protocol, char *boundary,
   else if (protocol == PROTOCOL_SMIME)
     {
       *boundary = 0;
+      rc = 0;
+      /*
+        For S/MIME encrypted mails we do not use the S/MIME conversion
+        code anymore. With Exchange 2016 this no longer works. Instead
+        we set an override mime tag, the extended headers in OOM in
+        Mail::update_crypt_oom and let outlook convert the attachment
+        to base64.
+
+        A bit more details can be found in T3853 / T3884
+
       rc = write_multistring (sink,
                               "Content-Type: application/pkcs7-mime; "
                               "smime-type=enveloped-data;\r\n"
@@ -1924,6 +1934,7 @@ create_top_encryption_header (sink_t sink, protocol_t protocol, char *boundary,
                               "MIME-Version: 1.0\r\n"
                               "\r\n",
                               NULL);
+      */
     }
   else
     {
diff --git a/src/oomhelp.h b/src/oomhelp.h
index cbc36ca..3bf86a6 100644
--- a/src/oomhelp.h
+++ b/src/oomhelp.h
@@ -117,6 +117,8 @@ DEFINE_OLEGUID(IID_IOleWindow,                0x00000114, 0, 0);
   "http://schemas.microsoft.com/mapi/proptag/0x5D01001F"
 #define PR_TAG_RECEIVED_REPRESENTING_SMTP_ADDRESS \
   "http://schemas.microsoft.com/mapi/proptag/0x5D08001F"
+#define PR_PIDNameContentType_DASL \
+  "http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/content-type/0x0000001F"
 
 #ifdef __cplusplus
 extern "C" {

commit 11ed13c4ee60b5f2b6ed8c46591f60ce92125f0b
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Apr 10 15:48:08 2018 +0200

    Improve acceptance of the parser
    
    * src/mimedataprovider.cpp (MimeDataProvider::collect_data): Relax.
    If a message starts with Content-Type it's probably a mime structure.

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index ff6538c..6b761b1 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -804,6 +804,19 @@ MimeDataProvider::collect_data(LPSTREAM stream)
                          SRCNAME, __func__);
 
             }
+          else if (bRead > 12 && !strncmp ("Content-Type:", buf, 13))
+            {
+              /* Similar as above but we messed with the order of the headers
+                 for some s/mime mails. So also check for content type.
+
+                 Want some cheese with that hack?
+              */
+              m_collect_everything = false;
+              log_debug ("%s:%s: Found Content-Type header."
+                         "Expecting headers even if type suggested not to.",
+                         SRCNAME, __func__);
+
+            }
           /* check for the PGP MESSAGE marker to see if we have it. */
           if (bRead && m_collect_everything)
             {

commit be8a7af4db06f5f8c479b550a84f96145e239030
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Apr 10 13:14:42 2018 +0200

    Handle error in mapi update
    
    * src/mail.cpp (do_crypt): Handle error in mapi update.

diff --git a/src/mail.cpp b/src/mail.cpp
index bd28cc3..df7d0f2 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -854,7 +854,19 @@ do_crypt (LPVOID arg)
     {
       mail->set_crypt_state (Mail::NeedsUpdateInMAPI);
       mail->update_crypt_mapi ();
-      mail->set_crypt_state (Mail::NeedsUpdateInOOM);
+      if (mail->crypt_state () == Mail::WantsSendMIME)
+        {
+          // For sync crypto we need to switch this.
+          mail->set_crypt_state (Mail::NeedsUpdateInOOM);
+        }
+      else
+        {
+          // A bug!
+          log_debug ("%s:%s: Resetting crypter because of state mismatch. %p",
+                     SRCNAME, __func__, arg);
+          crypter = nullptr;
+          mail->reset_crypter ();
+        }
       gpgrt_lock_unlock (&dtor_lock);
     }
   /* This works around a bug in pinentry that it might

commit 6219c5bb703e680eaff2b15e1f1cb262117b4927
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Apr 10 13:12:35 2018 +0200

    Sleep a bit before bringing window to front
    
    * src/common.c (bring_to_front): log when done.
    * src/windowmessages.cpp (gpgol_window_proc): Sleep a bit
    before bring to front.
    
    --
    This might resolve an observed deadlock where setforegroundwindow
    would block the UI thread as it tried to bring the disabled
    mail window to front. Might also help with:
    
    GnuPG-Bug-Id: T3889

diff --git a/src/common.c b/src/common.c
index 6f1ac56..a9ac04b 100644
--- a/src/common.c
+++ b/src/common.c
@@ -260,6 +260,7 @@ bring_to_front (HWND wid)
             }
         }
     }
+  log_debug ("%s:%s: done", SRCNAME, __func__);
 }
 
 void
diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp
index 9d96956..73292d1 100644
--- a/src/windowmessages.cpp
+++ b/src/windowmessages.cpp
@@ -159,6 +159,9 @@ gpgol_window_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
             }
           case (BRING_TO_FRONT):
             {
+              // We want to avoid a race where the mail window
+              // was still the active window.
+              Sleep (250);
               HWND wnd = get_active_hwnd ();
               if (wnd)
                 {

-----------------------------------------------------------------------

Summary of changes:
 src/common.c             |  1 +
 src/cryptcontroller.cpp  | 11 ++---------
 src/cryptcontroller.h    |  6 ++++++
 src/mail.cpp             | 29 ++++++++++++++++++++++++++++-
 src/mimedataprovider.cpp | 13 +++++++++++++
 src/mimemaker.cpp        | 11 +++++++++++
 src/oomhelp.h            |  2 ++
 src/windowmessages.cpp   |  3 +++
 8 files changed, 66 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list