[git] GpgOL - branch, master, updated. gpgol-2.3.2-21-g5af5604

by Andre Heinecke cvs at cvs.gnupg.org
Mon Feb 11 15:49:09 CET 2019


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  5af56045e25714e2b86a6555d8d976eae47ee748 (commit)
       via  dafa897fd20ae16a45d980aab15adf01db66b491 (commit)
       via  b25b89ba61cd7117bf0f6e5d064afbd27f7c3bcb (commit)
       via  a3e70c63fc2d8c2dface0cfbdb01533ea71a75f8 (commit)
       via  4eabc9dd780b9fdedcb79b495ccde86b2af2e824 (commit)
       via  2808386bb5b403f80de78a9d6f0de23c8a010726 (commit)
      from  489141670fe292216d230b80bb943c267b5d262b (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 5af56045e25714e2b86a6555d8d976eae47ee748
Author: Andre Heinecke <aheinecke at gnupg.org>
Date:   Mon Feb 11 15:48:05 2019 +0100

    Handle autoimport for attached pgp keys
    
    * src/keycache.cpp (KeyCache::import_pgp_key_data): New.
    * src/keycache.h: Update accordingly.
    * src/parsecontroller.cpp (ParseController::parse): Check for
    pgp-keys attachments and import them.

diff --git a/src/keycache.cpp b/src/keycache.cpp
index 81580ae..9d6f5d2 100644
--- a/src/keycache.cpp
+++ b/src/keycache.cpp
@@ -1423,3 +1423,54 @@ KeyCache::getUltimateKeys ()
   gpgrt_lock_unlock (&fpr_map_lock);
   return ret;
 }
+
+/* static */
+bool
+KeyCache::import_pgp_key_data (const GpgME::Data &data)
+{
+  TSTART;
+  if (data.isNull())
+    {
+      STRANGEPOINT;
+      TRETURN false;
+    }
+  auto ctx = GpgME::Context::create(GpgME::OpenPGP);
+
+  if (!ctx)
+    {
+      STRANGEPOINT;
+      TRETURN false;
+    }
+
+  const auto type = data.type();
+
+  if (type != GpgME::Data::PGPKey)
+    {
+      log_debug ("%s:%s: Data does not look like PGP Keys",
+                 SRCNAME, __func__);
+      TRETURN false;
+    }
+  const auto keys = data.toKeys();
+
+  if (keys.empty())
+    {
+      log_debug ("%s:%s: Data does not contain PGP Keys",
+                 SRCNAME, __func__);
+      TRETURN false;
+    }
+
+  if (opt.enable_debug & DBG_DATA)
+    {
+      std::stringstream ss;
+      for (const auto &key: keys)
+        {
+          ss << key << '\n';
+        }
+      log_debug ("Importing keys: %s", ss.str().c_str());
+    }
+  const auto result = ctx->importKeys(keys);
+
+  log_debug ("%s:%s: Import result from attached key err: %s",
+             SRCNAME, __func__, result.error ().asString ());
+  TRETURN !result.error();
+}
diff --git a/src/keycache.h b/src/keycache.h
index 0a90575..0563e24 100644
--- a/src/keycache.h
+++ b/src/keycache.h
@@ -32,6 +32,7 @@
 namespace GpgME
 {
   class Key;
+  class Data;
 };
 
 class Mail;
@@ -130,6 +131,10 @@ public:
     /* Get a vector of ultimately trusted keys. */
     std::vector<GpgME::Key> getUltimateKeys ();
 
+    /* Import PGP Keys from a Data object. Returns
+       true on success. */
+    static bool import_pgp_key_data(const GpgME::Data &data);
+
     // Internal for thread
     void setSmimeKey(const std::string &mbox, const GpgME::Key &key);
     void setPgpKey(const std::string &mbox, const GpgME::Key &key);
diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index 4a72a65..309e587 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -546,6 +546,20 @@ ParseController::parse()
       m_block_html = true;
     }
 
