[gtk+/gtk-2-16] Workaround for UAC on Windows



commit 1eaa240691dddbe7cd5d207c8a43ba6c018342b4
Author: Tor Lillqvist <tml iki fi>
Date:   Thu Sep 2 13:03:28 2010 +0300

    Workaround for UAC on Windows
    
    Create a gtk-update-icon-cache.exe.manifest file to avod UAC. Windows
    thinks that any program with "update" in its name is some kind of
    installer that needs administrative privileges to do its job.

 configure.in    |    3 +++
 gtk/Makefile.am |   35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/configure.in b/configure.in
index 57ac9c9..1e68817 100644
--- a/configure.in
+++ b/configure.in
@@ -124,6 +124,7 @@ AC_CANONICAL_HOST
 MATH_LIB=-lm
 AC_MSG_CHECKING([for native Win32])
 LIB_EXE_MACHINE_FLAG=X86
+EXE_MANIFEST_ARCHITECTURE=X86
 case "$host" in
   *-*-mingw*)
     os_win32=yes
@@ -132,6 +133,7 @@ case "$host" in
     case "$host" in
     x86_64-*-*)
       LIB_EXE_MACHINE_FLAG=X64
+      EXE_MANIFEST_ARCHITECTURE=AMD64
       ;;
     esac
     ;;
@@ -142,6 +144,7 @@ esac
 AC_MSG_RESULT([$os_win32])
 
 AC_SUBST(LIB_EXE_MACHINE_FLAG)
+AC_SUBST(EXE_MANIFEST_ARCHITECTURE)
 
 case $host in
   *-*-linux*)
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 6cc088a..f59454a 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -938,6 +938,39 @@ bin_PROGRAMS = \
 	gtk-update-icon-cache
 bin_SCRIPTS = gtk-builder-convert
 
+if OS_WIN32
+
+# Workaround for UAC silliness: programs with "update" in their name
+# are believed to be installers and require elevated privileges to be
+# used... Use a manifest file to tell Windows that
+# gtk-update-icon-cache.exe doesn't require any special privileges.
+
+GTK_UPDATE_ICON_CACHE_MANIFEST = gtk-update-icon-cache.exe.manifest
+
+bin_SCRIPTS += \
+	$(GTK_UPDATE_ICON_CACHE_MANIFEST)
+
+gtk-update-icon-cache.exe.manifest:
+	(echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' ; \
+	 echo '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">' ; \
+	 echo '  <assemblyIdentity version="1.0.0.0"' ; \
+	 echo '     processorArchitecture="'$(EXE_MANIFEST_ARCHITECTURE)'"' ; \
+	 echo '     name="gtk-update-icon-cache.exe"' ; \
+	 echo '     type="win32"/>' ; \
+	 echo '  <!-- Identify the application security requirements. -->' ; \
+	 echo '  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">' ; \
+	 echo '    <security>' ; \
+	 echo '      <requestedPrivileges>' ; \
+	 echo '        <requestedExecutionLevel' ; \
+	 echo '          level="asInvoker"' ; \
+	 echo '          uiAccess="false"/>' ; \
+	 echo '        </requestedPrivileges>' ; \
+	 echo '       </security>' ; \
+	 echo '  </trustInfo>' ; \
+	 echo '</assembly>' ) >$@
+
+endif
+
 gtk_query_immodules_2_0_DEPENDENCIES = $(DEPS)
 gtk_query_immodules_2_0_LDADD = $(LDADDS)
 
@@ -1256,7 +1289,7 @@ gtk_update_icon_cache_program =							\
 endif
 
 gtkbuiltincache.h: @REBUILD@ stamp-icons
-	$(MAKE) $(AM_MAKEFLAGS) gtk-update-icon-cache$(EXEEXT)
+	$(MAKE) $(AM_MAKEFLAGS) gtk-update-icon-cache$(EXEEXT) $(GTK_UPDATE_ICON_CACHE_MANIFEST)
 	$(gtk_update_icon_cache_program) --force --ignore-theme-index		\
 	   --source builtin_icons stock-icons > gtkbuiltincache.h.tmp &&        \
 	mv gtkbuiltincache.h.tmp gtkbuiltincache.h



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