This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Compiled executables requiring admin rights - different results between MinGW host type


On Mar 11 11:50, Tony Kelman wrote:
> Hi, I'm looking at a very simple 32-line c file, source is available
> here
> https://github.com/JuliaLang/julia/blob/master/contrib/stringpatch.c
> 
> I'm seeing unpredictable results w.r.t. the compiled executable
> requiring admin rights to run, depending which host compiler is
> used.
> 
> Under 32 bit Cygwin:
> gcc -o stringpatch-cyg stringpatch.c   # requires admin rights
> i686-pc-mingw32-gcc -o stringpatch-pc-32 stringpatch.c   # requires
> admin rights
> i686-w64-mingw32-gcc -o stringpatch-w64-32 stringpatch.c   #
> requires admin rights
> x86_64-w64-mingw32-gcc -o stringpatch-w64-64 stringpatch.c   # does
> not require admin rights
> 
> Under 64 bit Cygwin:
> gcc -o stringpatch-cyg stringpatch.c   # does not require admin rights
> i686-pc-mingw32-gcc -o stringpatch-pc-32 stringpatch.c   # requires
> admin rights
> i686-w64-mingw32-gcc -o stringpatch-w64-32 stringpatch.c   #
> requires admin rights
> x86_64-w64-mingw32-gcc -o stringpatch-w64-64 stringpatch.c   # does
> not require admin rights
> 
> What is the explanation for this discrepancy? Is this expected
> behavior?

You won't believe it, but yes!  Welcome to the wonderful world of
UAC installer detection!!!1!11

See http://msdn.microsoft.com/en-us/library/bb530410.aspx
and scroll down to the section called "Installer Detection".

I'll wait while you read...

[..."whistling while you work"...]

Finished?  Fine.  So, the only fault of your application is it's name.
It's called "something-with-patch-in-it".  As everybody knows, an
application which is called "something-with-patch-in-it" is an
installer and needs elevation.  But only if it's a 32 bit application.

> Is there an easy way to prevent any of the compiled
> executables from requiring admin rights?

You have four ways around this:

- Rename your executable so it doesn't have the chutzpah to call itself
  "something-with-patch-in-it" or "something-with-instal-in-it" or
  "something-with-setup-in-it" or "something-with-update-in-it".

- Take one of the manifest files you find in Cygwin's /usr/bin dir,
  and copy it alongside your binary, for instance:

    $ cp /usr/bin/patch.exe.manifest ./stringpatch.exe.manifest

- Wait until the next binutils version is released (should be in the
  next couple of days), and link your executable with the new linker.
  This will give you a default manifest integrated in your executable
  by default, which doesn't only claim compatibility with all existing
  WIndows versions, but also sets the RequestedExecutionLevel to
  "asInvoker", which avoids the elevation for this executable entirely.

- Switch off UAC installer detection on your machine.  You can do this
  in the Local Security Policy MMC Snapin.


HTH,
COrinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgpGgKIbtKQek.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]