[Haskell-cafe] Cabal install on Windows 7

Regis Saint-Paul regis.saint-paul at create-net.org
Thu Sep 10 09:18:19 EDT 2009


One way in which cabal can be made UAC aware (and therefore request for
elevation privileges instead of just failing) would be to embed a manifest
in the cabal.exe. This can be done by changing the default manifest (an XML
file) that is embedded at link time by GHC. This is supported by GHC through
compilation options. It could be used when building cabal for windows. The
manifest itself is simple, it just needs one additional line to say it
requires admin privileges.  

All details are here: 
http://msdn.microsoft.com/en-us/library/bb756929.aspx

However, a problem with this approach is that cabal.exe as a whole would be
seen as needing administrator privilege, regardless of whether the setting
is global or user. If we want to request admin privileges only when actually
needed (i.e., when writing in a protected folder). To address this, there
are several options:
- have two distinct executables for cabal, cabal-global and cabal-user with
different manifest
- use windows API for requesting elevation during the process (ugly)
- use shellexecute command for running a process performing just the task
that needs elevated privileges. 

Someone mentioned the "runas" command. But unlike su on linux, runas only
changes the user, not the privileges attached to it. That is, on VISTA and
7, even admin users are seen as "standard user" unless they explicitly
acknowledge they want to elevate a process with admin rights. So if you need
admin rights while running as admin, you are only prompted for yes or no,
while if you need admin rights as a non-admin user, you are also prompted
for admin pass. This was done do address the legacy problem that everyone
was using windows as admin in the first place.  

Also, the AppData folder is for application data, not for the application
itself. I'm not sure how far one needs to go in terms of well-behaving for
windows when it comes to multi-platform applications. I'd like to point out
the "Application Compatibility Toolkit" which allows testing if an
application is well behaved for vista and 7 and provides guidelines for that
(it's a free download): 

http://www.microsoft.com/downloads/details.aspx?FamilyID=24da89e9-b581-47b0-
b45e-492dd6da2971&DisplayLang=en

you may also need to download the application verifier here: 

http://www.microsoft.com/downloads/details.aspx?FamilyID=c4a25ab9-649d-4a1b-
b4a7-c9d8b095df18&DisplayLang=en

You can use also on XP to test for vista and 7. I tried running it with
cabal install somepackage and it points out a number of privilege errors. 

Note that if cabal was writing packages in AppData instead of "program
files", then the problem would only surface when cabal install moves
executable in the bin directory.  

It seems to me that the cygwin/mingw and, more generally, the GNU way of
dealing with windows is to mainly ignore the directory structure of windows
and install things in a separate directory chosen by the user (possibly in
program files or elsewhere), requesting the user to manually change the path
accordingly. That could be a solution to consider too. 

Hope this helps a bit, 

Regis 



More information about the Haskell-Cafe mailing list