server: Make create_semaphore use struct object_attributes and set the security descriptor of semaphore objects.
diff --git a/server/protocol.def b/server/protocol.def
index 41f71ca..b2ece5e 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -812,10 +812,9 @@
@REQ(create_semaphore)
unsigned int access; /* wanted access rights */
unsigned int attributes; /* object attributes */
- obj_handle_t rootdir; /* root directory */
unsigned int initial; /* initial count */
unsigned int max; /* maximum count */
- VARARG(name,unicode_str); /* object name */
+ VARARG(objattr,object_attributes); /* object attributes */
@REPLY
obj_handle_t handle; /* handle to the semaphore */
@END
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 );
diff --git a/server/trace.c b/server/trace.c
index 4abdb55..dd2ef1e 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -1230,11 +1230,10 @@
{
fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " attributes=%08x,", req->attributes );
- fprintf( stderr, " rootdir=%p,", req->rootdir );
fprintf( stderr, " initial=%08x,", req->initial );
fprintf( stderr, " max=%08x,", req->max );
- fprintf( stderr, " name=" );
- dump_varargs_unicode_str( cur_size );
+ fprintf( stderr, " objattr=" );
+ dump_varargs_object_attributes( cur_size );
}
static void dump_create_semaphore_reply( const struct create_semaphore_reply *req )