[gtk/uac.meson.master] gtk4-update-icon-cache: Avoid UAC on 32-bit Windows




commit 334201f48a2627b1d4d572ddd23332886cd897a4
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Feb 1 15:56:57 2021 +0800

    gtk4-update-icon-cache: Avoid UAC on 32-bit Windows
    
    As the program executable name has 'update' in its filename,
    gtk4-update-icon-cache.exe is considered to be an installer program on 32-bit
    Windows [1], which will cause the program to fail to run unless it is running
    with elevated privileges (i.e. UAC).
    
    Avoid this situation by embedding a manifest file into the final executable
    that tells Windows that this is not a program that requires elevation.
    
    Fixes issue #3632.
    
    [1]: 
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc709628(v=ws.10)?redirectedfrom=MSDN,
         under section "Installer Detection  Technology"

 tools/meson.build                    |  8 +++++++-
 tools/update-icon-cache.exe.manifest | 17 +++++++++++++++++
 tools/update-icon-cache.rc           |  3 +++
 3 files changed, 27 insertions(+), 1 deletion(-)
---
diff --git a/tools/meson.build b/tools/meson.build
index de724e55f4..3d2ea2eb78 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -1,4 +1,10 @@
 # Installed tools
+
+extra_update_icon_cache_objs = []
+if win32_enabled
+  extra_update_icon_cache_objs = import('windows').compile_resources('update-icon-cache.rc')
+endif
+
 gtk_tools = [
   ['gtk4-query-settings', ['gtk-query-settings.c'], [libgtk_dep]],
   ['gtk4-builder-tool', ['gtk-builder-tool.c',
@@ -6,7 +12,7 @@ gtk_tools = [
                          'gtk-builder-tool-validate.c',
                          'gtk-builder-tool-enumerate.c',
                          'gtk-builder-tool-preview.c'], [libgtk_dep] ],
-  ['gtk4-update-icon-cache', ['updateiconcache.c'], [ libgtk_static_dep ] ],
+  ['gtk4-update-icon-cache', ['updateiconcache.c'] + extra_update_icon_cache_objs, [ libgtk_static_dep ] ],
   ['gtk4-encode-symbolic-svg', ['encodesymbolic.c'], [ libgtk_static_dep ] ],
 ]
 
diff --git a/tools/update-icon-cache.exe.manifest b/tools/update-icon-cache.exe.manifest
new file mode 100644
index 0000000000..f215634abc
--- /dev/null
+++ b/tools/update-icon-cache.exe.manifest
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+  <assemblyIdentity version="1.0.0.0"
+     processorArchitecture="*"
+     name="gtk-update-icon-cache.exe"
+     type="win32"/>
+  <!-- Identify the application security requirements. -->
+  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+    <security>
+      <requestedPrivileges>
+        <requestedExecutionLevel
+          level="asInvoker"
+          uiAccess="false"/>
+        </requestedPrivileges>
+       </security>
+  </trustInfo>
+</assembly>
diff --git a/tools/update-icon-cache.rc b/tools/update-icon-cache.rc
new file mode 100644
index 0000000000..86ab7cd6fe
--- /dev/null
+++ b/tools/update-icon-cache.rc
@@ -0,0 +1,3 @@
+#include <winuser.h>
+
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "update-icon-cache.exe.manifest"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]