Alexandre Julliard : server: Pass full object attributes in the create_directory request.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jan 18 11:09:03 CST 2016


Module: wine
Branch: master
Commit: 82800f513c19a8e1c98a2ed6c1eb71a5d25680bb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=82800f513c19a8e1c98a2ed6c1eb71a5d25680bb

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Jan 15 19:02:18 2016 +0900

server: Pass full object attributes in the create_directory request.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/om.c                | 16 +++++++++-------
 include/wine/server_protocol.h |  4 +---
 server/directory.c             | 33 ++++++++++++++++++---------------
 server/protocol.def            |  4 +---
 server/request.h               |  4 +---
 server/trace.c                 |  4 +---
 6 files changed, 31 insertions(+), 34 deletions(-)

diff --git a/dlls/ntdll/om.c b/dlls/ntdll/om.c
index 3fadba7..cc3b4d6 100644
--- a/dlls/ntdll/om.c
+++ b/dlls/ntdll/om.c
@@ -478,25 +478,27 @@ NTSTATUS WINAPI NtOpenDirectoryObject(PHANDLE DirectoryHandle, ACCESS_MASK Desir
  *  Failure: An NTSTATUS error code.
  */
 NTSTATUS WINAPI NtCreateDirectoryObject(PHANDLE DirectoryHandle, ACCESS_MASK DesiredAccess,
-                                        POBJECT_ATTRIBUTES ObjectAttributes)
+                                        OBJECT_ATTRIBUTES *attr )
 {
     NTSTATUS ret;
+    data_size_t len;
+    struct object_attributes *objattr;
 
     if (!DirectoryHandle) return STATUS_ACCESS_VIOLATION;
-    TRACE("(%p,0x%08x,%s)\n", DirectoryHandle, DesiredAccess, debugstr_ObjectAttributes(ObjectAttributes));
+    TRACE("(%p,0x%08x,%s)\n", DirectoryHandle, DesiredAccess, debugstr_ObjectAttributes(attr));
+
+    if ((ret = alloc_object_attributes( attr, &objattr, &len ))) return ret;
 
     SERVER_START_REQ(create_directory)
     {
         req->access = DesiredAccess;
-        req->attributes = ObjectAttributes ? ObjectAttributes->Attributes : 0;
-        req->rootdir = wine_server_obj_handle( ObjectAttributes ? ObjectAttributes->RootDirectory : 0 );
-        if (ObjectAttributes && ObjectAttributes->ObjectName)
-            wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
-                                 ObjectAttributes->ObjectName->Length);
+        wine_server_add_data( req, objattr, len );
         ret = wine_server_call( req );
         *DirectoryHandle = wine_server_ptr_handle( reply->handle );
     }
     SERVER_END_REQ;
+
+    RtlFreeHeap( GetProcessHeap(), 0, objattr );
     return ret;
 }
 
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index e5b7506..8566617 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -4710,9 +4710,7 @@ struct create_directory_request
 {
     struct request_header __header;
     unsigned int   access;
-    unsigned int   attributes;
-    obj_handle_t   rootdir;
-    /* VARARG(directory_name,unicode_str); */
+    /* VARARG(objattr,object_attributes); */
 };
 struct create_directory_reply
 {
diff --git a/server/directory.c b/server/directory.c
index e0cf75e..d05b60f 100644
--- a/server/directory.c
+++ b/server/directory.c
@@ -189,7 +189,8 @@ static void directory_destroy( struct object *obj )
 }
 
 static struct directory *create_directory( struct directory *root, const struct unicode_str *name,
-                                           unsigned int attr, unsigned int hash_size )
+                                           unsigned int attr, unsigned int hash_size,
+                                           const struct security_descriptor *sd )
 {
     struct directory *dir;
 
@@ -201,6 +202,8 @@ static struct directory *create_directory( struct directory *root, const struct
             release_object( dir );
             dir = NULL;
         }
+        if (sd) default_set_sd( &dir->obj, sd, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION |
+                                DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION );
     }
     return dir;
 }
@@ -440,19 +443,19 @@ void init_directories(void)
     struct keyed_event *keyed_event;
     unsigned int i;
 
