[git] GpgOL - branch, master, updated. gpgol-1.4.0-267-g57bd437

by Andre Heinecke cvs at cvs.gnupg.org
Sun May 14 12:21:04 CEST 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  57bd43759afbf8609eaa8adf6fde801b367d2353 (commit)
       via  175acbd0ed9dd5a5727775f44fe9f3bf6ab0cb68 (commit)
       via  7d3af16035a5c874d3560ca95de331caf18171ec (commit)
       via  9ae192e3e3851cd57d2a8ff62963f93fef398264 (commit)
      from  001abffeed64d8627e896b2e18321991de46041e (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 57bd43759afbf8609eaa8adf6fde801b367d2353
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Sun May 14 10:54:40 2017 +0200

    Make it possible to register locally as user
    
    * src/olflange.cpp (DllRegisterServer): Register depending on
    elevation level.

diff --git a/src/olflange.cpp b/src/olflange.cpp
index 0483337..af0eae9 100644
--- a/src/olflange.cpp
+++ b/src/olflange.cpp
@@ -124,6 +124,18 @@ DllRegisterServer (void)
   TCHAR szModuleFileName[MAX_PATH];
   DWORD dwTemp = 0;
   long ec;
+  HKEY root_key;
+
+  int inst_global = is_elevated ();
+
+  if (inst_global)
+    {
+      root_key = HKEY_LOCAL_MACHINE;
+    }
+  else
+    {
+      root_key = HKEY_CURRENT_USER;
+    }
 
   /* Get server location. */
   if (!GetModuleFileName(glob_hinst, szModuleFileName, MAX_PATH))
@@ -165,7 +177,7 @@ DllRegisterServer (void)
      -    IExchExtModelessCallback
                    ___1234567___ */
   lstrcat (szEntry, ";11111101");
-  ec = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szKeyBuf, 0, NULL,
+  ec = RegCreateKeyEx (root_key, szKeyBuf, 0, NULL,
                        REG_OPTION_NON_VOLATILE,
                        KEY_ALL_ACCESS, NULL, &hkey, NULL);
   if (ec != ERROR_SUCCESS)
@@ -210,9 +222,21 @@ DllRegisterServer (void)
 
   /* Register the CLSID in the registry */
   hkey = NULL;
-  strcpy (szKeyBuf, "CLSID\\" CLSIDSTR_GPGOL);
-  ec = RegCreateKeyEx (HKEY_CLASSES_ROOT, szKeyBuf, 0, NULL,
-                  REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL);
+
+  if (inst_global)
+    {
+      strcpy (szKeyBuf, "CLSID\\" CLSIDSTR_GPGOL);
+      ec = RegCreateKeyEx (HKEY_CLASSES_ROOT, szKeyBuf, 0, NULL,
+                   REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL);
+      OutputDebugString("Created: ");
+      OutputDebugString(szKeyBuf);
+    }
+  else
+    {
+      strcpy (szKeyBuf, "Software\\Classes\\CLSID\\" CLSIDSTR_GPGOL);
+      ec = RegCreateKeyEx (HKEY_CURRENT_USER, szKeyBuf, 0, NULL,
+                   REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL);
+    }
   if (ec != ERROR_SUCCESS)
     {
       fprintf (stderr, "creating key `%s' failed: ec=%#lx\n", szKeyBuf, ec);
@@ -261,9 +285,20 @@ DllRegisterServer (void)
    * Extension
    */
   hkey = NULL;
-  strcpy (szKeyBuf, GPGOL_PROGID);
-  ec = RegCreateKeyEx (HKEY_CLASSES_ROOT, szKeyBuf, 0, NULL,
-                  REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL);
+
+  if (inst_global)
+    {
+      strcpy (szKeyBuf, GPGOL_PROGID);
+      ec = RegCreateKeyEx (HKEY_CLASSES_ROOT, szKeyBuf, 0, NULL,
+                      REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL);
+    }
+  else
+    {
+      strcpy (szKeyBuf, "Software\\Classes\\" GPGOL_PROGID);
+      ec = RegCreateKeyEx (HKEY_CURRENT_USER, szKeyBuf, 0, NULL,
+                      REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL);
+
+    }
   if (ec != ERROR_SUCCESS)
     {
       fprintf (stderr, "creating key `%s' failed: ec=%#lx\n", szKeyBuf, ec);
@@ -292,7 +327,7 @@ DllRegisterServer (void)
   /* Register ourself as an extension for outlook >= 14 */
 
   strcpy (szKeyBuf, "Software\\Microsoft\\Office\\Outlook\\Addins\\" GPGOL_PROGID);
-  ec = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szKeyBuf, 0, NULL,
+  ec = RegCreateKeyEx (root_key, szKeyBuf, 0, NULL,
                   REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL);
   if (ec != ERROR_SUCCESS)
     {
@@ -335,10 +370,20 @@ DllUnregisterServer (void)
   CHAR buf[MAX_PATH+1024];
   DWORD ntemp;
   long res;
+  HKEY root_key;
+
+  if (is_elevated ())
+    {
+      root_key = HKEY_LOCAL_MACHINE;
+    }
+  else
+    {
+      root_key = HKEY_CURRENT_USER;
+    }
 
   strcpy (buf, "Software\\Microsoft\\Exchange\\Client\\Extensions");
   /* Create and open key and subkey. */
-  res = RegCreateKeyEx (HKEY_LOCAL_MACHINE, buf, 0, NULL,
+  res = RegCreateKeyEx (root_key, buf, 0, NULL,
 			REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
 			NULL, &hkey, NULL);
   if (res != ERROR_SUCCESS)
@@ -371,7 +416,7 @@ DllUnregisterServer (void)
 
   /* Delete Addin entry */
   strcpy (buf, "Software\\Microsoft\\Office\\Outlook\\Addins\\" GPGOL_PROGID);
-  RegDeleteKey (HKEY_LOCAL_MACHINE, buf);
+  RegDeleteKey (root_key, buf);
 
   return S_OK;
 }

commit 175acbd0ed9dd5a5727775f44fe9f3bf6ab0cb68
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Sun May 14 10:53:10 2017 +0200

    Add UAC elevation check
    
    * src/common.c (is_elevated, has_high_integrity): New.
    * src/common.h (is_elevated): Exposed.

diff --git a/src/common.c b/src/common.c
index 47cd772..98cb264 100644
--- a/src/common.c
+++ b/src/common.c
@@ -1,6 +1,6 @@
 /* common.c - Common routines used by GpgOL
  * Copyright (C) 2005, 2007, 2008 g10 Code GmbH
- * Copyright (C) 2015, 2016 by Bundesamt für Sicherheit in der Informationstechnik
+ * 2015, 2016, 2017  Bundesamt für Sicherheit in der Informationstechnik
  * Software engineering by Intevation GmbH
  *
  * This file is part of GpgOL.
@@ -927,3 +927,80 @@ get_uiserver_name (void)
   log_error ("Failed to find a viable UIServer");
   return NULL;
 }
+
+int
+has_high_integrity(HANDLE hToken)
+{
+  PTOKEN_MANDATORY_LABEL integrity_label = NULL;
+  DWORD integrity_level = 0,
+        size = 0;
+
+
+  if (hToken == NULL || hToken == INVALID_HANDLE_VALUE)
+    {
+      log_debug ("Invalid parameters.");
+      return 0;
+    }
+
+  /* Get the required size */
+  if (!GetTokenInformation (hToken, TokenIntegrityLevel,
+                            NULL, 0, &size))
+    {
+      if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+        {
+          log_debug ("Failed to get required size.\n");
+          return 0;
+        }
+    }
+  integrity_label = (PTOKEN_MANDATORY_LABEL) LocalAlloc(0, size);
+  if (integrity_label == NULL)
+    {
+      log_debug ("Failed to allocate label. \n");
+      return 0;
+    }
+
+  if (!GetTokenInformation (hToken, TokenIntegrityLevel,
+                            integrity_label, size, &size))
+    {
+      log_debug ("Failed to get integrity level.\n");
+      LocalFree(integrity_label);
+      return 0;
+    }
+
+  /* Get the last integrity level */
+  integrity_level = *GetSidSubAuthority(integrity_label->Label.Sid,
+                     (DWORD)(UCHAR)(*GetSidSubAuthorityCount(
+                        integrity_label->Label.Sid) - 1));
+
+  LocalFree (integrity_label);
+
+  return integrity_level >= SECURITY_MANDATORY_HIGH_RID;
+}
+
+int
+is_elevated()
+{
+  int ret = 0;
+  HANDLE hToken = NULL;
+  if (OpenProcessToken (GetCurrentProcess(), TOKEN_QUERY, &hToken))
+    {
+      DWORD elevation;
+      DWORD cbSize = sizeof (DWORD);
+      if (GetTokenInformation (hToken, TokenElevation, &elevation,
+                               sizeof (TokenElevation), &cbSize))
+        {
+          ret = elevation;
+        }
+    }
+  /* Elevation will be true and ElevationType TokenElevationTypeFull even
+     if the token is a user token created by SAFER so we additionally
+     check the integrity level of the token which will only be high in
+     the real elevated process and medium otherwise. */
+
+  ret = ret && has_high_integrity (hToken);
+
+  if (hToken)
+    CloseHandle (hToken);
+
+  return ret;
+}
diff --git a/src/common.h b/src/common.h
index b703596..09c6072 100644
--- a/src/common.h
+++ b/src/common.h
@@ -125,6 +125,8 @@ char *format_date_from_gpgme (unsigned long time);
 /* Get the name of the uiserver */
 char *get_uiserver_name (void);
 
+int is_elevated (void);
+
 /*-- main.c --*/
 const void *get_128bit_session_key (void);
 const void *get_64bit_session_marker (void);

commit 7d3af16035a5c874d3560ca95de331caf18171ec
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon May 8 10:59:54 2017 +0200

    Fix implicit vector include
    
    * src/mimedataprovider.cpp: Fix build with newer stdc++ lib.

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index 7e4d712..82a84f0 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -21,6 +21,7 @@
 #include "common_indep.h"
 #include "xmalloc.h"
 #include <string.h>
+#include <vector>
 
 #include "mimedataprovider.h"
 #include "parsetlv.h"

commit 9ae192e3e3851cd57d2a8ff62963f93fef398264
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon May 8 10:12:24 2017 +0200

    Fix misleading indentation warning
    
    * src/w32-gettext.c (internal_gettext): Fix misleading indentation
    warning.

diff --git a/src/w32-gettext.c b/src/w32-gettext.c
index a073bc4..30ff0a0 100644
--- a/src/w32-gettext.c
+++ b/src/w32-gettext.c
@@ -1722,26 +1722,26 @@ internal_gettext (const char *msgid, int utf8)
                                 domain->orig_tab[nstr - 1].offset)))
         return get_string (domain, nstr - 1, utf8);
 
