Title: bdist_wininst installers don't use UAC, then crash
Type: crash Stage: resolved
Components: Distutils Versions: Python 3.4, Python 3.5, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, Redoute, benjamin.peterson, cboos, eric.araujo, loewis, python-dev, steve.dower, tarek
Priority: normal Keywords: patch

Created on 2012-11-26 20:02 by Redoute, last changed 2014-11-28 02:41 by python-dev. This issue is now closed.

File name Uploaded Description Edit
python-issue-16561.diff cboos, 2014-10-26 16:33 patch against 2.7.3 - seems it will also apply to more recent versions
Messages (9)
msg176449 - (view) Author: Redoute (Redoute) Date: 2012-11-26 20:02
Windows installers crash without useful explanation, when Python is located in /Program Files/Python27 and the installer is started without admin rights/UAC. I experienced this with Windows 8 and installers for packages pandas and rtree.

a) show error message instead of crash

As I don't use distutils for packaging, I am just guessing it would make sense to:

b) let bdist_wininst --user-access-control default to 'auto'
msg222955 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-13 16:48
I'm assuming that this is still an issue.  I've not tested it myself as I've never understood why python gets put in "Program Files" so I don't have such a setup and won't be creating one.
msg223032 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2014-07-14 15:14
I just noticed that I misread the original issue: it's not about the Python Windows installer, but about bdist_wininst packages.
msg230027 - (view) Author: Christian Boos (cboos) * Date: 2014-10-26 13:13
`--user-access-control auto` doesn't work for me...

With Python 2.7.8 installed ''for all'' in "C:/Program Files (x86)/Python27", an installer built with `bdist_wininst --user-access-control auto` will *not* ask for permission elevation and will crash as described above. If I build the installer with `bdist_wininst --user-access-control force` it will ask for permission elevation and the install will proceed normally. 

Same behavior for the amd64 version of 2.7.8 installed in "C:/Program Files/Python27".

However, one way or the other I think it would be annoying to ask for permission elevation when it's not actually needed, like when python is installed in the default "C:/Python27" location for example. 

So I think a better fix would be to simply *not crash* and fail saying elevated permissions are required. The user can then simply do a "Run as administrator" on the installer from the Windows explorer and things work as expected.
msg230030 - (view) Author: Christian Boos (cboos) * Date: 2014-10-26 16:33
The reason of the crash is pretty trivial, there's no check for success of the creation of the installation logfile. Trapping this and aborting (with a hint to use "Run as administrator") would be enough to fix the issue, I think.
msg231783 - (view) Author: Christian Boos (cboos) * Date: 2014-11-27 21:57
Ping. Probably too late for 2.7.9, but the patch is about adding a check a null pointer dereference and the follow-up crash, so someone might be interested to commit it, or a similar fix.
msg231793 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2014-11-28 01:54
The patch looks safe enough to me, if Benjamin is willing to consider it for 2.7.9?

Seems fine for 3.4 and 3.5 too, if nobody is opposed (or wants to argue over the wording of the message).
msg231794 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-11-28 02:41
I'm okay with it if Steve is.
msg231795 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-11-28 02:41
New changeset 1ac5aec658f6 by Benjamin Peterson in branch '2.7':
give a nice message when installer is launched w/o admin rights (closes #16561)

New changeset caee1eabba1e by Benjamin Peterson in branch '3.4':
give a nice message when installer is launched w/o admin rights (closes #16561)

New changeset ef5bbdc81796 by Benjamin Peterson in branch 'default':
merge 3.4 (#16561)
Date User Action Args
2014-11-28 02:41:57python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg231795

resolution: fixed
stage: resolved
2014-11-28 02:41:23benjamin.petersonsetmessages: + msg231794
2014-11-28 01:54:24steve.dowersetnosy: + benjamin.peterson
messages: + msg231793
2014-11-27 21:57:27cboossetmessages: + msg231783
2014-10-30 20:07:58pitrousetassignee: eric.araujo ->
2014-10-26 16:33:52cboossetfiles: + python-issue-16561.diff
keywords: + patch
messages: + msg230030
2014-10-26 13:13:12cboossetnosy: + cboos
messages: + msg230027
2014-07-14 15:21:24steve.dowersetnosy: + steve.dower
2014-07-14 15:14:24loewissetmessages: + msg223032
title: Windows installer doesn't use UAC, then crashes -> bdist_wininst installers don't use UAC, then crash
2014-07-13 16:48:22BreamoreBoysetnosy: + BreamoreBoy

messages: + msg222955
versions: + Python 3.4, Python 3.5
2012-11-26 20:23:46pitrousetnosy: + loewis
2012-11-26 20:02:33Redoutecreate