-    root_directory = create_directory( NULL, NULL, 0, HASH_SIZE );
-    dir_driver     = create_directory( root_directory, &dir_driver_str, 0, HASH_SIZE );
-    dir_device     = create_directory( root_directory, &dir_device_str, 0, HASH_SIZE );
-    dir_objtype    = create_directory( root_directory, &dir_objtype_str, 0, HASH_SIZE );
-    dir_sessions   = create_directory( root_directory, &dir_sessions_str, 0, HASH_SIZE );
-    dir_kernel     = create_directory( root_directory, &dir_kernel_str, 0, HASH_SIZE );
+    root_directory = create_directory( NULL, NULL, 0, HASH_SIZE, NULL );
+    dir_driver     = create_directory( root_directory, &dir_driver_str, 0, HASH_SIZE, NULL );
+    dir_device     = create_directory( root_directory, &dir_device_str, 0, HASH_SIZE, NULL );
+    dir_objtype    = create_directory( root_directory, &dir_objtype_str, 0, HASH_SIZE, NULL );
+    dir_sessions   = create_directory( root_directory, &dir_sessions_str, 0, HASH_SIZE, NULL );
+    dir_kernel     = create_directory( root_directory, &dir_kernel_str, 0, HASH_SIZE, NULL );
     make_object_static( &root_directory->obj );
     make_object_static( &dir_driver->obj );
     make_object_static( &dir_objtype->obj );
 
-    dir_global     = create_directory( NULL, &dir_global_str, 0, HASH_SIZE );
+    dir_global     = create_directory( NULL, &dir_global_str, 0, HASH_SIZE, NULL );
     /* use a larger hash table for this one since it can contain a lot of objects */
-    dir_basenamed  = create_directory( NULL, &dir_basenamed_str, 0, 37 );
+    dir_basenamed  = create_directory( NULL, &dir_basenamed_str, 0, 37, NULL );
 
     /* devices */
     create_named_pipe_device( dir_device, &named_pipe_str );
@@ -501,15 +504,15 @@ DECL_HANDLER(create_directory)
 {
     struct unicode_str name;
     struct directory *dir, *root = NULL;
+    const struct security_descriptor *sd;
+    const struct object_attributes *objattr = get_req_object_attributes( &sd, &name );
 
-    reply->handle = 0;
-    get_req_unicode_str( &name );
-    if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
-        return;
+    if (!objattr) return;
+    if (objattr->rootdir && !(root = get_directory_obj( current->process, objattr->rootdir, 0 ))) return;
 
-    if ((dir = create_directory( root, &name, req->attributes, HASH_SIZE )))
+    if ((dir = create_directory( root, &name, objattr->attributes, HASH_SIZE, sd )))
     {
-        reply->handle = alloc_handle( current->process, dir, req->access, req->attributes );
+        reply->handle = alloc_handle( current->process, dir, req->access, objattr->attributes );
         release_object( dir );
     }
 
diff --git a/server/protocol.def b/server/protocol.def
index 72a63e4..28c7022 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3300,9 +3300,7 @@ struct handle_info
 /* Create a directory object */
 @REQ(create_directory)
     unsigned int   access;        /* access flags */
-    unsigned int   attributes;    /* object attributes */
-    obj_handle_t   rootdir;       /* root directory */
-    VARARG(directory_name,unicode_str); /* Directory name */
+    VARARG(objattr,object_attributes); /* object attributes */
 @REPLY
     obj_handle_t   handle;        /* handle to the directory */
 @END
diff --git a/server/request.h b/server/request.h
index 310bcf4..2acf9cd 100644
--- a/server/request.h
+++ b/server/request.h
@@ -2095,9 +2095,7 @@ C_ASSERT( FIELD_OFFSET(struct set_mailslot_info_reply, read_timeout) == 8 );
 C_ASSERT( FIELD_OFFSET(struct set_mailslot_info_reply, max_msgsize) == 16 );
 C_ASSERT( sizeof(struct set_mailslot_info_reply) == 24 );
 C_ASSERT( FIELD_OFFSET(struct create_directory_request, access) == 12 );
-C_ASSERT( FIELD_OFFSET(struct create_directory_request, attributes) == 16 );
-C_ASSERT( FIELD_OFFSET(struct create_directory_request, rootdir) == 20 );
-C_ASSERT( sizeof(struct create_directory_request) == 24 );
+C_ASSERT( sizeof(struct create_directory_request) == 16 );
 C_ASSERT( FIELD_OFFSET(struct create_directory_reply, handle) == 8 );
 C_ASSERT( sizeof(struct create_directory_reply) == 16 );
 C_ASSERT( FIELD_OFFSET(struct open_directory_request, access) == 12 );
diff --git a/server/trace.c b/server/trace.c
index 82f8342..87fe202 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -3892,9 +3892,7 @@ static void dump_set_mailslot_info_reply( const struct set_mailslot_info_reply *
 static void dump_create_directory_request( const struct create_directory_request *req )
 {
     fprintf( stderr, " access=%08x", req->access );
-    fprintf( stderr, ", attributes=%08x", req->attributes );
-    fprintf( stderr, ", rootdir=%04x", req->rootdir );
-    dump_varargs_unicode_str( ", directory_name=", cur_size );
+    dump_varargs_object_attributes( ", objattr=", cur_size );
 }
 
 static void dump_create_directory_reply( const struct create_directory_reply *req )




More information about the wine-cvs mailing list