server: Make create_mutex use struct object_attributes and set the security descriptor of mutex objects.

This commit is contained in:
Rob Shearman 2007-10-25 15:43:05 +01:00 committed by Alexandre Julliard
parent b0e5fb4384
commit 1f86321964
5 changed files with 42 additions and 15 deletions

View File

@ -415,22 +415,36 @@ NTSTATUS WINAPI NtCreateMutant(OUT HANDLE* MutantHandle,
IN const OBJECT_ATTRIBUTES* attr OPTIONAL,
IN BOOLEAN InitialOwner)
{
NTSTATUS status;
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS status;
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;
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 )
{
req->access = access;
req->attributes = (attr) ? attr->Attributes : 0;
req->rootdir = attr ? attr->RootDirectory : 0;
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 );
status = wine_server_call( req );
*MutantHandle = reply->handle;
}
SERVER_END_REQ;
free_struct_sd( sd );
return status;
}

View File

@ -914,9 +914,8 @@ struct create_mutex_request
struct request_header __header;
unsigned int access;
unsigned int attributes;
obj_handle_t rootdir;
int owned;
/* VARARG(name,unicode_str); */
/* VARARG(objattr,object_attributes); */
};
struct create_mutex_reply
{
@ -4879,6 +4878,6 @@ union generic_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 */

View File

@ -34,6 +34,7 @@
#include "handle.h"
#include "thread.h"
#include "request.h"
#include "security.h"
struct mutex
{
@ -72,7 +73,7 @@ static const struct object_ops mutex_ops =
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;
@ -85,6 +86,10 @@ static struct mutex *create_mutex( struct directory *root, const struct unicode_
mutex->owner = NULL;
mutex->abandoned = 0;
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;
@ -191,13 +196,24 @@ DECL_HANDLER(create_mutex)
struct mutex *mutex;
struct unicode_str name;
struct directory *root = NULL;
const struct object_attributes *objattr = get_req_data();
const struct security_descriptor *sd;
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;
if ((mutex = create_mutex( root, &name, req->attributes, req->owned )))
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;
if ((mutex = create_mutex( root, &name, req->attributes, req->owned, sd )))
{
reply->handle = alloc_handle( current->process, mutex, req->access, req->attributes );
release_object( mutex );

View File

@ -781,9 +781,8 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
@REQ(create_mutex)
unsigned int access; /* wanted access rights */
unsigned int attributes; /* object attributes */
obj_handle_t rootdir; /* root directory */
int owned; /* initially owned? */
VARARG(name,unicode_str); /* object name */
VARARG(objattr,object_attributes); /* object attributes */
@REPLY
obj_handle_t handle; /* handle to the mutex */
@END

View File

@ -1191,10 +1191,9 @@ static void dump_create_mutex_request( const struct create_mutex_request *req )
{
fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " attributes=%08x,", req->attributes );
fprintf( stderr, " rootdir=%p,", req->rootdir );
fprintf( stderr, " owned=%d,", req->owned );
fprintf( stderr, " name=" );
dump_varargs_unicode_str( cur_size );
fprintf( stderr, " objattr=" );
dump_varargs_object_attributes( cur_size );
}
static void dump_create_mutex_reply( const struct create_mutex_reply *req )