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
|
PDWORD WINAPI
|
||||||
GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
|
GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
|
||||||
{
|
{
|
||||||
|
SetLastError(ERROR_SUCCESS);
|
||||||
return RtlSubAuthoritySid(pSid, nSubAuthority);
|
return RtlSubAuthoritySid(pSid, nSubAuthority);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1085,6 +1086,7 @@ GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
|
|||||||
PUCHAR WINAPI
|
PUCHAR WINAPI
|
||||||
GetSidSubAuthorityCount (PSID pSid)
|
GetSidSubAuthorityCount (PSID pSid)
|
||||||
{
|
{
|
||||||
|
SetLastError(ERROR_SUCCESS);
|
||||||
return RtlSubAuthorityCountSid(pSid);
|
return RtlSubAuthorityCountSid(pSid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,9 @@ typedef BOOL (WINAPI *fnSetFileSecurityA)(LPCSTR, SECURITY_INFORMATION,
|
|||||||
static DWORD (WINAPI *pGetNamedSecurityInfoA)(LPSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
static DWORD (WINAPI *pGetNamedSecurityInfoA)(LPSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
||||||
PSID*, PSID*, PACL*, PACL*,
|
PSID*, PSID*, PACL*, PACL*,
|
||||||
PSECURITY_DESCRIPTOR*);
|
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 DWORD (WINAPI *fnRtlAdjustPrivilege)(ULONG,BOOLEAN,BOOLEAN,PBOOLEAN);
|
||||||
typedef BOOL (WINAPI *fnCreateWellKnownSid)(WELL_KNOWN_SID_TYPE,PSID,PSID,DWORD*);
|
typedef BOOL (WINAPI *fnCreateWellKnownSid)(WELL_KNOWN_SID_TYPE,PSID,PSID,DWORD*);
|
||||||
typedef BOOL (WINAPI *fnDuplicateTokenEx)(HANDLE,DWORD,LPSECURITY_ATTRIBUTES,
|
typedef BOOL (WINAPI *fnDuplicateTokenEx)(HANDLE,DWORD,LPSECURITY_ATTRIBUTES,
|
||||||
@ -160,6 +163,9 @@ static void init(void)
|
|||||||
pSetFileSecurityA = (fnSetFileSecurityA)GetProcAddress(hmod, "SetFileSecurityA" );
|
pSetFileSecurityA = (fnSetFileSecurityA)GetProcAddress(hmod, "SetFileSecurityA" );
|
||||||
pCreateWellKnownSid = (fnCreateWellKnownSid)GetProcAddress( hmod, "CreateWellKnownSid" );
|
pCreateWellKnownSid = (fnCreateWellKnownSid)GetProcAddress( hmod, "CreateWellKnownSid" );
|
||||||
pGetNamedSecurityInfoA = (void *)GetProcAddress(hmod, "GetNamedSecurityInfoA");
|
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");
|
pMakeSelfRelativeSD = (void *)GetProcAddress(hmod, "MakeSelfRelativeSD");
|
||||||
pSetEntriesInAclW = (void *)GetProcAddress(hmod, "SetEntriesInAclW");
|
pSetEntriesInAclW = (void *)GetProcAddress(hmod, "SetEntriesInAclW");
|
||||||
pSetSecurityDescriptorControl = (void *)GetProcAddress(hmod, "SetSecurityDescriptorControl");
|
pSetSecurityDescriptorControl = (void *)GetProcAddress(hmod, "SetSecurityDescriptorControl");
|
||||||
@ -3176,6 +3182,34 @@ static void test_GetSecurityInfo(void)
|
|||||||
CloseHandle(obj);
|
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)
|
START_TEST(security)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
@ -3205,4 +3239,5 @@ START_TEST(security)
|
|||||||
test_PrivateObjectSecurity();
|
test_PrivateObjectSecurity();
|
||||||
test_acls();
|
test_acls();
|
||||||
test_GetSecurityInfo();
|
test_GetSecurityInfo();
|
||||||
|
test_GetSidSubAuthority();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user