mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 11:32:48 -05:00
Windows Pageant: turn 'has_security' into a global function.
Now it can be called from places other than Pageant's WinMain(). In particular, the attempt to make a security descriptor in lock_interprocess_mutex() is gated on it. In return, however, I've tightened up the semantics. In normal PuTTY builds that aren't trying to support pre-NT systems, the function *unconditionally* returns true, on the grounds that we don't expect to target any system that doesn't support the security APIs, and if someone manages to contrive one anyway - or, more likely, if we some day introduce a bug in our loading of the security API functions - then this safety catch should make Pageant less likely to accidentally fall back to 'never mind, just run in insecure mode'.
This commit is contained in:
@ -13,8 +13,8 @@ HANDLE lock_interprocess_mutex(const char *mutexname, char **error)
|
||||
PACL acl = NULL;
|
||||
HANDLE mutex = NULL;
|
||||
|
||||
if (!make_private_security_descriptor(MUTEX_ALL_ACCESS,
|
||||
&psd, &acl, error))
|
||||
if (should_have_security() && !make_private_security_descriptor(
|
||||
MUTEX_ALL_ACCESS, &psd, &acl, error))
|
||||
goto out;
|
||||
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
|
@ -20,6 +20,20 @@ DEF_WINDOWS_FUNCTION(GetSecurityInfo);
|
||||
DEF_WINDOWS_FUNCTION(SetSecurityInfo);
|
||||
DEF_WINDOWS_FUNCTION(SetEntriesInAclA);
|
||||
|
||||
bool should_have_security(void)
|
||||
{
|
||||
#ifdef LEGACY_WINDOWS
|
||||
/* Legacy pre-NT platforms are not expected to have any of these APIs */
|
||||
init_winver();
|
||||
return (osPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
#else
|
||||
/* In the up-to-date PuTTY builds which do not support those
|
||||
* platforms, unconditionally return true, to minimise the risk of
|
||||
* compiling out security checks. */
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool got_advapi(void)
|
||||
{
|
||||
static bool attempted = false;
|
||||
|
Reference in New Issue
Block a user