From 6783803c59f438afd2ad191bbc28a288d260dff2 Mon Sep 17 00:00:00 2001 From: Nexarian Date: Sat, 4 Feb 2023 23:50:48 -0500 Subject: [PATCH] Working on aup screen --- xrdp/xrdp_login_wnd.c | 31 +++++++++++++++++++++- xrdp/xrdp_types.h | 61 ++++++++++++++++++++++++++----------------- 2 files changed, 67 insertions(+), 25 deletions(-) diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c index a97467abbb..8336ae1e93 100644 --- a/xrdp/xrdp_login_wnd.c +++ b/xrdp/xrdp_login_wnd.c @@ -828,7 +828,6 @@ xrdp_login_wnd_create(struct xrdp_wm *self) self->login_window->left = primary_x_offset - self->login_window->width / 2; self->login_window->top = primary_y_offset - self->login_window->height / 2; - self->login_window->notify = xrdp_wm_login_notify; /* if window title not specified, use hostname as default */ @@ -951,6 +950,17 @@ xrdp_login_wnd_create(struct xrdp_wm *self) but->top = globals->ls_scaled.input_y_pos; set_string(&but->caption1, "Session"); + /* Acceptable Use Policy */ + but = xrdp_bitmap_create(globals->ls_scaled.acceptable_use_width, globals->ls_scaled.acceptable_use_height, + self->screen->bpp, WND_TYPE_LABEL, self); + list_add_item(self->login_window->child_list, (long)but); + but->parent = self->login_window; + but->owner = self->login_window; + but->left = globals->ls_scaled.acceptable_use_x_pos; + but->top = globals->ls_scaled.acceptable_use_y_pos; + //set_string(&but->caption1, globals->ls_acceptable_use_policy_filename); + set_string(&but->caption1, "This is a test of adding an acceptable use policy to the login screen"); + /* combo */ combo = xrdp_bitmap_create(globals->ls_scaled.input_width, combo_height, self->screen->bpp, WND_TYPE_COMBO, self); @@ -1084,6 +1094,10 @@ load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp) globals->ls_unscaled.logo_y_pos = 50; globals->ls_unscaled.label_x_pos = 30; globals->ls_unscaled.label_width = 65; + globals->ls_unscaled.acceptable_use_x_pos = 30; /* acceptable use x co-ordinate */ + globals->ls_unscaled.acceptable_use_y_pos = 240; /* acceptable use y co-ordinate */ + globals->ls_unscaled.acceptable_use_height = 50; /* height of the acceptable use policy */ + globals->ls_unscaled.acceptable_use_width = 250; /* width of the acceptable use policy */ globals->ls_unscaled.input_x_pos = 110; globals->ls_unscaled.input_width = 210; globals->ls_unscaled.input_y_pos = 150; @@ -1331,6 +1345,12 @@ load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp) globals->ls_bg_color = HCOLOR(bpp, xrdp_wm_htoi(v)); } + else if (g_strncmp(n, "ls_acceptable_use_policy_filename", 255) == 0) + { + g_strncpy(globals->ls_acceptable_use_policy_filename, v, 255); + globals->ls_acceptable_use_policy_filename[255] = 0; + } + else if (g_strncmp(n, "ls_title", 255) == 0) { g_strncpy(globals->ls_title, v, 255); @@ -1484,6 +1504,7 @@ load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp) LOG(LOG_LEVEL_DEBUG, "ls_width (unscaled): %d", globals->ls_unscaled.width); LOG(LOG_LEVEL_DEBUG, "ls_height (unscaled): %d", globals->ls_unscaled.height); LOG(LOG_LEVEL_DEBUG, "ls_bg_color: %x", globals->ls_bg_color); + LOG(LOG_LEVEL_DEBUG, "ls_acceptable_use_policy_filename: %s", globals->ls_acceptable_use_policy_filename); LOG(LOG_LEVEL_DEBUG, "ls_title: %s", globals->ls_title); LOG(LOG_LEVEL_DEBUG, "ls_logo_filename: %s", globals->ls_logo_filename); LOG(LOG_LEVEL_DEBUG, "ls_logo_x_pos : %d", globals->ls_unscaled.logo_x_pos); @@ -1552,6 +1573,14 @@ xrdp_login_wnd_scale_config_values(struct xrdp_wm *self) scaled->logo_y_pos = SCALE_AND_ROUND(unscaled->logo_y_pos); scaled->label_x_pos = SCALE_AND_ROUND(unscaled->label_x_pos); scaled->label_width = SCALE_AND_ROUND(unscaled->label_width); + scaled->acceptable_use_x_pos + = SCALE_AND_ROUND(unscaled->acceptable_use_x_pos); + scaled->acceptable_use_y_pos + = SCALE_AND_ROUND(unscaled->acceptable_use_y_pos); + scaled->acceptable_use_height + = SCALE_AND_ROUND(unscaled->acceptable_use_height); + scaled->acceptable_use_width + = SCALE_AND_ROUND(unscaled->acceptable_use_width); scaled->input_x_pos = SCALE_AND_ROUND(unscaled->input_x_pos); scaled->input_width = SCALE_AND_ROUND(unscaled->input_width); scaled->input_y_pos = SCALE_AND_ROUND(unscaled->input_y_pos); diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index 3cc19232d4..bef32e1ba9 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -687,30 +687,34 @@ struct xrdp_startup_params struct xrdp_ls_dimensions { - int width; /* window width */ - int height; /* window height */ - int logo_width; /* logo width (optional) */ - int logo_height; /* logo height (optional) */ - int logo_x_pos; /* logo x co-ordinate */ - int logo_y_pos; /* logo y co-ordinate */ - int label_x_pos; /* x pos of labels */ - int label_width; /* width of labels */ - int input_x_pos; /* x pos of text and combo boxes */ - int input_width; /* width of input and combo boxes */ - int input_y_pos; /* y pos for for first label and combo box */ - int btn_ok_x_pos; /* x pos for OK button */ - int btn_ok_y_pos; /* y pos for OK button */ - int btn_ok_width; /* width of OK button */ - int btn_ok_height; /* height of OK button */ - int btn_cancel_x_pos; /* x pos for Cancel button */ - int btn_cancel_y_pos; /* y pos for Cancel button */ - int btn_cancel_width; /* width of Cancel button */ - int btn_cancel_height; /* height of Cancel button */ - int default_btn_height; /* Default button height (e.g. OK on login box) */ - int log_wnd_width; /* Width of log window */ - int log_wnd_height; /* Height of log window */ - int edit_height; /* Height of an edit box */ - int combo_height; /* Height of a combo box */ + int width; /* window width */ + int height; /* window height */ + int logo_width; /* logo width (optional) */ + int logo_height; /* logo height (optional) */ + int logo_x_pos; /* logo x co-ordinate */ + int logo_y_pos; /* logo y co-ordinate */ + int label_x_pos; /* x pos of labels */ + int label_width; /* width of labels */ + int acceptable_use_x_pos; /* acceptable use x co-ordinate */ + int acceptable_use_y_pos; /* acceptable use y co-ordinate */ + int acceptable_use_height; /* height of the acceptable use policy */ + int acceptable_use_width; /* width of the acceptable use policy */ + int input_x_pos; /* x pos of text and combo boxes */ + int input_width; /* width of input and combo boxes */ + int input_y_pos; /* y pos for for first label and combo box */ + int btn_ok_x_pos; /* x pos for OK button */ + int btn_ok_y_pos; /* y pos for OK button */ + int btn_ok_width; /* width of OK button */ + int btn_ok_height; /* height of OK button */ + int btn_cancel_x_pos; /* x pos for Cancel button */ + int btn_cancel_y_pos; /* y pos for Cancel button */ + int btn_cancel_width; /* width of Cancel button */ + int btn_cancel_height; /* height of Cancel button */ + int default_btn_height; /* Default button height (e.g. OK on login box) */ + int log_wnd_width; /* Width of log window */ + int log_wnd_height; /* Height of log window */ + int edit_height; /* Height of an edit box */ + int combo_height; /* Height of a combo box */ int help_wnd_width; /* Width of login help window */ int help_wnd_height; /* Height of login help window */ }; @@ -756,6 +760,15 @@ struct xrdp_cfg_globals int ls_top_window_bg_color; /* top level window background color */ int ls_bg_color; /* background color */ char ls_background_image[256]; /* background image file name */ + /* + filename for acceptable use policy for use in enterprise environments + users are required to view this policy on every login. + setting this will implicity disable autologin. + + If the file is not found, no sessions will be created. + https://github.com/neutrinolabs/xrdp/issues/547 + */ + char ls_acceptable_use_policy_filename[256]; /* transform to apply to background image */ enum xrdp_bitmap_load_transform ls_background_transform; char ls_logo_filename[256]; /* logo filename */