+  /* Import any application/pgp-keys attachments if the option is set. */
+  if (opt.autoimport)
+    {
+      for (const auto &attach: get_attachments())
+        {
+          if (attach->get_content_type () == "application/pgp-keys")
+            {
+#ifndef BUILD_TESTS
+              KeyCache::import_pgp_key_data (attach->get_data());
+#endif
+            }
+        }
+    }
+
   if (opt.enable_debug & DBG_DATA)
     {
       std::stringstream ss;

commit dafa897fd20ae16a45d980aab15adf01db66b491
Author: Andre Heinecke <aheinecke at gnupg.org>
Date:   Mon Feb 11 15:46:00 2019 +0100

    Implement auto encrypt untrusted
    
    * src/keycache.cpp (getEncryptionKeys): Handle new option.
    
    --
    This allows opportunistic encryption to any key in the
    keyring. As this is problematic it is off by default.

diff --git a/src/keycache.cpp b/src/keycache.cpp
index 3352144..81580ae 100644
--- a/src/keycache.cpp
+++ b/src/keycache.cpp
@@ -574,6 +574,14 @@ public:
                 validEnough = true;
                 break;
               }
+            if (opt.auto_unstrusted &&
+                uid.validity() == GpgME::UserID::Unknown)
+              {
+                log_debug ("%s:%s: Passing unknown trust key for %s because of option",
+                           SRCNAME, __func__, anonstr (recip.c_str ()));
+                validEnough = true;
+                break;
+              }
           }
         if (!validEnough)
           {

commit b25b89ba61cd7117bf0f6e5d064afbd27f7c3bcb
Author: Andre Heinecke <aheinecke at gnupg.org>
Date:   Mon Feb 11 15:45:22 2019 +0100

    Add / parse new automation options
    
    * src/common_indep.h (opt): Add new fields.
    * src/main.c (read_options): Read them.

diff --git a/src/common_indep.h b/src/common_indep.h
index fb693ef..0a71914 100644
--- a/src/common_indep.h
+++ b/src/common_indep.h
@@ -206,6 +206,8 @@ struct
   int autoretrieve;           /* Use --auto-key-retrieve. */
   int search_smime_servers;  /* Search for S/MIME keys on all configured S/MIME keyservers
                                 for each new unknown mail */
+  int auto_unstrusted;       /* Automatically encrypt even to untrusted keys. */
+  int autoimport;            /* Automatically import keys from headers or attachments. */
 
   /* The forms revision number of the binary.  */
   int forms_revision;
diff --git a/src/main.c b/src/main.c
index 56b92ad..f61b9ee 100644
--- a/src/main.c
+++ b/src/main.c
@@ -299,6 +299,8 @@ read_options (void)
   opt.autotrust = get_conf_bool ("autotrust", 0);
   opt.search_smime_servers = get_conf_bool ("searchSmimeServers", 0);
   opt.smime_html_warn_shown = get_conf_bool ("smimeHtmlWarnShown", 0);
+  opt.auto_unstrusted = get_conf_bool ("autoencryptUntrusted", 0);
+  opt.autoimport = get_conf_bool ("autoimport", 0);
 
   if (!opt.automation)
     {
@@ -308,6 +310,8 @@ read_options (void)
       opt.autoresolve = 0;
       opt.autotrust = 0;
       opt.autoretrieve = 0;
+      opt.autoimport = 0;
+      opt.auto_unstrusted = 0;
     }
 
   /* Hidden options  */

commit a3e70c63fc2d8c2dface0cfbdb01533ea71a75f8
Author: Andre Heinecke <aheinecke at gnupg.org>
Date:   Mon Feb 11 15:44:15 2019 +0100

    Store content-type for attachments
    
    * src/attachment.cpp (get_content_type, set_content_type): New.
    * src/mimedataprovider.cpp (create_attachment): Set it.
    * src/attachment.h: Update accordingly.

diff --git a/src/attachment.cpp b/src/attachment.cpp
index e626d26..265483a 100644
--- a/src/attachment.cpp
+++ b/src/attachment.cpp
@@ -77,3 +77,15 @@ Attachment::get_content_id() const
 {
   return m_cid;
 }
+
+void
+Attachment::set_content_type(const char *ctype)
+{
+  m_ctype = ctype;
+}
+
+std::string
+Attachment::get_content_type() const
+{
+  return m_ctype;
+}
diff --git a/src/attachment.h b/src/attachment.h
index 92bcd78..79f91df 100644
--- a/src/attachment.h
+++ b/src/attachment.h
@@ -43,6 +43,10 @@ public:
   void set_content_id (const char *cid);
   std::string get_content_id() const;
 
+  /* Content type */
+  void set_content_type (const char *type);
+  std::string get_content_type () const;
+
   /* get the underlying data structure */
   GpgME::Data& get_data();
 
@@ -51,6 +55,7 @@ private:
   std::string m_utf8DisplayName;
   attachtype_t m_type;
   std::string m_cid;
+  std::string m_ctype;
 };
 
 #endif // ATTACHMENT_H
diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index be10e14..25e576c 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -1059,6 +1059,14 @@ MimeDataProvider::create_attachment()
   if (m_mime_ctx->mimestruct_cur && m_mime_ctx->mimestruct_cur->cid)
     {
       attach->set_content_id (m_mime_ctx->mimestruct_cur->cid);
+      log_data ("%s:%s: content-id: %s",
+                SRCNAME, __func__, m_mime_ctx->mimestruct_cur->cid);
+    }
+  if (m_mime_ctx->mimestruct_cur && m_mime_ctx->mimestruct_cur->content_type)
+    {
+      attach->set_content_type (m_mime_ctx->mimestruct_cur->content_type);
+      log_data ("%s:%s: content-type: %s",
+                SRCNAME, __func__, m_mime_ctx->mimestruct_cur->content_type);
     }
   m_attachments.push_back (attach);
 

commit 4eabc9dd780b9fdedcb79b495ccde86b2af2e824
Author: Andre Heinecke <aheinecke at gnupg.org>
Date:   Mon Feb 11 14:36:45 2019 +0100

    Fix syntax error
    
    * src/addin-options.cpp: Fix syntax.

diff --git a/src/addin-options.cpp b/src/addin-options.cpp
index 393bdaf..2e40bc5 100644
--- a/src/addin-options.cpp
+++ b/src/addin-options.cpp
@@ -84,10 +84,10 @@ i18n_noops[] = {
     N_("Also &with untrusted keys"),
     /* TRANSLATORS: Included means here both attached keys and keys from the
      * headers */
-    N_("&Import any keys included in mails.");
+    N_("&Import any keys included in mails."),
     /* TRANSLATORS: Included means here both attached keys and keys from the
      * headers */
-    N_("Import OpenPGP keys from mail attachments or from mail headers.");
+    N_("Import OpenPGP keys from mail attachments or from mail headers."),
 
     /* Not options but strings for the key adder */
     /* TRANSLATORS: Part of address book key configuration dialog.

commit 2808386bb5b403f80de78a9d6f0de23c8a010726
Author: Andre Heinecke <aheinecke at gnupg.org>
Date:   Mon Feb 11 14:35:52 2019 +0100

    Fix implicit fallthrough warnings
    
    * src/application-events.cpp: Fix unintentional fallthrough from
    QUIT.
    * src/mailitem-events.cpp: Mark reply fallthrough as intentional.

diff --git a/src/application-events.cpp b/src/application-events.cpp
index 5d8b9a8..06baaf7 100644
--- a/src/application-events.cpp
+++ b/src/application-events.cpp
@@ -100,6 +100,7 @@ EVENT_SINK_INVOKE(ApplicationEvents)
         {
           log_debug ("%s:%s: Quit event. Shutting down",
                      SRCNAME, __func__);
+          TBREAK;
         }
       default:
         log_oom ("%s:%s: Unhandled Event: %lx \n",
diff --git a/src/mailitem-events.cpp b/src/mailitem-events.cpp
index b251229..fa12d88 100644
--- a/src/mailitem-events.cpp
+++ b/src/mailitem-events.cpp
@@ -762,9 +762,8 @@ EVENT_SINK_INVOKE(MailItemEvents)
       /* Fallthrough */
       case ReplyAll:
       case Reply:
-        {
           is_reply = true;
-        }
+          __attribute__ ((fallthrough));
       case Forward:
         {
           log_oom ("%s:%s: %s : %p",

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

Summary of changes:
 src/addin-options.cpp      |  4 ++--
 src/application-events.cpp |  1 +
 src/attachment.cpp         | 12 ++++++++++
 src/attachment.h           |  5 ++++
 src/common_indep.h         |  2 ++
 src/keycache.cpp           | 59 ++++++++++++++++++++++++++++++++++++++++++++++
 src/keycache.h             |  5 ++++
 src/mailitem-events.cpp    |  3 +--
 src/main.c                 |  4 ++++
 src/mimedataprovider.cpp   |  8 +++++++
 src/parsecontroller.cpp    | 14 +++++++++++
 11 files changed, 113 insertions(+), 4 deletions(-)


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




More information about the Gnupg-commits mailing list