From 8cc619c2232df496fa08c128368754c062a666ce Mon Sep 17 00:00:00 2001 From: speidy Date: Wed, 30 Oct 2013 19:41:59 +0200 Subject: [PATCH 1/2] libxrdp: work on multimon --- common/xrdp_client_info.h | 17 ++++++++++++++--- libxrdp/libxrdp.h | 10 ---------- libxrdp/xrdp_mcs.c | 14 -------------- libxrdp/xrdp_sec.c | 39 +++++++++++++++++++++------------------ 4 files changed, 35 insertions(+), 45 deletions(-) diff --git a/common/xrdp_client_info.h b/common/xrdp_client_info.h index effac271..56aeb0bd 100644 --- a/common/xrdp_client_info.h +++ b/common/xrdp_client_info.h @@ -21,6 +21,15 @@ #if !defined(XRDP_CLIENT_INFO_H) #define XRDP_CLIENT_INFO_H +struct monitor_info +{ + int left; + int top; + int right; + int bottom; + int is_primary; +}; + struct xrdp_client_info { int size; /* bytes for this structure */ @@ -38,7 +47,6 @@ struct xrdp_client_info int bitmap_cache_version; /* ored 1 = original version, 2 = v2, 4 = v3 */ /* pointer info */ int pointer_cache_entries; - int pointer_flags; /* 0 color, 1 new, 2 no new */ /* other */ int use_bitmap_comp; int use_bitmap_cache; @@ -70,8 +78,6 @@ struct xrdp_client_info int offscreen_cache_size; int offscreen_cache_entries; int rfx; - int nego_sec_layer; /* 0, 1, 2 = RDP security layer, TLS , Negotiate */ - int multimon; /* 0 = deny , 1 = allow */ /* CAPSETTYPE_RAIL */ int rail_support_level; @@ -95,9 +101,14 @@ struct xrdp_client_info int order_flags_ex; int use_bulk_comp; int use_fast_path; + int pointer_flags; /* 0 color, 1 new, 2 no new */ int require_credentials; /* when true, credentials *must* be passed on cmd line */ char client_addr[256]; char client_port[256]; + + int nego_sec_layer; /* 0, 1, 2 = RDP security layer, TLS , Negotiate */ + int multimon; /* 0 = deny , 1 = allow */ + struct monitor_info minfo[16]; /* client monitor data */ }; #endif diff --git a/libxrdp/libxrdp.h b/libxrdp/libxrdp.h index f72b8b11..2790e991 100644 --- a/libxrdp/libxrdp.h +++ b/libxrdp/libxrdp.h @@ -61,16 +61,6 @@ struct mcs_channel_item int chanid; }; -/* used in mcs - client monitor data */ -struct mcs_monitor_item -{ - int left; - int top; - int right; - int bottom; - int is_primary; -}; - /* mcs */ struct xrdp_mcs { diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c index 86212bb1..c145158c 100644 --- a/libxrdp/xrdp_mcs.c +++ b/libxrdp/xrdp_mcs.c @@ -38,7 +38,6 @@ xrdp_mcs_create(struct xrdp_sec *owner, struct trans *trans, self->server_mcs_data = server_mcs_data; self->iso_layer = xrdp_iso_create(self, trans); self->channel_list = list_create(); - self->monitor_list = list_create(); DEBUG((" out xrdp_mcs_create")); return self; } @@ -48,7 +47,6 @@ void APP_CC xrdp_mcs_delete(struct xrdp_mcs *self) { struct mcs_channel_item *channel_item; - struct mcs_monitor_item *monitor_item; int index; int count; @@ -69,18 +67,6 @@ xrdp_mcs_delete(struct xrdp_mcs *self) list_delete(self->channel_list); - /* here we have to free the monitor items and anything in them */ - count = self->monitor_list->count; - - for (index = count - 1; index >= 0; index--) - { - monitor_item = (struct mcs_monitor_item *) - list_get_item(self->monitor_list, index); - g_free(monitor_item); - } - - list_delete(self->monitor_list); - xrdp_iso_delete(self->iso_layer); /* make sure we get null pointer exception if struct is used again. */ DEBUG(("xrdp_mcs_delete processed")) diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c index 161f88f8..dd0e2cd6 100644 --- a/libxrdp/xrdp_sec.c +++ b/libxrdp/xrdp_sec.c @@ -959,7 +959,9 @@ xrdp_sec_process_mcs_data_monitors(struct xrdp_sec *self, struct stream *s) int index; int monitorCount; int flags; - struct mcs_monitor_item *monitor_item; + struct xrdp_client_info *client_info = (struct xrdp_client_info *)NULL; + + client_info = &(self->rdp_layer->client_info); DEBUG(("processing monitors data, allow_multimon is %d", self->multimon)); /* this is an option set in xrdp.ini */ @@ -975,7 +977,7 @@ xrdp_sec_process_mcs_data_monitors(struct xrdp_sec *self, struct stream *s) { DEBUG(("[ERROR] xrdp_sec_process_mcs_data_monitors: flags MUST be " "zero, detected: %d", flags)); - return 0; + return 1; } in_uint32_le(s, monitorCount); //verify monitorCount - max 16 @@ -983,24 +985,23 @@ xrdp_sec_process_mcs_data_monitors(struct xrdp_sec *self, struct stream *s) { DEBUG(("[ERROR] xrdp_sec_process_mcs_data_monitors: max allowed " "monitors is 16, detected: %d", monitorCount)); - return 0; + return 1; } + + g_writeln("monitorCount= %d", monitorCount); // for debugging only + + /* Add client_monitor_data to client_info struct, will later pass to X11rdp */ for (index = 0; index < monitorCount; index++) { - monitor_item = (struct mcs_monitor_item *) - g_malloc(sizeof(struct mcs_monitor_item), 1); - in_uint32_le(s, monitor_item->left); - in_uint32_le(s, monitor_item->top); - in_uint32_le(s, monitor_item->right); - in_uint32_le(s, monitor_item->bottom); - in_uint32_le(s, monitor_item->is_primary); - list_add_item(self->mcs_layer->monitor_list, (long)monitor_item); - DEBUG(("got monitor: left: %d, top: %d, right: %d, bottom: %d, is " - "primary: %d", monitor_item->left, monitor_item->top, - monitor_item->right, monitor_item->bottom, - monitor_item->is_primary)); - } + in_uint32_le(s, client_info->minfo->left); + in_uint32_le(s, client_info->minfo->top); + in_uint32_le(s, client_info->minfo->right); + in_uint32_le(s, client_info->minfo->bottom); + in_uint32_le(s, client_info->minfo->is_primary); + g_writeln("got a monitor: left= %d, top= %d, right= %d, bottom= %d, is_primary?= %d", client_info->minfo->left, + client_info->minfo->top, client_info->minfo->right, client_info->minfo->bottom, client_info->minfo->is_primary); + } return 0; } /*****************************************************************************/ @@ -1052,7 +1053,10 @@ xrdp_sec_process_mcs_data(struct xrdp_sec *self) case SEC_TAG_CLI_4: break; case SEC_TAG_CLI_MONITOR: - xrdp_sec_process_mcs_data_monitors(self, s); + if (xrdp_sec_process_mcs_data_monitors(self, s) != 0) + { + return 1; + } break; default: g_writeln("error unknown xrdp_sec_process_mcs_data tag %d size %d", @@ -1210,7 +1214,6 @@ xrdp_sec_in_mcs_data(struct xrdp_sec *self) client_info->hostname[index] = c; index++; } - /* get build */ s->p = s->data; if (!s_check_rem(s, 43 + 4)) From 5591c19b3f158d637a3f767ef1c39b9cc4463304 Mon Sep 17 00:00:00 2001 From: speidy Date: Wed, 30 Oct 2013 21:34:51 +0200 Subject: [PATCH 2/2] libxrdp: remove old monitor_list struct --- libxrdp/libxrdp.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libxrdp/libxrdp.h b/libxrdp/libxrdp.h index 2790e991..5bf627b5 100644 --- a/libxrdp/libxrdp.h +++ b/libxrdp/libxrdp.h @@ -71,7 +71,6 @@ struct xrdp_mcs struct stream* client_mcs_data; struct stream* server_mcs_data; struct list* channel_list; - struct list* monitor_list; }; /* sec */