Commit 1f863219 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

server: Make create_mutex use struct object_attributes and set the security…

server: Make create_mutex use struct object_attributes and set the security descriptor of mutex objects.
parent b0e5fb43
...@@ -415,22 +415,36 @@ NTSTATUS WINAPI NtCreateMutant(OUT HANDLE* MutantHandle, ...@@ -415,22 +415,36 @@ NTSTATUS WINAPI NtCreateMutant(OUT HANDLE* MutantHandle,
IN const OBJECT_ATTRIBUTES* attr OPTIONAL, IN const OBJECT_ATTRIBUTES* attr OPTIONAL,
IN BOOLEAN InitialOwner) IN BOOLEAN InitialOwner)
{ {
NTSTATUS status; NTSTATUS status;
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
struct security_descriptor *sd = NULL;
struct object_attributes objattr;
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG; if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
objattr.rootdir = attr ? attr->RootDirectory : 0;
objattr.sd_len = 0;
if (attr)
{
status = create_struct_sd( attr->SecurityDescriptor, &sd, &objattr.sd_len );
if (status != STATUS_SUCCESS) return status;
}
SERVER_START_REQ( create_mutex ) SERVER_START_REQ( create_mutex )
{ {
req->access = access; req->access = access;
req->attributes = (attr) ? attr->Attributes : 0; req->attributes = (attr) ? attr->Attributes : 0;
req->rootdir = attr ? attr->RootDirectory : 0;
req->owned = InitialOwner; req->owned = InitialOwner;
wine_server_add_data( req, &objattr, sizeof(objattr) );
if (objattr.sd_len) wine_server_add_data( req, sd, objattr.sd_len );
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len ); if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
status = wine_server_call( req ); status = wine_server_call( req );
*MutantHandle = reply->handle; *MutantHandle = reply->handle;
} }
SERVER_END_REQ; SERVER_END_REQ;
free_struct_sd( sd );
return status; return status;
} }
......
...@@ -914,9 +914,8 @@ struct create_mutex_request ...@@ -914,9 +914,8 @@ struct create_mutex_request
struct request_header __header; struct request_header __header;
unsigned int access; unsigned int access;
unsigned int attributes; unsigned int attributes;
obj_handle_t rootdir;
int owned; int owned;
/* VARARG(name,unicode_str); */ /* VARARG(objattr,object_attributes); */
}; };
struct create_mutex_reply struct create_mutex_reply
{ {
...@@ -4879,6 +4878,6 @@ union generic_reply ...@@ -4879,6 +4878,6 @@ union generic_reply
struct set_completion_info_reply set_completion_info_reply; struct set_completion_info_reply set_completion_info_reply;
}; };
#define SERVER_PROTOCOL_VERSION 319 #define SERVER_PROTOCOL_VERSION 320
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "handle.h" #include "handle.h"
#include "thread.h" #include "thread.h"
#include "request.h" #include "request.h"
#include "security.h"
struct mutex struct mutex
{ {
...@@ -72,7 +73,7 @@ static const struct object_ops mutex_ops = ...@@ -72,7 +73,7 @@ static const struct object_ops mutex_ops =
static struct mutex *create_mutex( struct directory *root, const struct unicode_str *name, static struct mutex *create_mutex( struct directory *root, const struct unicode_str *name,
unsigned int attr, int owned ) unsigned int attr, int owned, const struct security_descriptor *sd )
{ {
struct mutex *mutex; struct mutex *mutex;
...@@ -85,6 +86,10 @@ static struct mutex *create_mutex( struct directory *root, const struct unicode_ ...@@ -85,6 +86,10 @@ static struct mutex *create_mutex( struct directory *root, const struct unicode_
mutex->owner = NULL; mutex->owner = NULL;
mutex->abandoned = 0; mutex->abandoned = 0;
if (owned) mutex_satisfied( &mutex->obj, current ); if (owned) mutex_satisfied( &mutex->obj, current );
if (sd) default_set_sd( &mutex->obj, sd, OWNER_SECURITY_INFORMATION|
GROUP_SECURITY_INFORMATION|
DACL_SECURITY_INFORMATION|
SACL_SECURITY_INFORMATION );
} }
} }
return mutex; return mutex;
...@@ -191,13 +196,24 @@ DECL_HANDLER(create_mutex) ...@@ -191,13 +196,24 @@ DECL_HANDLER(create_mutex)
struct mutex *mutex; struct mutex *mutex;
struct unicode_str name; struct unicode_str name;
struct directory *root = NULL; struct directory *root = NULL;
const struct object_attributes *objattr = get_req_data();
const struct security_descriptor *sd;
reply->handle = 0; reply->handle = 0;
get_req_unicode_str( &name );
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 ))) if (!objattr_is_valid( objattr, get_req_data_size() ))
return;
sd = objattr->sd_len ? (const struct security_descriptor *)(objattr + 1) : NULL;
/* get unicode string */
name.len = ((get_req_data_size() - sizeof(*objattr) - objattr->sd_len) / sizeof(WCHAR)) * sizeof(WCHAR);
name.str = (const WCHAR *)get_req_data() + (sizeof(*objattr) + objattr->sd_len) / sizeof(WCHAR);
if (objattr->rootdir && !(root = get_directory_obj( current->process, objattr->rootdir, 0 )))
return; return;
if ((mutex = create_mutex( root, &name, req->attributes, req->owned ))) if ((mutex = create_mutex( root, &name, req->attributes, req->owned, sd )))
{ {
reply->handle = alloc_handle( current->process, mutex, req->access, req->attributes ); reply->handle = alloc_handle( current->process, mutex, req->access, req->attributes );
release_object( mutex ); release_object( mutex );
......
...@@ -781,9 +781,8 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT }; ...@@ -781,9 +781,8 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
@REQ(create_mutex) @REQ(create_mutex)
unsigned int access; /* wanted access rights */ unsigned int access; /* wanted access rights */
unsigned int attributes; /* object attributes */ unsigned int attributes; /* object attributes */
obj_handle_t rootdir; /* root directory */
int owned; /* initially owned? */ int owned; /* initially owned? */
VARARG(name,unicode_str); /* object name */ VARARG(objattr,object_attributes); /* object attributes */
@REPLY @REPLY
obj_handle_t handle; /* handle to the mutex */ obj_handle_t handle; /* handle to the mutex */
@END @END
......
...@@ -1191,10 +1191,9 @@ static void dump_create_mutex_request( const struct create_mutex_request *req ) ...@@ -1191,10 +1191,9 @@ static void dump_create_mutex_request( const struct create_mutex_request *req )
{ {
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " attributes=%08x,", req->attributes ); fprintf( stderr, " attributes=%08x,", req->attributes );
fprintf( stderr, " rootdir=%p,", req->rootdir );
fprintf( stderr, " owned=%d,", req->owned ); fprintf( stderr, " owned=%d,", req->owned );
fprintf( stderr, " name=" ); fprintf( stderr, " objattr=" );
dump_varargs_unicode_str( cur_size ); dump_varargs_object_attributes( cur_size );
} }
static void dump_create_mutex_reply( const struct create_mutex_reply *req ) static void dump_create_mutex_reply( const struct create_mutex_reply *req )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment