From 5ff8aee291040993eef6f6364d718689f55d0c70 Mon Sep 17 00:00:00 2001 From: speidy Date: Fri, 11 Apr 2014 02:24:17 +0300 Subject: [PATCH] xrdp: for proxy modules, pass target ip to module (if ip passed-in from client into domain field (starting with _)) --- xrdp/xrdp_login_wnd.c | 4 ++-- xrdp/xrdp_wm.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c index cd62c013..c3f7c2ac 100644 --- a/xrdp/xrdp_login_wnd.c +++ b/xrdp/xrdp_login_wnd.c @@ -329,8 +329,8 @@ xrdp_wm_show_edits(struct xrdp_wm *self, struct xrdp_bitmap *combo) /* If the first char in the domain name is '_' we use the domain name as IP*/ if(self->session->client_info->domain[0]=='_') { - g_strncpy(b->caption1, &self->session->client_info->domain[1], 255); - b->edit_pos = g_mbstowcs(0, b->caption1, 0); + g_strncpy(b->caption1, &self->session->client_info->domain[1], 255); + b->edit_pos = g_mbstowcs(0, b->caption1, 0); } } diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 4f010698..fb0825f3 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -540,6 +540,7 @@ xrdp_wm_init(struct xrdp_wm *self) struct list *values; char *q; char *r; + char param[256]; char section_name[256]; char cfg_file[256]; char autorun_name[256]; @@ -632,6 +633,29 @@ xrdp_wm_init(struct xrdp_wm *self) r = self->session->client_info->username; } } + else if (g_strncmp("ip", q, 255) == 0) + { + /* if the ip has been asked for by the module, use what the + client says (target ip should be in 'domain' field, when starting with "_") + if the ip has been manually set in the config, use that + instead of what the client says. */ + if (g_strncmp("ask", r, 3) == 0) + { + if (self->session->client_info->domain[0] == '_') + { + g_strncpy(param, &self->session->client_info->domain[1], 255); + r = param; + } + + } + } + else if (g_strncmp("port", q, 255) == 0) + { + if (g_strncmp("ask3389", r, 7) == 0) + { + r = "3389"; /* use default */ + } + } list_add_item(self->mm->login_names, (long)g_strdup(q)); list_add_item(self->mm->login_values, (long)g_strdup(r));