[Python-3000-checkins] r64989 - in python/branches/py3k: Lib/distutils/command/wininst-6.0.exe Lib/distutils/command/wininst-7.1.exe Lib/distutils/command/wininst-9.0-amd64.exe Lib/distutils/command/wininst-9.0.exe PC/bdist_wininst/install.c

georg.brandl python-3000-checkins at python.org
Wed Jul 16 04:02:25 CEST 2008


Author: georg.brandl
Date: Wed Jul 16 04:02:25 2008
New Revision: 64989

Log:
Merged revisions 63828 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r63828 | mark.hammond | 2008-05-31 07:11:07 +0200 (Sat, 31 May 2008) | 2 lines
  
  Fix bdist_wininst --user-access-control for win2k
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/distutils/command/wininst-6.0.exe
   python/branches/py3k/Lib/distutils/command/wininst-7.1.exe
   python/branches/py3k/Lib/distutils/command/wininst-9.0-amd64.exe
   python/branches/py3k/Lib/distutils/command/wininst-9.0.exe
   python/branches/py3k/PC/bdist_wininst/install.c

Modified: python/branches/py3k/Lib/distutils/command/wininst-6.0.exe
==============================================================================
Binary files. No diff available.

Modified: python/branches/py3k/Lib/distutils/command/wininst-7.1.exe
==============================================================================
Binary files. No diff available.

Modified: python/branches/py3k/Lib/distutils/command/wininst-9.0-amd64.exe
==============================================================================
Binary files. No diff available.

Modified: python/branches/py3k/Lib/distutils/command/wininst-9.0.exe
==============================================================================
Binary files. No diff available.

Modified: python/branches/py3k/PC/bdist_wininst/install.c
==============================================================================
--- python/branches/py3k/PC/bdist_wininst/install.c	(original)
+++ python/branches/py3k/PC/bdist_wininst/install.c	Wed Jul 16 04:02:25 2008
@@ -2115,11 +2115,6 @@
 {
 	HKEY hk;
 	char key_name[80];
-	OSVERSIONINFO winverinfo;
-	winverinfo.dwOSVersionInfoSize = sizeof(winverinfo);
-	// If less than XP, then we can't do it (and its not necessary).
-	if (!GetVersionEx(&winverinfo) || winverinfo.dwMajorVersion < 5)
-		return FALSE;
 	// no Python version info == we can't know yet.
 	if (target_version[0] == '\0')
 		return FALSE;
@@ -2135,6 +2130,23 @@
 	return TRUE;
 }
 
+// Returns TRUE if the platform supports UAC.
+BOOL PlatformSupportsUAC()
+{
+	// Note that win2k does seem to support ShellExecute with 'runas',
+	// but does *not* support IsUserAnAdmin - so we just pretend things
+	// only work on XP and later.
+	BOOL bIsWindowsXPorLater;
+	OSVERSIONINFO winverinfo;
+	winverinfo.dwOSVersionInfoSize = sizeof(winverinfo);
+	if (!GetVersionEx(&winverinfo))
+		return FALSE; // something bad has gone wrong
+	bIsWindowsXPorLater = 
+       ( (winverinfo.dwMajorVersion > 5) ||
+       ( (winverinfo.dwMajorVersion == 5) && (winverinfo.dwMinorVersion >= 1) ));
+	return bIsWindowsXPorLater;
+}
+
 // Spawn ourself as an elevated application.  On failure, a message is
 // displayed to the user - but this app will always terminate, even
 // on error.
@@ -2190,7 +2202,7 @@
 
 	// See if we need to do the Vista UAC magic.
 	if (strcmp(user_access_control, "force")==0) {
-		if (!MyIsUserAnAdmin()) {
+		if (PlatformSupportsUAC() && !MyIsUserAnAdmin()) {
 			SpawnUAC();
 			return 0;
 		}
@@ -2198,7 +2210,7 @@
 	} else if (strcmp(user_access_control, "auto")==0) {
 		// Check if it looks like we need UAC control, based
 		// on how Python itself was installed.
-		if (!MyIsUserAnAdmin() && NeedAutoUAC()) {
+		if (PlatformSupportsUAC() && !MyIsUserAnAdmin() && NeedAutoUAC()) {
 			SpawnUAC();
 			return 0;
 		}


More information about the Python-3000-checkins mailing list