Alexandre Julliard : server: Use attributes instead of inherit flag in token requests.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Dec 9 05:54:21 CST 2005


Module: wine
Branch: refs/heads/master
Commit: 836d07c36971305960d8af8d4c9acb4e3ae9de43
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=836d07c36971305960d8af8d4c9acb4e3ae9de43

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Dec  9 12:17:19 2005 +0100

server: Use attributes instead of inherit flag in token requests.
Also use the specified access rights in the open_token request.

---

 dlls/ntdll/nt.c                |   20 ++++++++++++--------
 include/wine/server_protocol.h |    6 ++++--
 server/protocol.def            |   10 ++++++----
 server/token.c                 |    9 ++++++---
 server/trace.c                 |    4 +++-
 5 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index a60820d..3fe44cb 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -63,10 +63,10 @@ NTSTATUS WINAPI NtDuplicateToken(
 
     SERVER_START_REQ( duplicate_token )
     {
-        req->handle = ExistingToken;
-        req->access = DesiredAccess;
-        req->inherit = ObjectAttributes && (ObjectAttributes->Attributes & OBJ_INHERIT);
-        req->primary = (TokenType == TokenPrimary);
+        req->handle              = ExistingToken;
+        req->access              = DesiredAccess;
+        req->attributes          = ObjectAttributes ? ObjectAttributes->Attributes : 0;
+        req->primary             = (TokenType == TokenPrimary);
         req->impersonation_level = ImpersonationLevel;
         status = wine_server_call( req );
         if (!status) *NewToken = reply->new_handle;
@@ -91,8 +91,10 @@ NTSTATUS WINAPI NtOpenProcessToken(
 
     SERVER_START_REQ( open_token )
     {
-        req->handle = ProcessHandle;
-        req->flags  = 0;
+        req->handle     = ProcessHandle;
+        req->access     = DesiredAccess;
+        req->attributes = 0;
+        req->flags      = 0;
         ret = wine_server_call( req );
         if (!ret) *TokenHandle = reply->token;
     }
@@ -118,8 +120,10 @@ NTSTATUS WINAPI NtOpenThreadToken(
 
     SERVER_START_REQ( open_token )
     {
-        req->handle = ThreadHandle;
-        req->flags  = OPEN_TOKEN_THREAD;
+        req->handle     = ThreadHandle;
+        req->access     = DesiredAccess;
+        req->attributes = 0;
+        req->flags      = OPEN_TOKEN_THREAD;
         if (OpenAsSelf) req->flags |= OPEN_TOKEN_AS_SELF;
         ret = wine_server_call( req );
         if (!ret) *TokenHandle = reply->token;
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index f38868f..65a5be8 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -3416,6 +3416,8 @@ struct open_token_request
 {
     struct request_header __header;
     obj_handle_t   handle;
+    unsigned int   access;
+    unsigned int   attributes;
     unsigned int   flags;
 };
 struct open_token_reply
@@ -3498,7 +3500,7 @@ struct duplicate_token_request
     struct request_header __header;
     obj_handle_t  handle;
     unsigned int  access;
-    int           inherit;
+    unsigned int  attributes;
     int           primary;
     int           impersonation_level;
 };
@@ -4319,6 +4321,6 @@ union generic_reply
     struct query_symlink_reply query_symlink_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 212
+#define SERVER_PROTOCOL_VERSION 213
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/protocol.def b/server/protocol.def
index df5a975..70b587a 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -2399,6 +2399,8 @@ enum message_type
 /* Open a security token */
 @REQ(open_token)
     obj_handle_t   handle;    /* handle to the thread or process */
+    unsigned int   access;    /* access rights to the new token */
+    unsigned int   attributes;/* object attributes */
     unsigned int   flags;     /* flags (see below) */
 @REPLY
     obj_handle_t   token;    /* handle to the token */
@@ -2454,10 +2456,10 @@ enum message_type
 @END
 
 @REQ(duplicate_token)
-    obj_handle_t  handle; /* handle to the token to duplicate */
-    unsigned int  access; /* access rights to the new token */
-    int           inherit; /* inherit flag */
-    int           primary; /* is the new token to be a primary one? */
+    obj_handle_t  handle;        /* handle to the token to duplicate */
+    unsigned int  access;        /* access rights to the new token */
+    unsigned int  attributes;    /* object attributes */
+    int           primary;       /* is the new token to be a primary one? */
     int           impersonation_level; /* impersonation level of the new token */
 @REPLY
     obj_handle_t  new_handle; /* duplicated handle */
diff --git a/server/token.c b/server/token.c
index a31d656..d10b9a1 100644
--- a/server/token.c
+++ b/server/token.c
@@ -883,7 +883,8 @@ DECL_HANDLER(open_token)
         if (thread)
         {
             if (thread->token)
-                reply->token = alloc_handle( current->process, thread->token, TOKEN_ALL_ACCESS, 0);
+                reply->token = alloc_handle( current->process, thread->token, req->access,
+                                             req->attributes & OBJ_INHERIT );
             else
                 set_error(STATUS_NO_TOKEN);
             release_object( thread );
@@ -895,7 +896,8 @@ DECL_HANDLER(open_token)
         if (process)
         {
             if (process->token)
-                reply->token = alloc_handle( current->process, process->token, TOKEN_ALL_ACCESS, 0);
+                reply->token = alloc_handle( current->process, process->token, req->access,
+                                             req->attributes & OBJ_INHERIT );
             else
                 set_error(STATUS_NO_TOKEN);
             release_object( process );
@@ -1015,7 +1017,8 @@ DECL_HANDLER(duplicate_token)
 
             access = req->access;
             if (access & MAXIMUM_ALLOWED) access = TOKEN_ALL_ACCESS; /* FIXME: needs general solution */
-            reply->new_handle = alloc_handle( current->process, token, access, req->inherit);
+            reply->new_handle = alloc_handle( current->process, token, access,
+                                              req->attributes & OBJ_INHERIT);
             release_object( token );
         }
         release_object( src_token );
diff --git a/server/trace.c b/server/trace.c
index 153f5a9..aff977f 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -2949,6 +2949,8 @@ static void dump_set_clipboard_info_repl
 static void dump_open_token_request( const struct open_token_request *req )
 {
     fprintf( stderr, " handle=%p,", req->handle );
+    fprintf( stderr, " access=%08x,", req->access );
+    fprintf( stderr, " attributes=%08x,", req->attributes );
     fprintf( stderr, " flags=%08x", req->flags );
 }
 
@@ -3021,7 +3023,7 @@ static void dump_duplicate_token_request
 {
     fprintf( stderr, " handle=%p,", req->handle );
     fprintf( stderr, " access=%08x,", req->access );
-    fprintf( stderr, " inherit=%d,", req->inherit );
+    fprintf( stderr, " attributes=%08x,", req->attributes );
     fprintf( stderr, " primary=%d,", req->primary );
     fprintf( stderr, " impersonation_level=%d", req->impersonation_level );
 }




More information about the wine-cvs mailing list