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
a33a6371
Commit
a33a6371
authored
May 13, 2006
by
Robert Shearman
Committed by
Alexandre Julliard
May 15, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Add tests for getting the groups, user and privileges of a token.
parent
dcfb0f44
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
security.c
dlls/advapi32/tests/security.c
+70
-0
No files found.
dlls/advapi32/tests/security.c
View file @
a33a6371
...
...
@@ -26,6 +26,7 @@
#include "winerror.h"
#include "aclapi.h"
#include "winnt.h"
#include "sddl.h"
typedef
VOID
(
WINAPI
*
fnBuildTrusteeWithSidA
)(
PTRUSTEEA
pTrustee
,
PSID
pSid
);
typedef
VOID
(
WINAPI
*
fnBuildTrusteeWithNameA
)(
PTRUSTEEA
pTrustee
,
LPSTR
pName
);
...
...
@@ -693,6 +694,74 @@ static void test_AccessCheck(void)
HeapFree
(
GetProcessHeap
(),
0
,
PrivSet
);
}
/* test GetTokenInformation for the various attributes */
static
void
test_token_attr
(
void
)
{
HANDLE
Token
;
DWORD
Size
;
TOKEN_PRIVILEGES
*
Privileges
;
TOKEN_GROUPS
*
Groups
;
TOKEN_USER
*
User
;
BOOL
ret
;
DWORD
i
;
LPTSTR
SidString
;
ret
=
OpenProcessToken
(
GetCurrentProcess
(),
TOKEN_QUERY
,
&
Token
);
ok
(
ret
,
"OpenProcessToken failed with error %ld
\n
"
,
GetLastError
());
/* groups */
ret
=
GetTokenInformation
(
Token
,
TokenGroups
,
NULL
,
0
,
&
Size
);
Groups
=
HeapAlloc
(
GetProcessHeap
(),
0
,
Size
);
ret
=
GetTokenInformation
(
Token
,
TokenGroups
,
Groups
,
Size
,
&
Size
);
ok
(
ret
,
"GetTokenInformation(TokenGroups) failed with error %ld
\n
"
,
GetLastError
());
trace
(
"TokenGroups:
\n
"
);
for
(
i
=
0
;
i
<
Groups
->
GroupCount
;
i
++
)
{
DWORD
NameLength
=
255
;
TCHAR
Name
[
255
];
DWORD
DomainLength
=
255
;
TCHAR
Domain
[
255
];
SID_NAME_USE
SidNameUse
;
ConvertSidToStringSid
(
Groups
->
Groups
[
i
].
Sid
,
&
SidString
);
Name
[
0
]
=
'\0'
;
Domain
[
0
]
=
'\0'
;
ret
=
LookupAccountSid
(
NULL
,
Groups
->
Groups
[
i
].
Sid
,
Name
,
&
NameLength
,
Domain
,
&
DomainLength
,
&
SidNameUse
);
ok
(
ret
,
"LookupAccountSid failed with error %ld
\n
"
,
GetLastError
());
trace
(
"
\t
%s, %s
\\
%s attr: 0x%08lx
\n
"
,
SidString
,
Domain
,
Name
,
Groups
->
Groups
[
i
].
Attributes
);
LocalFree
(
SidString
);
}
/* user */
ret
=
GetTokenInformation
(
Token
,
TokenUser
,
NULL
,
0
,
&
Size
);
ok
(
!
ret
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
),
"GetTokenInformation(TokenUser) failed with error %ld
\n
"
,
GetLastError
());
User
=
HeapAlloc
(
GetProcessHeap
(),
0
,
Size
);
ret
=
GetTokenInformation
(
Token
,
TokenUser
,
User
,
Size
,
&
Size
);
ok
(
ret
,
"GetTokenInformation(TokenUser) failed with error %ld
\n
"
,
GetLastError
());
ConvertSidToStringSid
(
User
->
User
.
Sid
,
&
SidString
);
trace
(
"TokenUser: %s attr: 0x%08lx
\n
"
,
SidString
,
User
->
User
.
Attributes
);
LocalFree
(
SidString
);
/* privileges */
ret
=
GetTokenInformation
(
Token
,
TokenPrivileges
,
NULL
,
0
,
&
Size
);
ok
(
!
ret
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
),
"GetTokenInformation(TokenPrivileges) failed with error %ld
\n
"
,
GetLastError
());
Privileges
=
HeapAlloc
(
GetProcessHeap
(),
0
,
Size
);
ret
=
GetTokenInformation
(
Token
,
TokenPrivileges
,
Privileges
,
Size
,
&
Size
);
ok
(
ret
,
"GetTokenInformation(TokenPrivileges) failed with error %ld
\n
"
,
GetLastError
());
trace
(
"TokenPrivileges:
\n
"
);
for
(
i
=
0
;
i
<
Privileges
->
PrivilegeCount
;
i
++
)
{
TCHAR
Name
[
256
];
DWORD
NameLen
=
sizeof
(
Name
)
/
sizeof
(
Name
[
0
]);
LookupPrivilegeName
(
NULL
,
&
Privileges
->
Privileges
[
i
].
Luid
,
Name
,
&
NameLen
);
trace
(
"
\t
%s, 0x%lx
\n
"
,
Name
,
Privileges
->
Privileges
[
i
].
Attributes
);
}
}
START_TEST
(
security
)
{
init
();
...
...
@@ -702,4 +771,5 @@ START_TEST(security)
test_luid
();
test_FileSecurity
();
test_AccessCheck
();
test_token_attr
();
}
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