[PATCH] [Server]: fix access rights for console creation (#24792)

Eric Pouech eric.pouech at orange.fr
Wed Oct 27 00:10:48 CDT 2010




A+
---

 server/console.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)


diff --git a/server/console.c b/server/console.c
index c00e1e8..95d4e54 100644
--- a/server/console.c
+++ b/server/console.c
@@ -68,6 +68,7 @@ struct console_input
 static void console_input_dump( struct object *obj, int verbose );
 static void console_input_destroy( struct object *obj );
 static struct fd *console_input_get_fd( struct object *obj );
+static unsigned int console_map_access( struct object *obj, unsigned int access );
 
 static const struct object_ops console_input_ops =
 {
@@ -80,7 +81,7 @@ static const struct object_ops console_input_ops =
     no_satisfied,                     /* satisfied */
     no_signal,                        /* signal */
     console_input_get_fd,             /* get_fd */
-    default_fd_map_access,            /* map_access */
+    console_map_access,               /* map_access */
     default_get_sd,                   /* get_sd */
     default_set_sd,                   /* set_sd */
     no_lookup_name,                   /* lookup_name */
@@ -157,7 +158,7 @@ static const struct object_ops screen_buffer_ops =
     NULL,                             /* satisfied */
     no_signal,                        /* signal */
     screen_buffer_get_fd,             /* get_fd */
-    default_fd_map_access,            /* map_access */
+    console_map_access,               /* map_access */
     default_get_sd,                   /* get_sd */
     default_set_sd,                   /* set_sd */
     no_lookup_name,                   /* lookup_name */
@@ -204,6 +205,23 @@ static enum server_fd_type console_get_fd_type( struct fd *fd )
     return FD_TYPE_CHAR;
 }
 
+static unsigned int console_map_access( struct object *obj, unsigned int access )
+{
+    if (access & GENERIC_READ)    access |= FILE_GENERIC_READ;
+    /* FIXME: we add FILE_READ_PROPERTIES access even in write-only mode.
+     * As tested on Windows, this is not correct (ie GetConsoleMode() on with GENERIC_WRITE only
+     * access fails).
+     * But, this is currently needed as part of kernel32/console.c client side code relies on the
+     * fact that it can read properties: lots of 'set' functions like WriteConsole,
+     * ScrollConsoleScreenBuffer, SetConsoleCursorPosition (and many others) do call 'get'
+     * functions.
+     */
+    if (access & GENERIC_WRITE)   access |= FILE_GENERIC_WRITE | FILE_READ_PROPERTIES;
+    if (access & GENERIC_EXECUTE) access |= FILE_GENERIC_EXECUTE;
+    if (access & GENERIC_ALL)     access |= FILE_ALL_ACCESS;
+    return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
+}
+
 /* dumps the renderer events of a console */
 static void console_input_events_dump( struct object *obj, int verbose )
 {






More information about the wine-patches mailing list