Create a token object in wineserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




ChangeLog: * Create a token object in wineserver
? server/named_pipe.c.good
? server/named_pipe.c.merged
? server/token.c
Index: dlls/ntdll/nt.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/nt.c,v
retrieving revision 1.52
diff -u -r1.52 nt.c
--- dlls/ntdll/nt.c	9 Jul 2003 02:57:57 -0000	1.52
+++ dlls/ntdll/nt.c	21 Jul 2003 09:32:03 -0000
@@ -210,10 +210,21 @@
 	DWORD DesiredAccess,
 	HANDLE *TokenHandle)
 {
-	FIXME("(%p,0x%08lx,%p): stub\n",
-	ProcessHandle,DesiredAccess, TokenHandle);
-	*TokenHandle = (HANDLE)0xcafe;
-	return 0;
+    NTSTATUS ret;
+
+    TRACE("(%p,0x%08lx,%p)\n", ProcessHandle,DesiredAccess, TokenHandle);
+
+    SERVER_START_REQ( open_token )
+    {
+        req->handle = ProcessHandle;
+        req->flags  = 0;
+        ret = wine_server_call( req );
+        if( !ret )
+            *TokenHandle = reply->handle;
+    }
+    SERVER_END_REQ;
+
+    return ret;
 }
 
 /******************************************************************************
@@ -226,10 +237,27 @@
 	BOOLEAN OpenAsSelf,
 	HANDLE *TokenHandle)
 {
-	FIXME("(%p,0x%08lx,0x%08x,%p): stub\n",
-	ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
-	*TokenHandle = (HANDLE)0xcafe;
-	return 0;
+    NTSTATUS ret;
+ 
+    TRACE("(%p,0x%08lx,0x%08x,%p)\n",
+          ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
+ 
+    SERVER_START_REQ( open_token )
+    {
+        req->handle = ThreadHandle;
+        req->flags  = OPEN_TOKEN_THREAD;
+        if( OpenAsSelf )
+            req->flags = OPEN_TOKEN_AS_SELF;
+        ret = wine_server_call( req );
+        if( !ret )
+            *TokenHandle = reply->handle;
+    }
+    SERVER_END_REQ;
+
+    return ret;
+}
+  
+  /******************************************************************************
 }
 
 /******************************************************************************
Index: include/wine/server_protocol.h
===================================================================
RCS file: /home/wine/wine/include/wine/server_protocol.h,v
retrieving revision 1.76
diff -u -r1.76 server_protocol.h
--- include/wine/server_protocol.h	11 Jul 2003 21:55:59 -0000	1.76
+++ include/wine/server_protocol.h	21 Jul 2003 09:32:05 -0000
@@ -3072,6 +3072,20 @@
     unsigned int   seqno;
 };
 
+#define OPEN_TOKEN_THREAD   1
+#define OPEN_TOKEN_AS_SELF  2
+struct open_token_request
+{
+    struct request_header __header;
+    obj_handle_t   handle;
+    unsigned int   flags;
+};
+struct open_token_reply
+{
+    struct reply_header __header;
+    obj_handle_t   handle;
+};
+
 #define SET_CB_OPEN      0x001
 #define SET_CB_OWNER     0x002
 #define SET_CB_VIEWER    0x004
@@ -3260,6 +3274,7 @@
     REQ_finish_hook_chain,
     REQ_get_next_hook,
     REQ_set_clipboard_info,
+    REQ_open_token,
     REQ_NB_REQUESTS
 };
 
@@ -3443,6 +3458,7 @@
     struct finish_hook_chain_request finish_hook_chain_request;
     struct get_next_hook_request get_next_hook_request;
     struct set_clipboard_info_request set_clipboard_info_request;
+    struct open_token_request open_token_request;
 };
 union generic_reply
 {
@@ -3624,8 +3640,9 @@
     struct finish_hook_chain_reply finish_hook_chain_reply;
     struct get_next_hook_reply get_next_hook_reply;
     struct set_clipboard_info_reply set_clipboard_info_reply;
+    struct open_token_reply open_token_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 116
+#define SERVER_PROTOCOL_VERSION 117
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
Index: server/Makefile.in
===================================================================
RCS file: /home/wine/wine/server/Makefile.in,v
retrieving revision 1.46
diff -u -r1.46 Makefile.in
--- server/Makefile.in	23 Jun 2003 23:02:03 -0000	1.46
+++ server/Makefile.in	21 Jul 2003 09:32:05 -0000
@@ -39,6 +39,7 @@
 	sock.c \
 	thread.c \
 	timer.c \
+	token.c \
 	trace.c \
 	unicode.c \
 	user.c \
Index: server/process.c
===================================================================
RCS file: /home/wine/wine/server/process.c,v
retrieving revision 1.105
diff -u -r1.105 process.c
--- server/process.c	21 Jun 2003 02:07:10 -0000	1.105
+++ server/process.c	21 Jul 2003 09:32:05 -0000
@@ -268,6 +268,7 @@
     process->exe.filename    = NULL;
     process->group_id        = 0;
     list_init( &process->locks );
+    process->token           = create_token();
 
     gettimeofday( &process->start_time, NULL );
     if ((process->next = first_process) != NULL) process->next->prev = process;
@@ -405,6 +406,7 @@
     if (process->exe.file) release_object( process->exe.file );
     if (process->exe.filename) free( process->exe.filename );
     if (process->id) free_ptid( process->id );
+    if (process->token) release_object( process->token );
 }
 
 /* dump a process on stdout for debugging purposes */
