server: Make create_semaphore use struct object_attributes and set the security descriptor of semaphore objects.
diff --git a/server/semaphore.c b/server/semaphore.c
index af651e9..a8318cd 100644
--- a/server/semaphore.c
+++ b/server/semaphore.c
@@ -34,6 +34,7 @@
#include "handle.h"
#include "thread.h"
#include "request.h"
+#include "security.h"
struct semaphore
{
@@ -69,7 +70,8 @@
static struct semaphore *create_semaphore( struct directory *root, const struct unicode_str *name,
- unsigned int attr, unsigned int initial, unsigned int max )
+ unsigned int attr, unsigned int initial, unsigned int max,
+ const struct security_descriptor *sd )
{
struct semaphore *sem;
@@ -85,6 +87,10 @@
/* initialize it if it didn't already exist */
sem->count = initial;
sem->max = max;
+ if (sd) default_set_sd( &sem->obj, sd, OWNER_SECURITY_INFORMATION|
+ GROUP_SECURITY_INFORMATION|
+ DACL_SECURITY_INFORMATION|
+ SACL_SECURITY_INFORMATION );
}
}
return sem;
@@ -165,13 +171,23 @@
struct semaphore *sem;
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 ((sem = create_semaphore( root, &name, req->attributes, req->initial, req->max )))
+ 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 ((sem = create_semaphore( root, &name, req->attributes, req->initial, req->max, sd )))
{
reply->handle = alloc_handle( current->process, sem, req->access, req->attributes );
release_object( sem );