-        for(;;)
-          {
-            if (idx >= domain->hash_size - incr)
-              idx -= domain->hash_size - incr;
-            else
-              idx += incr;
-
-            nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx]);
-            if (!nstr)
-              /* Hash table entry is empty.  */
-              goto not_found;
-
-            if (SWAPIT (domain->must_swap,
-                        domain->orig_tab[nstr - 1].length) == len
-                && !strcmp (msgid,
-                            domain->data
-                            + SWAPIT (domain->must_swap,
-                                      domain->orig_tab[nstr - 1].offset)))
-              return get_string (domain, nstr-1, utf8);
-          }
+      for(;;)
+        {
+          if (idx >= domain->hash_size - incr)
+            idx -= domain->hash_size - incr;
+          else
+            idx += incr;
+
+          nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx]);
+          if (!nstr)
+            /* Hash table entry is empty.  */
+            goto not_found;
+
+          if (SWAPIT (domain->must_swap,
+                      domain->orig_tab[nstr - 1].length) == len
+              && !strcmp (msgid,
+                          domain->data
+                          + SWAPIT (domain->must_swap,
+                                    domain->orig_tab[nstr - 1].offset)))
+            return get_string (domain, nstr-1, utf8);
+        }
         /* NOTREACHED */
     }
 

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

Summary of changes:
 src/common.c             | 79 +++++++++++++++++++++++++++++++++++++++++++++++-
 src/common.h             |  2 ++
 src/mimedataprovider.cpp |  1 +
 src/olflange.cpp         | 65 +++++++++++++++++++++++++++++++++------
 src/w32-gettext.c        | 40 ++++++++++++------------
 5 files changed, 156 insertions(+), 31 deletions(-)


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




More information about the Gnupg-commits mailing list