Index: server/process.h
===================================================================
RCS file: /home/wine/wine/server/process.h,v
retrieving revision 1.37
diff -u -r1.37 process.h
--- server/process.h	18 Mar 2003 05:04:33 -0000	1.37
+++ server/process.h	21 Jul 2003 09:32:05 -0000
@@ -77,6 +77,7 @@
     struct process_dll   exe;             /* main exe file */
     void                *ldt_copy;        /* pointer to LDT copy in client addr space */
     void                *ldt_flags;       /* pointer to LDT flags in client addr space */
+    struct token        *token;           /* process's security token */
 };
 
 struct process_snapshot
Index: server/protocol.def
===================================================================
RCS file: /home/wine/wine/server/protocol.def,v
retrieving revision 1.76
diff -u -r1.76 protocol.def
--- server/protocol.def	11 Jul 2003 21:55:58 -0000	1.76
+++ server/protocol.def	21 Jul 2003 09:32:06 -0000
@@ -2152,6 +2152,15 @@
     unsigned int   seqno;           /* current sequence number */
 @END
 
+#define OPEN_TOKEN_THREAD   1
+#define OPEN_TOKEN_AS_SELF  2
+@REQ(open_token)
+    obj_handle_t   handle;
+    unsigned int   flags;
+@REPLY
+    obj_handle_t   handle;
+@END
+
 #define SET_CB_OPEN      0x001
 #define SET_CB_OWNER     0x002
 #define SET_CB_VIEWER    0x004
Index: server/request.h
===================================================================
RCS file: /home/wine/wine/server/request.h,v
retrieving revision 1.86
diff -u -r1.86 request.h
--- server/request.h	23 Jun 2003 23:02:03 -0000	1.86
+++ server/request.h	21 Jul 2003 09:32:07 -0000
@@ -279,6 +279,7 @@
 DECL_HANDLER(finish_hook_chain);
 DECL_HANDLER(get_next_hook);
 DECL_HANDLER(set_clipboard_info);
+DECL_HANDLER(open_token);
 
 #ifdef WANT_REQUEST_HANDLERS
 
@@ -461,6 +462,7 @@
     (req_handler)req_finish_hook_chain,
     (req_handler)req_get_next_hook,
     (req_handler)req_set_clipboard_info,
+    (req_handler)req_open_token,
 };
 #endif  /* WANT_REQUEST_HANDLERS */
 
Index: server/thread.c
===================================================================
RCS file: /home/wine/wine/server/thread.c,v
retrieving revision 1.100
diff -u -r1.100 thread.c
--- server/thread.c	9 Jul 2003 02:57:57 -0000	1.100
+++ server/thread.c	21 Jul 2003 09:32:07 -0000
@@ -178,6 +178,8 @@
         return NULL;
     }
 
+    thread->token = (struct token *) grab_object( process->token );
+
     set_fd_events( thread->request_fd, POLLIN );  /* start listening to events */
     add_process_thread( thread->process, thread );
     return thread;
@@ -246,6 +248,7 @@
     cleanup_thread( thread );
     release_object( thread->process );
     if (thread->id) free_ptid( thread->id );
+    if( thread->token ) release_object( thread->token );
 }
 
 /* dump a thread on stdout for debugging purposes */
Index: server/thread.h
===================================================================
RCS file: /home/wine/wine/server/thread.h,v
retrieving revision 1.53
diff -u -r1.53 thread.h
--- server/thread.h	3 Jul 2003 18:16:48 -0000	1.53
+++ server/thread.h	21 Jul 2003 09:32:07 -0000
@@ -32,6 +32,7 @@
 struct debug_ctx;
 struct debug_event;
 struct msg_queue;
