libtool-patches
[Top][All Lists]
Advanced

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

[PATCH] [cygwin|mingw] Create UAC manifest files.


From: Charles Wilson
Subject: [PATCH] [cygwin|mingw] Create UAC manifest files.
Date: Tue, 30 Jun 2009 08:05:47 -0400

* libltdl/config/ltmain.m4sh (func_emit_exe_manifest): New function.
(func_mode_link) [cygwin|mingw]: Create manifest files for wrapper
and target exe when target name matches heuristic that triggers
UAC problems for newer win32 OSs.

Signed-off-by: Charles Wilson <address@hidden>
---
The attached patch was submitted on the cygwin list by Yaakov
Selkowitz, and is currently included in the cygwin libtool
distribution.  It has received some objection (notably by Peter
Rosin) over there, but I'll let him speak for himself -- I'm
posting this version explicitly to attract comments so the patch
can be refined.

>From Yaakov's original submission
http://cygwin.com/ml/cygwin/2009-06/msg00620.html
(the rest of the thread is instructive as well):

> Look at func_mode_link (omitting some lines for clarity):
> 
>   *cygwin* | *mingw* )
>     cwrappersource="$output_path/$objdir/lt-$output_name.c"
>     cwrapper="$output_path/$output_name.exe"
>     $RM $cwrappersource $cwrapper
> 
> 
>     func_emit_cwrapperexe_src > $cwrappersource
>     $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
>     $STRIP $cwrapper
> 
> 
> $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
> 
> IOW, the cwrapper source is created and built, then the cwrapper is
> run to create the ltwrapper ($objdir/${output_name}_ltshwrapper).
> But if the target .exe has one of those names that trigger UAC, the
> last step fails and the ltwrapper is empty. So not only can you not
> run the program in-place, but worse, during install, the cwrapper
> is installed instead of the real program, which obviously isn't very
> helpful.
> 
> So yes, in order for libtool to work with UAC, libtool needs to
> generate a .manifest for both the $cwrapper in the $output_path
> (*before* the lt-dump-script call) AND the real program in $objdir,
> so that running in-place works. Whether it's libtool's responsibility
> to *install* the latter is debatable.

Comments?

--
Chuck


 libltdl/config/ltmain.m4sh |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index ebd3909..1e8635e 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -3604,6 +3604,32 @@ EOF
 }
 # end: func_emit_cwrapperexe_src
 
+# func_emit_exe_manifest
+# emit a Win32 UAC manifest for executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_exe_manifest ()
+{
+    cat <<EOF
+<?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="X86"
+     name="$host_os.$PROGRAM.$outputname"
+     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>
+EOF
+}
+
 # func_win32_import_lib_p ARG
 # True if ARG is an import lib, as indicated by $file_magic_cmd
 func_win32_import_lib_p ()
@@ -7434,6 +7460,13 @@ EOF
            $opt_dry_run || {
              # note: this script will not be executed, so do not chmod.
              if test "x$build" = "x$host" ; then
+               # Create the UAC manifests first if necessary
+               case $output_name in
+                 *instal*|*patch*|*setup*|*update*)
+                   func_emit_exe_manifest > $cwrapper.manifest
+                   func_emit_exe_manifest > 
$output_path/$objdir/$output_name.exe.manifest
+                 ;;
+               esac
                $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
              else
                func_emit_wrapper no > $func_ltwrapper_scriptname_result
-- 
1.6.3.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]