From 5bd88333ee233e2770942e9ffe26db0e83789048 Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Sat, 31 May 2008 05:11:07 +0000 Subject: Fix bdist_wininst --user-access-control for win2k --- Lib/distutils/command/wininst-6.0.exe | Bin 61440 -> 61440 bytes Lib/distutils/command/wininst-7.1.exe | Bin 61440 -> 65536 bytes Lib/distutils/command/wininst-9.0-amd64.exe | Bin 77312 -> 77824 bytes Lib/distutils/command/wininst-9.0.exe | Bin 66048 -> 66048 bytes PC/bdist_wininst/install.c | 26 +++++++++++++++++++------- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Lib/distutils/command/wininst-6.0.exe b/Lib/distutils/command/wininst-6.0.exe index 10c9819..f57c855 100644 Binary files a/Lib/distutils/command/wininst-6.0.exe and b/Lib/distutils/command/wininst-6.0.exe differ diff --git a/Lib/distutils/command/wininst-7.1.exe b/Lib/distutils/command/wininst-7.1.exe index 6779aa8..1433bc1 100644 Binary files a/Lib/distutils/command/wininst-7.1.exe and b/Lib/distutils/command/wininst-7.1.exe differ diff --git a/Lib/distutils/command/wininst-9.0-amd64.exe b/Lib/distutils/command/wininst-9.0-amd64.exe index b4cb062..9dedfcd 100644 Binary files a/Lib/distutils/command/wininst-9.0-amd64.exe and b/Lib/distutils/command/wininst-9.0-amd64.exe differ diff --git a/Lib/distutils/command/wininst-9.0.exe b/Lib/distutils/command/wininst-9.0.exe index 0d04a66..9102ecd 100644 Binary files a/Lib/distutils/command/wininst-9.0.exe and b/Lib/distutils/command/wininst-9.0.exe differ diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c index a4f4865..7e69eaa 100644 --- a/PC/bdist_wininst/install.c +++ b/PC/bdist_wininst/install.c @@ -2115,11 +2115,6 @@ BOOL NeedAutoUAC() { 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 @@ BOOL NeedAutoUAC() 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 @@ int DoInstall(void) // 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 @@ int DoInstall(void) } 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; } -- cgit v0.12