server: Use generic file access rights (inside of console specific ones) for console management.
This commit is contained in:
parent
c1d35ba540
commit
465f3d1a85
|
@ -34,14 +34,11 @@
|
|||
#include "handle.h"
|
||||
#include "process.h"
|
||||
#include "request.h"
|
||||
#include "file.h"
|
||||
#include "unicode.h"
|
||||
#include "wincon.h"
|
||||
#include "winternl.h"
|
||||
|
||||
/* specific access rights (FIXME: should use finer-grained access rights) */
|
||||
#define CONSOLE_READ 0x01
|
||||
#define CONSOLE_WRITE 0x02
|
||||
|
||||
struct screen_buffer;
|
||||
struct console_input_events;
|
||||
|
||||
|
@ -67,8 +64,6 @@ struct console_input
|
|||
struct event *event; /* event to wait on for input queue */
|
||||
};
|
||||
|
||||
static unsigned int console_map_access( struct object *obj, unsigned int access );
|
||||
|
||||
static void console_input_dump( struct object *obj, int verbose );
|
||||
static void console_input_destroy( struct object *obj );
|
||||
|
||||
|
@ -83,7 +78,7 @@ static const struct object_ops console_input_ops =
|
|||
no_satisfied, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
no_get_fd, /* get_fd */
|
||||
console_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
default_get_sd, /* get_sd */
|
||||
default_set_sd, /* set_sd */
|
||||
no_lookup_name, /* lookup_name */
|
||||
|
@ -115,7 +110,7 @@ static const struct object_ops console_input_events_ops =
|
|||
no_satisfied, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
no_get_fd, /* get_fd */
|
||||
console_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
default_get_sd, /* get_sd */
|
||||
default_set_sd, /* set_sd */
|
||||
no_lookup_name, /* lookup_name */
|
||||
|
@ -158,7 +153,7 @@ static const struct object_ops screen_buffer_ops =
|
|||
NULL, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
no_get_fd, /* get_fd */
|
||||
console_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
default_get_sd, /* get_sd */
|
||||
default_set_sd, /* set_sd */
|
||||
no_lookup_name, /* lookup_name */
|
||||
|
@ -171,16 +166,6 @@ static struct list screen_buffer_list = LIST_INIT(screen_buffer_list);
|
|||
|
||||
static const char_info_t empty_char_info = { ' ', 0x000f }; /* white on black space */
|
||||
|
||||
/* access mapping for all console objects */
|
||||
static unsigned int console_map_access( struct object *obj, unsigned int access )
|
||||
{
|
||||
if (access & GENERIC_READ) access |= SYNCHRONIZE | STANDARD_RIGHTS_READ | CONSOLE_READ;
|
||||
if (access & GENERIC_WRITE) access |= SYNCHRONIZE | STANDARD_RIGHTS_WRITE | CONSOLE_WRITE;
|
||||
if (access & GENERIC_EXECUTE) access |= SYNCHRONIZE | STANDARD_RIGHTS_EXECUTE;
|
||||
if (access & GENERIC_ALL) access |= STANDARD_RIGHTS_ALL | CONSOLE_READ | CONSOLE_WRITE;
|
||||
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 )
|
||||
{
|
||||
|
@ -519,7 +504,7 @@ static int get_console_mode( obj_handle_t handle )
|
|||
struct object *obj;
|
||||
int ret = 0;
|
||||
|
||||
if ((obj = get_handle_obj( current->process, handle, CONSOLE_READ, NULL )))
|
||||
if ((obj = get_handle_obj( current->process, handle, FILE_READ_PROPERTIES, NULL )))
|
||||
{
|
||||
if (obj->ops == &console_input_ops)
|
||||
ret = ((struct console_input *)obj)->mode;
|
||||
|
@ -538,7 +523,7 @@ static int set_console_mode( obj_handle_t handle, int mode )
|
|||
struct object *obj;
|
||||
int ret = 0;
|
||||
|
||||
if (!(obj = get_handle_obj( current->process, handle, CONSOLE_WRITE, NULL )))
|
||||
if (!(obj = get_handle_obj( current->process, handle, FILE_WRITE_PROPERTIES, NULL )))
|
||||
return 0;
|
||||
if (obj->ops == &console_input_ops)
|
||||
{
|
||||
|
@ -607,7 +592,7 @@ static int read_console_input( obj_handle_t handle, int count, int flush )
|
|||
struct console_input *console;
|
||||
|
||||
if (!(console = (struct console_input *)get_handle_obj( current->process, handle,
|
||||
CONSOLE_READ, &console_input_ops )))
|
||||
FILE_READ_DATA, &console_input_ops )))
|
||||
return -1;
|
||||
|
||||
if (!count)
|
||||
|
@ -650,7 +635,7 @@ static int set_console_input_info( const struct set_console_input_info_request *
|
|||
struct console_input *console;
|
||||
struct console_renderer_event evt;
|
||||
|
||||
if (!(console = console_input_get( req->handle, CONSOLE_WRITE ))) goto error;
|
||||
if (!(console = console_input_get( req->handle, FILE_WRITE_PROPERTIES ))) goto error;
|
||||
|
||||
memset(&evt.u, 0, sizeof(evt.u));
|
||||
if (req->mask & SET_CONSOLE_INPUT_INFO_ACTIVE_SB)
|
||||
|
@ -658,7 +643,7 @@ static int set_console_input_info( const struct set_console_input_info_request *
|
|||
struct screen_buffer *screen_buffer;
|
||||
|
||||
screen_buffer = (struct screen_buffer *)get_handle_obj( current->process, req->active_sb,
|
||||
CONSOLE_WRITE, &screen_buffer_ops );
|
||||
FILE_WRITE_PROPERTIES, &screen_buffer_ops );
|
||||
if (!screen_buffer || screen_buffer->input != console)
|
||||
{
|
||||
set_error( STATUS_INVALID_HANDLE );
|
||||
|
@ -1252,7 +1237,7 @@ static void scroll_console_output( obj_handle_t handle, int xsrc, int ysrc, int
|
|||
struct console_renderer_event evt;
|
||||
|
||||
if (!(screen_buffer = (struct screen_buffer *)get_handle_obj( current->process, handle,
|
||||
CONSOLE_READ, &screen_buffer_ops )))
|
||||
FILE_WRITE_DATA, &screen_buffer_ops )))
|
||||
return;
|
||||
if (xsrc < 0 || ysrc < 0 || xdst < 0 || ydst < 0 ||
|
||||
xsrc + w > screen_buffer->width ||
|
||||
|
@ -1368,7 +1353,7 @@ DECL_HANDLER(get_console_renderer_events)
|
|||
struct console_input_events *evt;
|
||||
|
||||
evt = (struct console_input_events *)get_handle_obj( current->process, req->handle,
|
||||
CONSOLE_READ, &console_input_events_ops );
|
||||
FILE_READ_PROPERTIES, &console_input_events_ops );
|
||||
if (!evt) return;
|
||||
console_input_events_get( evt );
|
||||
release_object( evt );
|
||||
|
@ -1392,7 +1377,7 @@ DECL_HANDLER(open_console)
|
|||
obj = grab_object( (struct object*)current->process->console->active );
|
||||
}
|
||||
else if ((obj = get_handle_obj( current->process, req->from,
|
||||
CONSOLE_READ|CONSOLE_WRITE, &console_input_ops )))
|
||||
FILE_READ_PROPERTIES|FILE_WRITE_PROPERTIES, &console_input_ops )))
|
||||
{
|
||||
struct console_input *console = (struct console_input *)obj;
|
||||
obj = (console->active) ? grab_object( console->active ) : NULL;
|
||||
|
@ -1419,7 +1404,7 @@ DECL_HANDLER(get_console_input_info)
|
|||
{
|
||||
struct console_input *console;
|
||||
|
||||
if (!(console = console_input_get( req->handle, CONSOLE_READ ))) return;
|
||||
if (!(console = console_input_get( req->handle, FILE_READ_PROPERTIES ))) return;
|
||||
if (console->title)
|
||||
{
|
||||
data_size_t len = strlenW( console->title ) * sizeof(WCHAR);
|
||||
|
@ -1456,7 +1441,7 @@ DECL_HANDLER(write_console_input)
|
|||
|
||||
reply->written = 0;
|
||||
if (!(console = (struct console_input *)get_handle_obj( current->process, req->handle,
|
||||
CONSOLE_WRITE, &console_input_ops )))
|
||||
FILE_WRITE_PROPERTIES, &console_input_ops )))
|
||||
return;
|
||||
reply->written = write_console_input( console, get_req_data_size() / sizeof(INPUT_RECORD),
|
||||
get_req_data() );
|
||||
|
@ -1475,7 +1460,7 @@ DECL_HANDLER(append_console_input_history)
|
|||
{
|
||||
struct console_input *console;
|
||||
|
||||
if (!(console = console_input_get( req->handle, CONSOLE_WRITE ))) return;
|
||||
if (!(console = console_input_get( req->handle, FILE_WRITE_PROPERTIES ))) return;
|
||||
console_input_append_hist( console, get_req_data(), get_req_data_size() / sizeof(WCHAR) );
|
||||
release_object( console );
|
||||
}
|
||||
|
@ -1485,7 +1470,7 @@ DECL_HANDLER(get_console_input_history)
|
|||
{
|
||||
struct console_input *console;
|
||||
|
||||
if (!(console = console_input_get( req->handle, CONSOLE_WRITE ))) return;
|
||||
if (!(console = console_input_get( req->handle, FILE_READ_PROPERTIES ))) return;
|
||||
reply->total = console_input_get_hist( console, req->index );
|
||||
release_object( console );
|
||||
}
|
||||
|
@ -1496,7 +1481,7 @@ DECL_HANDLER(create_console_output)
|
|||
struct console_input* console;
|
||||
struct screen_buffer* screen_buffer;
|
||||
|
||||
if (!(console = console_input_get( req->handle_in, CONSOLE_WRITE ))) return;
|
||||
if (!(console = console_input_get( req->handle_in, FILE_WRITE_PROPERTIES ))) return;
|
||||
|
||||
screen_buffer = create_console_output( console );
|
||||
if (screen_buffer)
|
||||
|
@ -1515,7 +1500,7 @@ DECL_HANDLER(set_console_output_info)
|
|||
struct screen_buffer *screen_buffer;
|
||||
|
||||
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
|
||||
CONSOLE_WRITE, &screen_buffer_ops)))
|
||||
FILE_WRITE_PROPERTIES, &screen_buffer_ops)))
|
||||
{
|
||||
set_console_output_info( screen_buffer, req );
|
||||
release_object( screen_buffer );
|
||||
|
@ -1528,7 +1513,7 @@ DECL_HANDLER(get_console_output_info)
|
|||
struct screen_buffer *screen_buffer;
|
||||
|
||||
if ((screen_buffer = (struct screen_buffer *)get_handle_obj( current->process, req->handle,
|
||||
CONSOLE_READ, &screen_buffer_ops)))
|
||||
FILE_READ_PROPERTIES, &screen_buffer_ops)))
|
||||
{
|
||||
reply->cursor_size = screen_buffer->cursor_size;
|
||||
reply->cursor_visible = screen_buffer->cursor_visible;
|
||||
|
@ -1553,7 +1538,7 @@ DECL_HANDLER(read_console_output)
|
|||
struct screen_buffer *screen_buffer;
|
||||
|
||||
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
|
||||
CONSOLE_READ, &screen_buffer_ops )))
|
||||
FILE_READ_DATA, &screen_buffer_ops )))
|
||||
{
|
||||
read_console_output( screen_buffer, req->x, req->y, req->mode, req->wrap );
|
||||
reply->width = screen_buffer->width;
|
||||
|
@ -1568,7 +1553,7 @@ DECL_HANDLER(write_console_output)
|
|||
struct screen_buffer *screen_buffer;
|
||||
|
||||
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
|
||||
CONSOLE_WRITE, &screen_buffer_ops)))
|
||||
FILE_WRITE_DATA, &screen_buffer_ops)))
|
||||
{
|
||||
reply->written = write_console_output( screen_buffer, get_req_data_size(), get_req_data(),
|
||||
req->mode, req->x, req->y, req->wrap );
|
||||
|
@ -1584,7 +1569,7 @@ DECL_HANDLER(fill_console_output)
|
|||
struct screen_buffer *screen_buffer;
|
||||
|
||||
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
|
||||
CONSOLE_WRITE, &screen_buffer_ops)))
|
||||
FILE_WRITE_DATA, &screen_buffer_ops)))
|
||||
{
|
||||
reply->written = fill_console_output( screen_buffer, req->data, req->mode,
|
||||
req->x, req->y, req->count, req->wrap );
|
||||
|
|
Loading…
Reference in New Issue