server: Make create_mapping use struct object_attributes and set the security descriptor of file mapping objects.
diff --git a/server/mapping.c b/server/mapping.c
index 33e4204..8f1bf5c 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -37,6 +37,7 @@
#include "handle.h"
#include "thread.h"
#include "request.h"
+#include "security.h"
struct mapping
{
@@ -281,7 +282,7 @@
static struct object *create_mapping( struct directory *root, const struct unicode_str *name,
unsigned int attr, file_pos_t size, int protect,
- obj_handle_t handle )
+ obj_handle_t handle, const struct security_descriptor *sd )
{
struct mapping *mapping;
int access = 0;
@@ -293,6 +294,10 @@
if (get_error() == STATUS_OBJECT_NAME_EXISTS)
return &mapping->obj; /* Nothing else to do */
+ if (sd) default_set_sd( &mapping->obj, sd, OWNER_SECURITY_INFORMATION|
+ GROUP_SECURITY_INFORMATION|
+ DACL_SECURITY_INFORMATION|
+ SACL_SECURITY_INFORMATION );
mapping->header_size = 0;
mapping->base = NULL;
mapping->shared_file = NULL;
@@ -394,13 +399,24 @@
struct object *obj;
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 ((obj = create_mapping( root, &name, req->attributes, req->size, req->protect, req->file_handle )))
+ 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 ((obj = create_mapping( root, &name, req->attributes, req->size, req->protect, req->file_handle, sd )))
{
reply->handle = alloc_handle( current->process, obj, req->access, req->attributes );
release_object( obj );