[git] GpgOL - branch, master, updated. gpgol-1.4.0-238-gabaca16

by Andre Heinecke cvs at cvs.gnupg.org
Fri Jan 6 15:12:00 CET 2017


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  abaca16b9019781359c105944ea22adf3f6fa4c8 (commit)
      from  3cfdd110a195ed02059d533d43fdb66da56d1852 (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 abaca16b9019781359c105944ea22adf3f6fa4c8
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jan 6 15:09:07 2017 +0100

    Warn if partial crypto with attachments is found
    
    * src/mail.cpp (Mail::check_attachments): Check if
    all attachments are hidden and warn otherwise.
    (Mail::parsing_done): Call check_attachments.
    * src/mail.h: Update accordingly.
    * src/oomhelp.p: Add new DASL.
    
    --
    This is important for inline Crypto mails where Attachments
    may not have been signed or encrypted.
    
    For MIME Mails we don't have the problem as we only handle
    Crypto MIME Mails if the top level mime part is a crypto part
    and so everything is crypto or not.

diff --git a/src/mail.cpp b/src/mail.cpp
index 95df6fd..5fed0f6 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -258,6 +258,89 @@ get_attachment (LPDISPATCH mailitem, int pos)
   return attachment;
 }
 
+/** Helper to check that all attachments are hidden, to be
+  called before crypto. */
+int
+Mail::check_attachments () const
+{
+  LPDISPATCH attachments = get_oom_object (m_mailitem, "Attachments");
+  if (!attachments)
+    {
+      log_debug ("%s:%s: Failed to get attachments.",
+                 SRCNAME, __func__);
+      return 1;
+    }
+  int count = get_oom_int (attachments, "Count");
+  if (!count)
+    {
+      gpgol_release (attachments);
+      return 0;
+    }
+
+  std::string message;
+
+  if (is_encrypted () && is_signed ())
+    {
+      message += _("Not all attachments were encrypted or signed.\n"
+                   "The unsigned / unencrypted attachments are:\n\n");
+    }
+  else if (is_signed ())
+    {
+      message += _("Not all attachments were signed.\n"
+                   "The unsigned attachments are:\n\n");
+    }
+  else if (is_encrypted ())
+    {
+      message += _("Not all attachments were encrypted.\n"
+                   "The unencrypted attachments are:\n\n");
+    }
+  else
+    {
+      gpgol_release (attachments);
+      return 0;
+    }
+
+  bool foundOne = false;
+
+  for (int i = 1; i <= count; i++)
+    {
+      std::string item_str;
+      item_str = std::string("Item(") + std::to_string (i) + ")";
+      LPDISPATCH oom_attach = get_oom_object (attachments, item_str.c_str ());
+      if (!oom_attach)
+        {
+          log_error ("%s:%s: Failed to get attachment.",
+                     SRCNAME, __func__);
+          continue;
+        }
+      VARIANT var;
+      VariantInit (&var);
+      if (get_pa_variant (oom_attach, PR_ATTACHMENT_HIDDEN_DASL, &var) ||
+          (var.vt == VT_BOOL && var.boolVal == VARIANT_FALSE))
+        {
+          foundOne = true;
+          message += get_oom_string (oom_attach, "DisplayName");
+          message += "\n";
+        }
+      VariantClear (&var);
+      gpgol_release (oom_attach);
+    }
+  if (foundOne)
+    {
+      message += "\n";
+      message += _("Note: The attachments may be encrypted or signed "
+                    "on a file level but the GpgOL status does not apply to them.");
+      wchar_t *wmsg = utf8_to_wchar (message.c_str ());
+      wchar_t *wtitle = utf8_to_wchar (_("GpgOL Warning"));
+      MessageBoxW (get_active_hwnd (), wmsg, wtitle,
+                   MB_ICONWARNING|MB_OK);
+      xfree (wmsg);
+      xfree (wtitle);
+    }
+  gpgol_release (attachments);
+  return 0;
+}
+
 /** Get the cipherstream of the mailitem. */
 static LPSTREAM
 get_attachment_stream (LPDISPATCH mailitem, int pos)
@@ -730,6 +813,9 @@ Mail::parsing_done()
   update_body();
   TRACEPOINT;
 
+  /* Check that there are no unsigned / unencrypted messages. */
+  check_attachments ();
+
   /* Update attachments */
   if (add_attachments (m_mailitem, m_parser->get_attachments()))
     {
diff --git a/src/mail.h b/src/mail.h
index bba161a..b61569c 100644
--- a/src/mail.h
+++ b/src/mail.h
@@ -320,6 +320,10 @@ public:
     https://wiki.gnupg.org/EasyGpg2016/AutomatedEncryption for
     a definition of the levels. */
   int get_signature_level () const;
+
+  /** Check if all attachments are hidden and show a warning
+    message appropiate to the crypto state if necessary. */
+  int check_attachments () const;
 private:
   void update_categories ();
   void update_body ();
diff --git a/src/oomhelp.h b/src/oomhelp.h
index 3914f5e..3c94c3b 100644
--- a/src/oomhelp.h
+++ b/src/oomhelp.h
@@ -84,6 +84,11 @@ DEFINE_OLEGUID(IID_IOleWindow,                0x00000114, 0, 0);
   "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
 #endif
 
+#ifndef PR_ATTACHMENT_HIDDEN_DASL
+#define PR_ATTACHMENT_HIDDEN_DASL \
+  "http://schemas.microsoft.com/mapi/proptag/0x7FFE000B"
+#endif
+
 #define PR_MESSAGE_CLASS_W_DASL \
   "http://schemas.microsoft.com/mapi/proptag/0x001A001F"
 #define GPGOL_ATTACHTYPE_DASL \

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

Summary of changes:
 src/mail.cpp  | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/mail.h    |  4 +++
 src/oomhelp.h |  5 ++++
 3 files changed, 95 insertions(+)


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




More information about the Gnupg-commits mailing list