Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
cf680ed0
Commit
cf680ed0
authored
Nov 08, 2009
by
Rob Shearman
Committed by
Alexandre Julliard
Nov 09, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Implement CheckTokenMembership.
parent
dd4804c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
5 deletions
+91
-5
security.c
dlls/advapi32/security.c
+47
-5
security.c
dlls/advapi32/tests/security.c
+44
-0
No files found.
dlls/advapi32/security.c
View file @
cf680ed0
...
@@ -622,13 +622,55 @@ AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
...
@@ -622,13 +622,55 @@ AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
* Failure: FALSE.
* Failure: FALSE.
*/
*/
BOOL
WINAPI
BOOL
WINAPI
CheckTokenMembership
(
HANDLE
TokenHandle
,
PSID
SidToC
heck
,
CheckTokenMembership
(
HANDLE
token
,
PSID
sid_to_c
heck
,
PBOOL
IsM
ember
)
PBOOL
is_m
ember
)
{
{
FIXME
(
"(%p %p %p) stub!
\n
"
,
TokenHandle
,
SidToCheck
,
IsMember
);
PTOKEN_GROUPS
token_groups
;
DWORD
size
,
i
;
*
IsMember
=
TRUE
;
TRACE
(
"(%p %s %p)
\n
"
,
token
,
debugstr_sid
(
sid_to_check
),
is_member
);
return
(
TRUE
);
*
is_member
=
FALSE
;
if
(
!
token
)
{
if
(
!
OpenThreadToken
(
GetCurrentThread
(),
TOKEN_QUERY
,
TRUE
,
&
token
))
return
FALSE
;
}
if
(
!
GetTokenInformation
(
token
,
TokenGroups
,
NULL
,
0
,
&
size
))
{
if
(
GetLastError
()
!=
ERROR_INSUFFICIENT_BUFFER
)
return
FALSE
;
}
token_groups
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
!
token_groups
)
return
FALSE
;
if
(
!
GetTokenInformation
(
token
,
TokenGroups
,
token_groups
,
size
,
&
size
))
{
HeapFree
(
GetProcessHeap
(),
0
,
token_groups
);
return
FALSE
;
}
for
(
i
=
0
;
i
<
token_groups
->
GroupCount
;
i
++
)
{
TRACE
(
"Groups[%d]: {0x%x, %s}
\n
"
,
i
,
token_groups
->
Groups
[
i
].
Attributes
,
debugstr_sid
(
token_groups
->
Groups
[
i
].
Sid
));
if
((
token_groups
->
Groups
[
i
].
Attributes
&
SE_GROUP_ENABLED
)
&&
EqualSid
(
sid_to_check
,
token_groups
->
Groups
[
i
].
Sid
))
{
*
is_member
=
TRUE
;
TRACE
(
"sid enabled and found in token
\n
"
);
break
;
}
}
HeapFree
(
GetProcessHeap
(),
0
,
token_groups
);
return
TRUE
;
}
}
/******************************************************************************
/******************************************************************************
...
...
dlls/advapi32/tests/security.c
View file @
cf680ed0
...
@@ -3200,6 +3200,49 @@ static void test_GetSidSubAuthority(void)
...
@@ -3200,6 +3200,49 @@ static void test_GetSidSubAuthority(void)
LocalFree
(
psid
);
LocalFree
(
psid
);
}
}
static
void
test_CheckTokenMembership
(
void
)
{
PTOKEN_GROUPS
token_groups
;
DWORD
size
;
HANDLE
token
;
BOOL
is_member
;
BOOL
ret
;
DWORD
i
;
ret
=
OpenProcessToken
(
GetCurrentProcess
(),
TOKEN_QUERY
,
&
token
);
ok
(
ret
,
"OpenProcessToken failed with error %d
\n
"
,
GetLastError
());
/* groups */
ret
=
GetTokenInformation
(
token
,
TokenGroups
,
NULL
,
0
,
&
size
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"GetTokenInformation(TokenGroups) %s with error %d
\n
"
,
ret
?
"succeeded"
:
"failed"
,
GetLastError
());
token_groups
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
ret
=
GetTokenInformation
(
token
,
TokenGroups
,
token_groups
,
size
,
&
size
);
ok
(
ret
,
"GetTokenInformation(TokenGroups) failed with error %d
\n
"
,
GetLastError
());
for
(
i
=
0
;
i
<
token_groups
->
GroupCount
;
i
++
)
{
if
(
token_groups
->
Groups
[
i
].
Attributes
&
SE_GROUP_ENABLED
)
break
;
}
if
(
i
==
token_groups
->
GroupCount
)
{
HeapFree
(
GetProcessHeap
(),
0
,
token_groups
);
CloseHandle
(
token
);
skip
(
"user not a member of any group
\n
"
);
return
;
}
ret
=
CheckTokenMembership
(
token
,
token_groups
->
Groups
[
i
].
Sid
,
&
is_member
);
ok
(
ret
,
"CheckTokenMembership failed with error %d
\n
"
,
GetLastError
());
ok
(
is_member
,
"CheckTokenMembership should have detected sid as member"
);
HeapFree
(
GetProcessHeap
(),
0
,
token_groups
);
CloseHandle
(
token
);
}
START_TEST
(
security
)
START_TEST
(
security
)
{
{
init
();
init
();
...
@@ -3230,4 +3273,5 @@ START_TEST(security)
...
@@ -3230,4 +3273,5 @@ START_TEST(security)
test_acls
();
test_acls
();
test_GetSecurityInfo
();
test_GetSecurityInfo
();
test_GetSidSubAuthority
();
test_GetSidSubAuthority
();
test_CheckTokenMembership
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment