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
8fd1cf0f
Commit
8fd1cf0f
authored
Sep 27, 2007
by
Mikolaj Zalewski
Committed by
Alexandre Julliard
Sep 28, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Implement GetPrivateObjectSecurity (with test).
parent
0590dc9b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
3 deletions
+98
-3
security.c
dlls/advapi32/security.c
+42
-2
security.c
dlls/advapi32/tests/security.c
+56
-1
No files found.
dlls/advapi32/security.c
View file @
8fd1cf0f
...
...
@@ -1123,11 +1123,51 @@ BOOL WINAPI GetPrivateObjectSecurity(
DWORD
DescriptorLength
,
PDWORD
ReturnLength
)
{
SECURITY_DESCRIPTOR
desc
;
BOOL
defaulted
,
present
;
PACL
pacl
;
PSID
psid
;
TRACE
(
"(%p,0x%08x,%p,0x%08x,%p)
\n
"
,
ObjectDescriptor
,
SecurityInformation
,
ResultantDescriptor
,
DescriptorLength
,
ReturnLength
);
return
set_ntstatus
(
NtQuerySecurityObject
(
ObjectDescriptor
,
SecurityInformation
,
ResultantDescriptor
,
DescriptorLength
,
ReturnLength
));
if
(
!
InitializeSecurityDescriptor
(
&
desc
,
SECURITY_DESCRIPTOR_REVISION
))
return
FALSE
;
if
(
SecurityInformation
&
OWNER_SECURITY_INFORMATION
)
{
if
(
!
GetSecurityDescriptorOwner
(
ObjectDescriptor
,
&
psid
,
&
defaulted
))
return
FALSE
;
SetSecurityDescriptorOwner
(
&
desc
,
psid
,
defaulted
);
}
if
(
SecurityInformation
&
GROUP_SECURITY_INFORMATION
)
{
if
(
!
GetSecurityDescriptorGroup
(
ObjectDescriptor
,
&
psid
,
&
defaulted
))
return
FALSE
;
SetSecurityDescriptorGroup
(
&
desc
,
psid
,
defaulted
);
}
if
(
SecurityInformation
&
DACL_SECURITY_INFORMATION
)
{
if
(
!
GetSecurityDescriptorDacl
(
ObjectDescriptor
,
&
present
,
&
pacl
,
&
defaulted
))
return
FALSE
;
SetSecurityDescriptorDacl
(
&
desc
,
present
,
pacl
,
defaulted
);
}
if
(
SecurityInformation
&
SACL_SECURITY_INFORMATION
)
{
if
(
!
GetSecurityDescriptorSacl
(
ObjectDescriptor
,
&
present
,
&
pacl
,
&
defaulted
))
return
FALSE
;
SetSecurityDescriptorSacl
(
&
desc
,
present
,
pacl
,
defaulted
);
}
*
ReturnLength
=
DescriptorLength
;
if
(
!
MakeSelfRelativeSD
(
&
desc
,
ResultantDescriptor
,
ReturnLength
))
return
FALSE
;
GetSecurityDescriptorOwner
(
ResultantDescriptor
,
&
psid
,
&
defaulted
);
FIXME
(
"%p, sid=%p
\n
"
,
&
desc
,
psid
);
return
TRUE
;
}
/******************************************************************************
...
...
dlls/advapi32/tests/security.c
View file @
8fd1cf0f
...
...
@@ -2044,10 +2044,64 @@ static void test_ConvertSecurityDescriptorToString()
AddAuditAccessAceEx
(
pacl
,
ACL_REVISION
,
NO_PROPAGATE_INHERIT_ACE
,
FILE_GENERIC_READ
|
FILE_GENERIC_WRITE
,
psid2
,
TRUE
,
FALSE
);
ok
(
pConvertSecurityDescriptorToStringSecurityDescriptorA
(
&
desc
,
SDDL_REVISION_1
,
sec_info
,
&
string
,
&
len
),
"Convertion failed
\n
"
);
CHECK_RESULT_AND_FREE
(
"O:SYG:S-1-5-21-93476-23408-4576D:S:(AU;OICINPIOIDSAFA;CCDCLCSWRPRC;;;SU)(AU;NPSA;0x12019f;;;SU)"
);
}
static
void
test_PrivateObjectSecurity
(
void
)
{
SECURITY_INFORMATION
sec_info
=
OWNER_SECURITY_INFORMATION
|
GROUP_SECURITY_INFORMATION
|
DACL_SECURITY_INFORMATION
|
SACL_SECURITY_INFORMATION
;
SECURITY_DESCRIPTOR_CONTROL
ctrl
;
PSECURITY_DESCRIPTOR
sec
;
DWORD
dwDescSize
;
DWORD
dwRevision
;
DWORD
retSize
;
LPSTR
string
;
ULONG
len
;
PSECURITY_DESCRIPTOR
buf
;
ok
(
ConvertStringSecurityDescriptorToSecurityDescriptorA
(
"O:SY"
"G:S-1-5-21-93476-23408-4576"
"D:(A;NP;GAGXGWGR;;;SU)(A;IOID;CCDC;;;SU)(D;OICI;0xffffffff;;;S-1-5-21-93476-23408-4576)"
"S:(AU;OICINPIOIDSAFA;CCDCLCSWRPRC;;;SU)(AU;NPSA;0x12019f;;;SU)"
,
SDDL_REVISION_1
,
&
sec
,
&
dwDescSize
),
"Creating descriptor failed
\n
"
);
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwDescSize
);
SetSecurityDescriptorControl
(
sec
,
SE_DACL_PROTECTED
,
SE_DACL_PROTECTED
);
GetSecurityDescriptorControl
(
sec
,
&
ctrl
,
&
dwRevision
);
todo_wine
expect_eq
(
ctrl
,
0x9014
,
int
,
"%x"
);
ok
(
GetPrivateObjectSecurity
(
sec
,
GROUP_SECURITY_INFORMATION
,
buf
,
dwDescSize
,
&
retSize
),
"GetPrivateObjectSecurity failed (err=%u)
\n
"
,
GetLastError
());
ok
(
retSize
<=
dwDescSize
,
"Buffer too small (%d vs %d)
\n
"
,
retSize
,
dwDescSize
);
ok
(
pConvertSecurityDescriptorToStringSecurityDescriptorA
(
buf
,
SDDL_REVISION_1
,
sec_info
,
&
string
,
&
len
),
"Convertion failed
\n
"
);
CHECK_RESULT_AND_FREE
(
"G:S-1-5-21-93476-23408-4576"
);
GetSecurityDescriptorControl
(
buf
,
&
ctrl
,
&
dwRevision
);
expect_eq
(
ctrl
,
0x8000
,
int
,
"%x"
);
ok
(
GetPrivateObjectSecurity
(
sec
,
GROUP_SECURITY_INFORMATION
|
DACL_SECURITY_INFORMATION
,
buf
,
dwDescSize
,
&
retSize
),
"GetPrivateObjectSecurity failed (err=%u)
\n
"
,
GetLastError
());
ok
(
retSize
<=
dwDescSize
,
"Buffer too small (%d vs %d)
\n
"
,
retSize
,
dwDescSize
);
ok
(
pConvertSecurityDescriptorToStringSecurityDescriptorA
(
buf
,
SDDL_REVISION_1
,
sec_info
,
&
string
,
&
len
),
"Convertion failed err=%u
\n
"
,
GetLastError
());
CHECK_RESULT_AND_FREE
(
"G:S-1-5-21-93476-23408-4576D:(A;NP;GAGXGWGR;;;SU)(A;IOID;CCDC;;;SU)(D;OICI;0xffffffff;;;S-1-5-21-93476-23408-4576)"
);
GetSecurityDescriptorControl
(
buf
,
&
ctrl
,
&
dwRevision
);
expect_eq
(
ctrl
,
0x8004
,
int
,
"%x"
);
ok
(
GetPrivateObjectSecurity
(
sec
,
sec_info
,
buf
,
dwDescSize
,
&
retSize
),
"GetPrivateObjectSecurity failed (err=%u)
\n
"
,
GetLastError
());
ok
(
retSize
==
dwDescSize
,
"Buffer too small (%d vs %d)
\n
"
,
retSize
,
dwDescSize
);
ok
(
pConvertSecurityDescriptorToStringSecurityDescriptorA
(
buf
,
SDDL_REVISION_1
,
sec_info
,
&
string
,
&
len
),
"Convertion failed
\n
"
);
CHECK_RESULT_AND_FREE
(
"O:SY"
"G:S-1-5-21-93476-23408-4576"
"D:(A;NP;GAGXGWGR;;;SU)(A;IOID;CCDC;;;SU)(D;OICI;0xffffffff;;;S-1-5-21-93476-23408-4576)"
"S:(AU;OICINPIOIDSAFA;CCDCLCSWRPRC;;;SU)(AU;NPSA;0x12019f;;;SU)"
);
GetSecurityDescriptorControl
(
buf
,
&
ctrl
,
&
dwRevision
);
expect_eq
(
ctrl
,
0x8014
,
int
,
"%x"
);
SetLastError
(
0xdeadbeef
);
ok
(
GetPrivateObjectSecurity
(
sec
,
sec_info
,
buf
,
5
,
&
retSize
)
==
FALSE
,
"GetPrivateObjectSecurity should have failed
\n
"
);
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Expected error ERROR_INSUFFICIENT_BUFFER, got %u
\n
"
,
GetLastError
());
#undef CHECK_RESULT_AND_FREE
LocalFree
(
sec
);
}
#undef CHECK_RESULT_AND_FREE
START_TEST
(
security
)
{
...
...
@@ -2074,4 +2128,5 @@ START_TEST(security)
test_GetNamedSecurityInfoA
();
test_ConvertStringSecurityDescriptor
();
test_ConvertSecurityDescriptorToString
();
test_PrivateObjectSecurity
();
}
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