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
d195bbeb
Commit
d195bbeb
authored
Jan 18, 2013
by
Erich Hoover
Committed by
Alexandre Julliard
Jan 30, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Make an internal routine for [Get|Set]SecurityInfo file objects.
parent
e4717c29
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
42 deletions
+38
-42
security.c
dlls/advapi32/security.c
+38
-42
No files found.
dlls/advapi32/security.c
View file @
d195bbeb
...
...
@@ -401,6 +401,28 @@ static inline BOOL set_ntstatus( NTSTATUS status )
return
!
status
;
}
/* helper function for SE_FILE_OBJECT objects in [Get|Set]NamedSecurityInfo */
static
inline
DWORD
get_security_file
(
LPWSTR
full_file_name
,
DWORD
access
,
HANDLE
*
file
)
{
UNICODE_STRING
file_nameW
;
OBJECT_ATTRIBUTES
attr
;
IO_STATUS_BLOCK
io
;
NTSTATUS
status
;
if
(
!
RtlDosPathNameToNtPathName_U
(
full_file_name
,
&
file_nameW
,
NULL
,
NULL
))
return
ERROR_PATH_NOT_FOUND
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
attr
.
Attributes
=
OBJ_CASE_INSENSITIVE
;
attr
.
ObjectName
=
&
file_nameW
;
attr
.
SecurityDescriptor
=
NULL
;
status
=
NtCreateFile
(
file
,
access
,
&
attr
,
&
io
,
NULL
,
FILE_FLAG_BACKUP_SEMANTICS
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
,
FILE_OPEN
,
FILE_OPEN_FOR_BACKUP_INTENT
,
NULL
,
0
);
RtlFreeUnicodeString
(
&
file_nameW
);
return
RtlNtStatusToDosError
(
status
);
}
#define WINE_SIZE_OF_WORLD_ACCESS_ACL (sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + sizeof(sidWorld) - sizeof(DWORD))
static
void
GetWorldAccessACL
(
PACL
pACL
)
...
...
@@ -3964,12 +3986,9 @@ DWORD WINAPI SetNamedSecurityInfoW(LPWSTR pObjectName,
SE_OBJECT_TYPE
ObjectType
,
SECURITY_INFORMATION
SecurityInfo
,
PSID
psidOwner
,
PSID
psidGroup
,
PACL
pDacl
,
PACL
pSacl
)
{
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
;
IO_STATUS_BLOCK
io
;
DWORD
access
=
0
;
HANDLE
h
Fi
le
;
DWORD
status
;
HANDLE
h
and
le
;
DWORD
err
;
TRACE
(
"%s %d %d %p %p %p %p
\n
"
,
debugstr_w
(
pObjectName
),
ObjectType
,
SecurityInfo
,
psidOwner
,
psidGroup
,
pDacl
,
pSacl
);
...
...
@@ -3980,8 +3999,6 @@ DWORD WINAPI SetNamedSecurityInfoW(LPWSTR pObjectName,
}
if
(
!
pObjectName
)
return
ERROR_INVALID_PARAMETER
;
if
(
!
RtlDosPathNameToNtPathName_U
(
pObjectName
,
&
nameW
,
NULL
,
NULL
))
return
ERROR_PATH_NOT_FOUND
;
if
(
SecurityInfo
&
(
OWNER_SECURITY_INFORMATION
|
GROUP_SECURITY_INFORMATION
))
access
|=
WRITE_OWNER
;
...
...
@@ -3989,21 +4006,13 @@ DWORD WINAPI SetNamedSecurityInfoW(LPWSTR pObjectName,
access
|=
WRITE_DAC
;
if
(
SecurityInfo
&
SACL_SECURITY_INFORMATION
)
access
|=
ACCESS_SYSTEM_SECURITY
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
attr
.
Attributes
=
OBJ_CASE_INSENSITIVE
;
attr
.
ObjectName
=
&
nameW
;
attr
.
SecurityDescriptor
=
NULL
;
status
=
NtCreateFile
(
&
hFile
,
access
,
&
attr
,
&
io
,
NULL
,
FILE_FLAG_BACKUP_SEMANTICS
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
,
FILE_OPEN
,
FILE_OPEN_FOR_BACKUP_INTENT
,
NULL
,
0
);
RtlFreeUnicodeString
(
&
nameW
);
if
(
status
!=
STATUS_SUCCESS
)
return
RtlNtStatusToDosError
(
status
);
status
=
SetSecurityInfo
(
hFile
,
ObjectType
,
SecurityInfo
,
psidOwner
,
psidGroup
,
pDacl
,
pSacl
);
CloseHandle
(
hFile
);
return
status
;
err
=
get_security_file
(
pObjectName
,
access
,
&
handle
);
if
(
err
!=
ERROR_SUCCESS
)
return
err
;
err
=
SetSecurityInfo
(
handle
,
ObjectType
,
SecurityInfo
,
psidOwner
,
psidGroup
,
pDacl
,
pSacl
);
CloseHandle
(
handle
);
return
err
;
}
/******************************************************************************
...
...
@@ -5520,12 +5529,9 @@ DWORD WINAPI GetNamedSecurityInfoW( LPWSTR name, SE_OBJECT_TYPE type,
SECURITY_INFORMATION
info
,
PSID
*
owner
,
PSID
*
group
,
PACL
*
dacl
,
PACL
*
sacl
,
PSECURITY_DESCRIPTOR
*
descriptor
)
{
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
;
IO_STATUS_BLOCK
io
;
DWORD
access
=
0
;
HANDLE
h
Fi
le
;
DWORD
status
;
HANDLE
h
and
le
;
DWORD
err
;
TRACE
(
"%s %d %d %p %p %p %p %p
\n
"
,
debugstr_w
(
name
),
type
,
info
,
owner
,
group
,
dacl
,
sacl
,
descriptor
);
...
...
@@ -5550,28 +5556,18 @@ DWORD WINAPI GetNamedSecurityInfoW( LPWSTR name, SE_OBJECT_TYPE type,
||
((
info
&
DACL_SECURITY_INFORMATION
)
&&
!
dacl
)
||
((
info
&
SACL_SECURITY_INFORMATION
)
&&
!
sacl
)
))
return
ERROR_INVALID_PARAMETER
;
if
(
!
RtlDosPathNameToNtPathName_U
(
name
,
&
nameW
,
NULL
,
NULL
))
return
ERROR_PATH_NOT_FOUND
;
if
(
info
&
(
OWNER_SECURITY_INFORMATION
|
GROUP_SECURITY_INFORMATION
|
DACL_SECURITY_INFORMATION
))
access
|=
READ_CONTROL
;
if
(
info
&
SACL_SECURITY_INFORMATION
)
access
|=
ACCESS_SYSTEM_SECURITY
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
attr
.
Attributes
=
OBJ_CASE_INSENSITIVE
;
attr
.
ObjectName
=
&
nameW
;
attr
.
SecurityDescriptor
=
NULL
;
status
=
NtCreateFile
(
&
hFile
,
access
,
&
attr
,
&
io
,
NULL
,
FILE_FLAG_BACKUP_SEMANTICS
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
,
FILE_OPEN
,
FILE_OPEN_FOR_BACKUP_INTENT
,
NULL
,
0
);
RtlFreeUnicodeString
(
&
nameW
);
if
(
status
!=
STATUS_SUCCESS
)
return
RtlNtStatusToDosError
(
status
);
status
=
GetSecurityInfo
(
hFile
,
type
,
info
,
owner
,
group
,
dacl
,
sacl
,
descriptor
);
CloseHandle
(
hFile
);
return
status
;
err
=
get_security_file
(
name
,
access
,
&
handle
);
if
(
err
!=
ERROR_SUCCESS
)
return
err
;
err
=
GetSecurityInfo
(
handle
,
type
,
info
,
owner
,
group
,
dacl
,
sacl
,
descriptor
);
CloseHandle
(
handle
);
return
err
;
}
/******************************************************************************
...
...
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