+struct token;
 
 enum run_state
 {
@@ -92,6 +93,7 @@
     int                    suspend;       /* suspend count */
     time_t                 creation_time; /* Thread creation time */
     time_t                 exit_time;     /* Thread exit time */
+    struct token          *token;         /* security token associated with this thread */
 };
 
 struct thread_snapshot
@@ -145,5 +147,8 @@
 static inline void clear_error(void)    { set_error(0); }
 
 static inline thread_id_t get_thread_id( struct thread *thread ) { return thread->id; }
+
+/* token functions */
+struct token *create_token( void );
 
 #endif  /* __WINE_SERVER_THREAD_H */
Index: server/trace.c
===================================================================
RCS file: /home/wine/wine/server/trace.c,v
retrieving revision 1.173
diff -u -r1.173 trace.c
--- server/trace.c	11 Jul 2003 21:55:58 -0000	1.173
+++ server/trace.c	21 Jul 2003 09:32:09 -0000
@@ -2486,6 +2486,17 @@
     fprintf( stderr, " seqno=%08x", req->seqno );
 }
 
+static void dump_open_token_request( const struct open_token_request *req )
+{
+    fprintf( stderr, " handle=%p,", req->handle );
+    fprintf( stderr, " flags=%08x", req->flags );
+}
+
+static void dump_open_token_reply( const struct open_token_reply *req )
+{
+    fprintf( stderr, " handle=%p", req->handle );
+}
+
 static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
     (dump_func)dump_new_process_request,
     (dump_func)dump_get_new_process_info_request,
@@ -2663,6 +2674,7 @@
     (dump_func)dump_finish_hook_chain_request,
     (dump_func)dump_get_next_hook_request,
     (dump_func)dump_set_clipboard_info_request,
+    (dump_func)dump_open_token_request,
 };
 
 static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
@@ -2842,6 +2854,7 @@
     (dump_func)0,
     (dump_func)dump_get_next_hook_reply,
     (dump_func)dump_set_clipboard_info_reply,
+    (dump_func)dump_open_token_reply,
 };
 
 static const char * const req_names[REQ_NB_REQUESTS] = {
@@ -3021,6 +3034,7 @@
     "finish_hook_chain",
     "get_next_hook",
     "set_clipboard_info",
+    "open_token",
 };
 
 /* ### make_requests end ### */
--- /dev/null	1994-07-18 08:46:18.000000000 +0900
+++ server/token.c	2003-07-21 18:38:42.000000000 +0900
@@ -0,0 +1,103 @@
+/*
+ * Tokens
+ *
+ * Copyright (C) 1998 Alexandre Julliard
+ * Copyright (C) 2003 Mike McCormack
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "windef.h"
+
+#include "handle.h"
+#include "thread.h"
+#include "process.h"
+#include "request.h"
+
+struct token
+{
+    struct object  obj;             /* object header */
+};
+
+static void token_dump( struct object *obj, int verbose );
+static void token_destroy( struct object *obj );
+
+static const struct object_ops token_ops =
+{
+    sizeof(struct token),      /* size */
+    token_dump,                /* dump */
+    no_add_queue,              /* add_queue */
+    NULL,                      /* remove_queue */
+    NULL,                      /* signaled */
+    NULL,                      /* satified */
+    no_get_fd,                 /* get_fd */
+    token_destroy              /* destroy */
+};
+
+static void token_destroy( struct object *obj )
+{
+}
+
+struct token *get_token_obj( struct process *process, obj_handle_t handle, unsigned int access )
+{
+    return (struct token *)get_handle_obj( process, handle, access, &token_ops );
+}
+
+static void token_dump( struct object *obj, int verbose )
+{
+    struct token *token = (struct token *)obj;
+    assert( obj->ops == &token_ops );
+    fprintf( stderr, "token %p\n", token );
+}
+
+struct token *create_token( void )
+{
+    struct token *token = alloc_object( &token_ops );
+    return token;
+}
+
+DECL_HANDLER(open_token)
+{
+    if( req->flags & OPEN_TOKEN_THREAD )
+    {
+        struct thread *thread;
+        thread = get_thread_from_handle( req->handle, 0 );
+        if( thread )
+        {
+            reply->handle = alloc_handle( current->process, thread->token,
+                                           TOKEN_ALL_ACCESS, 0);
+            release_object( thread );
+        }
+    }
+    else
+    {
+        struct process *process;
+        process = get_process_from_handle( req->handle, 0 );
+        if( process )
+        {
+            reply->handle = alloc_handle( current->process, process->token,
+                                           TOKEN_ALL_ACCESS, 0);
+            release_object( process );
+        }
+    }
+}
+

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux