Commit 5bd88333 authored by Mark Hammond's avatar Mark Hammond

Fix bdist_wininst --user-access-control for win2k

parent 6d7702ec
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
...@@ -2115,11 +2115,6 @@ BOOL NeedAutoUAC() ...@@ -2115,11 +2115,6 @@ BOOL NeedAutoUAC()
{ {
HKEY hk; HKEY hk;
char key_name[80]; 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. // no Python version info == we can't know yet.
if (target_version[0] == '\0') if (target_version[0] == '\0')
return FALSE; return FALSE;
...@@ -2135,6 +2130,23 @@ BOOL NeedAutoUAC() ...@@ -2135,6 +2130,23 @@ BOOL NeedAutoUAC()
return TRUE; 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 // Spawn ourself as an elevated application. On failure, a message is
// displayed to the user - but this app will always terminate, even // displayed to the user - but this app will always terminate, even
// on error. // on error.
...@@ -2190,7 +2202,7 @@ int DoInstall(void) ...@@ -2190,7 +2202,7 @@ int DoInstall(void)
// See if we need to do the Vista UAC magic. // See if we need to do the Vista UAC magic.
if (strcmp(user_access_control, "force")==0) { if (strcmp(user_access_control, "force")==0) {
if (!MyIsUserAnAdmin()) { if (PlatformSupportsUAC() && !MyIsUserAnAdmin()) {
SpawnUAC(); SpawnUAC();
return 0; return 0;
} }
...@@ -2198,7 +2210,7 @@ int DoInstall(void) ...@@ -2198,7 +2210,7 @@ int DoInstall(void)
} else if (strcmp(user_access_control, "auto")==0) { } else if (strcmp(user_access_control, "auto")==0) {
// Check if it looks like we need UAC control, based // Check if it looks like we need UAC control, based
// on how Python itself was installed. // on how Python itself was installed.
if (!MyIsUserAnAdmin() && NeedAutoUAC()) { if (PlatformSupportsUAC() && !MyIsUserAnAdmin() && NeedAutoUAC()) {
SpawnUAC(); SpawnUAC();
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment