advapi32: Add a few tests for GetSidSubAuthority and SetLastError correctly.
This commit is contained in:
parent
0ca3b3b423
commit
011c5b8fae
|
@ -1073,6 +1073,7 @@ GetSidIdentifierAuthority( PSID pSid )
|
|||
PDWORD WINAPI
|
||||
GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
|
||||
{
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
return RtlSubAuthoritySid(pSid, nSubAuthority);
|
||||
}
|
||||
|
||||
|
@ -1085,6 +1086,7 @@ GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
|
|||
PUCHAR WINAPI
|
||||
GetSidSubAuthorityCount (PSID pSid)
|
||||
{
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
return RtlSubAuthorityCountSid(pSid);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ typedef BOOL (WINAPI *fnSetFileSecurityA)(LPCSTR, SECURITY_INFORMATION,
|
|||
static DWORD (WINAPI *pGetNamedSecurityInfoA)(LPSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
||||
PSID*, PSID*, PACL*, PACL*,
|
||||
PSECURITY_DESCRIPTOR*);
|
||||
static PDWORD (WINAPI *pGetSidSubAuthority)(PSID, DWORD);
|
||||
static PUCHAR (WINAPI *pGetSidSubAuthorityCount)(PSID);
|
||||
static BOOL (WINAPI *pIsValidSid)(PSID);
|
||||
typedef DWORD (WINAPI *fnRtlAdjustPrivilege)(ULONG,BOOLEAN,BOOLEAN,PBOOLEAN);
|
||||
typedef BOOL (WINAPI *fnCreateWellKnownSid)(WELL_KNOWN_SID_TYPE,PSID,PSID,DWORD*);
|
||||
typedef BOOL (WINAPI *fnDuplicateTokenEx)(HANDLE,DWORD,LPSECURITY_ATTRIBUTES,
|
||||
|
@ -160,6 +163,9 @@ static void init(void)
|
|||
pSetFileSecurityA = (fnSetFileSecurityA)GetProcAddress(hmod, "SetFileSecurityA" );
|
||||
pCreateWellKnownSid = (fnCreateWellKnownSid)GetProcAddress( hmod, "CreateWellKnownSid" );
|
||||
pGetNamedSecurityInfoA = (void *)GetProcAddress(hmod, "GetNamedSecurityInfoA");
|
||||
pGetSidSubAuthority = (void *)GetProcAddress(hmod, "GetSidSubAuthority");
|
||||
pGetSidSubAuthorityCount = (void *)GetProcAddress(hmod, "GetSidSubAuthorityCount");
|
||||
pIsValidSid = (void *)GetProcAddress(hmod, "IsValidSid");
|
||||
pMakeSelfRelativeSD = (void *)GetProcAddress(hmod, "MakeSelfRelativeSD");
|
||||
pSetEntriesInAclW = (void *)GetProcAddress(hmod, "SetEntriesInAclW");
|
||||
pSetSecurityDescriptorControl = (void *)GetProcAddress(hmod, "SetSecurityDescriptorControl");
|
||||
|
@ -3176,6 +3182,34 @@ static void test_GetSecurityInfo(void)
|
|||
CloseHandle(obj);
|
||||
}
|
||||
|
||||
static void test_GetSidSubAuthority(void)
|
||||
{
|
||||
PSID psid = NULL;
|
||||
|
||||
if (!pGetSidSubAuthority || !pConvertStringSidToSidA || !pIsValidSid || !pGetSidSubAuthorityCount)
|
||||
{
|
||||
win_skip("Some functions not available\n");
|
||||
return;
|
||||
}
|
||||
/* Note: on windows passing in an invalid index like -1, lets GetSidSubAuthority return 0x05000000 but
|
||||
still GetLastError returns ERROR_SUCCESS then. We don't test these unlikely cornercases here for now */
|
||||
ok(pConvertStringSidToSidA("S-1-5-21-93476-23408-4576",&psid),"ConvertStringSidToSidA failed\n");
|
||||
ok(pIsValidSid(psid),"Sid is not valid\n");
|
||||
SetLastError(0xbebecaca);
|
||||
ok(*pGetSidSubAuthorityCount(psid) == 4,"GetSidSubAuthorityCount gave %d expected 4\n",*pGetSidSubAuthorityCount(psid));
|
||||
ok(GetLastError() == 0,"GetLastError returned %d instead of 0\n",GetLastError());
|
||||
SetLastError(0xbebecaca);
|
||||
ok(*pGetSidSubAuthority(psid,0) == 21,"GetSidSubAuthority gave %d expected 21",*pGetSidSubAuthority(psid,0));
|
||||
ok(GetLastError() == 0,"GetLastError returned %d instead of 0\n",GetLastError());
|
||||
SetLastError(0xbebecaca);
|
||||
ok(*pGetSidSubAuthority(psid,1) == 93476,"GetSidSubAuthority gave %d expected 93476",*pGetSidSubAuthority(psid,1));
|
||||
ok(GetLastError() == 0,"GetLastError returned %d instead of 0\n",GetLastError());
|
||||
SetLastError(0xbebecaca);
|
||||
todo_wine ok(*pGetSidSubAuthority(psid,4) == 0,"GetSidSubAuthority gave %d,expected 0\n",*pGetSidSubAuthority(psid,4));
|
||||
ok(GetLastError() == 0,"GetLastError returned %d instead of 0\n",GetLastError());
|
||||
LocalFree(psid);
|
||||
}
|
||||
|
||||
START_TEST(security)
|
||||
{
|
||||
init();
|
||||
|
@ -3205,4 +3239,5 @@ START_TEST(security)
|
|||
test_PrivateObjectSecurity();
|
||||
test_acls();
|
||||
test_GetSecurityInfo();
|
||||
test_GetSidSubAuthority();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue