From 7d305b0085a652f618efdb840ca306ea9ffd573d Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:24:26 +0100 Subject: [PATCH] Add support for SCP_SESSION_TYPE_RESIZEABLE_VNC --- sesman/libscp/libscp_session.c | 4 ++++ sesman/libscp/libscp_types.h | 11 ++++++----- sesman/libscp/libscp_v0.c | 10 +++++++++- sesman/scp_v0.c | 3 ++- sesman/scp_v1.c | 3 ++- sesman/session.c | 5 ++++- sesman/tools/sesrun.c | 14 +++++++++++--- xrdp/xrdp.ini.in | 6 ++++++ xrdp/xrdp_mm.c | 8 ++++---- xrdp/xrdp_types.h | 2 +- 10 files changed, 49 insertions(+), 17 deletions(-) diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c index 8df34b34..7805a0c3 100644 --- a/sesman/libscp/libscp_session.c +++ b/sesman/libscp/libscp_session.c @@ -63,6 +63,10 @@ scp_session_set_type(struct SCP_SESSION *s, tui8 type) s->type = SCP_SESSION_TYPE_XVNC; break; + case SCP_SESSION_TYPE_RESIZABLE_XVNC: + s->type = SCP_SESSION_TYPE_RESIZABLE_XVNC; + break; + case SCP_SESSION_TYPE_XRDP: s->type = SCP_SESSION_TYPE_XRDP; break; diff --git a/sesman/libscp/libscp_types.h b/sesman/libscp/libscp_types.h index 8cb9166c..a3a73924 100644 --- a/sesman/libscp/libscp_types.h +++ b/sesman/libscp/libscp_types.h @@ -38,15 +38,16 @@ #define SCP_RESOURCE_SHARING_REQUEST_YES 0x01 #define SCP_RESOURCE_SHARING_REQUEST_NO 0x00 -#define SCP_SESSION_TYPE_XVNC 0x00 -#define SCP_SESSION_TYPE_XRDP 0x01 -#define SCP_SESSION_TYPE_MANAGE 0x02 -#define SCP_SESSION_TYPE_XORG 0x03 +#define SCP_SESSION_TYPE_XVNC 0x00 +#define SCP_SESSION_TYPE_XRDP 0x01 +#define SCP_SESSION_TYPE_MANAGE 0x02 +#define SCP_SESSION_TYPE_XORG 0x03 /* SCP_GW_AUTHENTICATION can be used when XRDP + sesman act as a gateway * XRDP sends this command to let sesman verify if the user is allowed * to use the gateway */ -#define SCP_GW_AUTHENTICATION 0x04 +#define SCP_GW_AUTHENTICATION 0x04 +#define SCP_SESSION_TYPE_RESIZABLE_XVNC 0x05 #define SCP_ADDRESS_TYPE_IPV4 0x00 #define SCP_ADDRESS_TYPE_IPV6 0x01 diff --git a/sesman/libscp/libscp_v0.c b/sesman/libscp/libscp_v0.c index 61bf4fda..a3bc6efc 100644 --- a/sesman/libscp/libscp_v0.c +++ b/sesman/libscp/libscp_v0.c @@ -56,6 +56,10 @@ scp_v0c_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s) { out_uint16_be(c->out_s, 0); } + else if (s->type == SCP_SESSION_TYPE_RESIZABLE_XVNC) + { + out_uint16_be(c->out_s, 1); + } else if (s->type == SCP_SESSION_TYPE_XRDP) { out_uint16_be(c->out_s, 10); @@ -199,7 +203,7 @@ scp_v0s_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s, int skipVchk) in_uint16_be(c->in_s, code); - if (code == 0 || code == 10 || code == 20) + if (code == 0 || code == 1 || code == 10 || code == 20) { session = scp_session_create(); @@ -215,6 +219,10 @@ scp_v0s_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s, int skipVchk) { scp_session_set_type(session, SCP_SESSION_TYPE_XVNC); } + else if (code == 1) + { + scp_session_set_type(session, SCP_SESSION_TYPE_RESIZABLE_XVNC); + } else if (code == 10) { scp_session_set_type(session, SCP_SESSION_TYPE_XRDP); diff --git a/sesman/scp_v0.c b/sesman/scp_v0.c index cc3712cc..d1d3067c 100644 --- a/sesman/scp_v0.c +++ b/sesman/scp_v0.c @@ -120,7 +120,8 @@ scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) "username %s", s->username); } - if (SCP_SESSION_TYPE_XVNC == s->type) + if (SCP_SESSION_TYPE_XVNC == s->type || + SCP_SESSION_TYPE_RESIZABLE_XVNC == s->type) { log_message( LOG_LEVEL_INFO, "starting Xvnc session..."); display = session_start(data, SESMAN_SESSION_TYPE_XVNC, c, s); diff --git a/sesman/scp_v1.c b/sesman/scp_v1.c index 60f82112..ccceabbd 100644 --- a/sesman/scp_v1.c +++ b/sesman/scp_v1.c @@ -124,7 +124,8 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) log_message(LOG_LEVEL_INFO, "++ created session (access granted): username %s", s->username); } - if (SCP_SESSION_TYPE_XVNC == s->type) + if (SCP_SESSION_TYPE_XVNC == s->type || + SCP_SESSION_TYPE_RESIZABLE_XVNC == s->type) { log_message(LOG_LEVEL_INFO, "starting Xvnc session..."); display = session_start(data, SESMAN_SESSION_TYPE_XVNC, c, s); diff --git a/sesman/session.c b/sesman/session.c index 9fab0392..200be9c3 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -105,10 +105,13 @@ session_get_bydata(const char *name, int width, int height, int bpp, int type, { case SCP_SESSION_TYPE_XVNC: /* 0 */ type = SESMAN_SESSION_TYPE_XVNC; /* 2 */ - /* Xvnc cannot resize */ + /* standard Xvnc can never resize */ policy = (enum SESMAN_CFG_SESS_POLICY) (policy | SESMAN_CFG_SESS_POLICY_D); break; + case SCP_SESSION_TYPE_RESIZABLE_XVNC: + type = SESMAN_SESSION_TYPE_XVNC; + break; case SCP_SESSION_TYPE_XRDP: /* 1 */ type = SESMAN_SESSION_TYPE_XRDP; /* 1 */ break; diff --git a/sesman/tools/sesrun.c b/sesman/tools/sesrun.c index 57335dd1..fd9ca567 100644 --- a/sesman/tools/sesrun.c +++ b/sesman/tools/sesrun.c @@ -31,6 +31,10 @@ #include "sesman.h" #include "tcp.h" +#if !defined(PACKAGE_VERSION) +#define PACKAGE_VERSION "???" +#endif + struct config_sesman g_cfg; /* config.h */ /******************************************************************************/ @@ -61,10 +65,14 @@ main(int argc, char **argv) if (argc == 1) { - g_printf("xrdp session starter v0.1\n"); + g_printf("xrdp session starter v" PACKAGE_VERSION "\n"); g_printf("\nusage:\n"); - g_printf("sesrun \n"); - g_printf("session code 0 for Xvnc, 10 for X11RDP, 20 for Xorg\n"); + g_printf("sesrun \n"); + g_printf("session code:-\n"); + g_printf(" - 0 for fixed Xvnc\n"); + g_printf(" - 1 for resizeable Xvnc\n"); + g_printf(" - 10 for X11RDP\n"); + g_printf(" - 20 for Xorg\n"); } else if (argc == 8) { diff --git a/xrdp/xrdp.ini.in b/xrdp/xrdp.ini.in index bba2624e..5042952a 100644 --- a/xrdp/xrdp.ini.in +++ b/xrdp/xrdp.ini.in @@ -171,6 +171,12 @@ ip=127.0.0.1 port=-1 #xserverbpp=24 #delay_ms=2000 +; If your Xvnc server supports the ExtendedDesktopSize encoding, you can +; uncomment the following line for resizeable session support. This includes +; support for multiple monitors. +; Unlike traditional VNC sessions, you can connect to (and resize) active +; VNC sessions on the same machine which have different sizes. +#code=1 [vnc-any] name=vnc-any diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 96c6945c..77d498e4 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -197,7 +197,7 @@ xrdp_mm_send_login(struct xrdp_mm *self) } else if (g_strcasecmp(name, "code") == 0) { - /* this code is either 0 for Xvnc, 10 for X11rdp or 20 for Xorg */ + /* this code is either 0/1 for Xvnc, 10 for X11rdp or 20 for Xorg */ self->code = g_atoi(value); } else if (g_strcasecmp(name, "xserverbpp") == 0) @@ -215,7 +215,7 @@ xrdp_mm_send_login(struct xrdp_mm *self) s = trans_get_out_s(self->sesman_trans, 8192); s_push_layer(s, channel_hdr, 8); - /* this code is either 0 for Xvnc, 10 for X11rdp or 20 for Xorg */ + /* this code is either 0/1 for Xvnc, 10 for X11rdp or 20 for Xorg */ out_uint16_be(s, self->code); index = g_strlen(username); out_uint16_be(s, index); @@ -515,7 +515,7 @@ xrdp_mm_setup_mod2(struct xrdp_mm *self, tui8 *guid) { if (self->display > 0) { - if (self->code == 0) /* Xvnc */ + if (self->code == 0 || self->code == 1) /* Xvnc */ { g_snprintf(text, 255, "%d", 5900 + self->display); } @@ -1903,7 +1903,7 @@ cleanup_states(struct xrdp_mm *self) self-> sesman_trans_up = 0; /* true once connected to sesman */ self-> delete_sesman_trans = 0; /* boolean set when done with sesman connection */ self-> display = 0; /* 10 for :10.0, 11 for :11.0, etc */ - self-> code = 0; /* 0 Xvnc session, 10 X11rdp session, 20 Xorg session */ + self-> code = 0; /* 0/1 Xvnc session, 10 X11rdp session, 20 Xorg session */ self-> sesman_controlled = 0; /* true if this is a sesman session */ self-> chan_trans = NULL; /* connection to chansrv */ self-> chan_trans_up = 0; /* true once connected to chansrv */ diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index dc6db4bc..fabe3d73 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -290,7 +290,7 @@ struct xrdp_mm int (*mod_exit)(struct xrdp_mod*); struct xrdp_mod* mod; /* module interface */ int display; /* 10 for :10.0, 11 for :11.0, etc */ - int code; /* 0=Xvnc session, 10=X11rdp session, 20=xorg driver mode */ + int code; /* 0/1=Xvnc session, 10=X11rdp session, 20=xorg driver mode */ int sesman_controlled; /* true if this is a sesman session */ struct trans* chan_trans; /* connection to chansrv */ int chan_trans_up; /* true once connected to chansrv */