From 26a776e9f8037e2a9d61a0f51ab18b5319432cb5 Mon Sep 17 00:00:00 2001 From: Andriy Palamarchuk Date: Tue, 17 Sep 2002 18:31:06 +0000 Subject: [PATCH] Make LsaOpenPolicy return success. --- dlls/advapi32/security.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c index 1c515f0026..8fedf7e386 100644 --- a/dlls/advapi32/security.c +++ b/dlls/advapi32/security.c @@ -49,6 +49,42 @@ static void dumpLsaAttributes( PLSA_OBJECT_ATTRIBUTES oa ) } } +/************************************************************ + * ADVAPI_IsLocalComputer + * + * Checks whether the server name indicates local machine. + */ +BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName) +{ + if (!ServerName) + { + return TRUE; + } + else + { + DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1; + BOOL Result; + LPWSTR buf; + + buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR)); + Result = GetComputerNameW(buf, &dwSize); + if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\')) + ServerName += 2; + Result = Result && !lstrcmpW(ServerName, buf); + HeapFree(GetProcessHeap(), 0, buf); + + return Result; + } +} + +#define ADVAPI_ForceLocalComputer(ServerName, FailureCode) \ + if (!ADVAPI_IsLocalComputer(ServerName)) \ + { \ + FIXME("Action Implemented for local computer only. " \ + "Requested for server %s\n", debugstr_w(ServerName)); \ + return FailureCode; \ + } + /* ############################## ###### TOKEN FUNCTIONS ###### ############################## @@ -802,9 +838,11 @@ LsaOpenPolicy( FIXME("(%s,%p,0x%08lx,%p):stub\n", SystemName?debugstr_w(SystemName->Buffer):"null", ObjectAttributes, DesiredAccess, PolicyHandle); + ADVAPI_ForceLocalComputer(SystemName ? SystemName->Buffer : NULL, + STATUS_ACCESS_VIOLATION); dumpLsaAttributes(ObjectAttributes); if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe; - return TRUE; + return STATUS_SUCCESS; } /******************************************************************************