nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 372 lines 15 kB view raw
1diff --git a/common/xrdp_client_info.h b/common/xrdp_client_info.h 2index f45195e8..b87ae64e 100644 3--- a/common/xrdp_client_info.h 4+++ b/common/xrdp_client_info.h 5@@ -148,6 +148,9 @@ struct xrdp_client_info 6 7 char certificate[1024]; 8 char key_file[1024]; 9+ char rsakeys_ini_file[256]; 10+ char xrdp_keyboard_ini_file[256]; 11+ char keymaps_path[256]; 12 13 /* X11 keyboard layout - inferred from keyboard type/subtype */ 14 char model[16]; 15diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c 16index d08f068a..cc7a173d 100644 17--- a/libxrdp/xrdp_rdp.c 18+++ b/libxrdp/xrdp_rdp.c 19@@ -27,6 +27,7 @@ 20 #include "log.h" 21 #include "ssl_calls.h" 22 #include "string_calls.h" 23+#include <string.h> 24 25 #if defined(XRDP_NEUTRINORDP) 26 #include <freerdp/codec/rfx.h> 27@@ -46,10 +47,21 @@ xrdp_rdp_read_config(const char *xrdp_ini, struct xrdp_client_info *client_info) 28 struct list *values = (struct list *)NULL; 29 char *item = NULL; 30 char *value = NULL; 31+ char cfg_dir[256]; 32 int pos; 33 char *tmp = NULL; 34 int tmp_length = 0; 35 36+ g_strncpy(cfg_dir, xrdp_ini, 255); 37+ *(strrchr(cfg_dir, '/')) = 0; 38+ 39+ /* default location is next to xrdp.ini */ 40+ g_snprintf(client_info->certificate, 1023, "%s/cert.pem", cfg_dir); 41+ g_snprintf(client_info->key_file, 1023, "%s/key.pem", cfg_dir); 42+ g_snprintf(client_info->xrdp_keyboard_ini_file, 255, "%s/xrdp_keyboard.ini", cfg_dir); 43+ g_snprintf(client_info->rsakeys_ini_file, 255, "%s/rsakeys.ini", cfg_dir); 44+ g_snprintf(client_info->keymaps_path, 255, "%s", cfg_dir); 45+ 46 client_info->xrdp_keyboard_overrides.type = -1; 47 client_info->xrdp_keyboard_overrides.subtype = -1; 48 client_info->xrdp_keyboard_overrides.layout = -1; 49@@ -253,14 +265,14 @@ xrdp_rdp_read_config(const char *xrdp_ini, struct xrdp_client_info *client_info) 50 if (g_strlen(value) == 0) 51 { 52 /* default key_file path */ 53- g_snprintf(client_info->key_file, 1023, "%s/key.pem", XRDP_CFG_PATH); 54+ g_snprintf(client_info->key_file, 1023, "%s/key.pem", cfg_dir); 55 LOG(LOG_LEVEL_INFO, "Using default X.509 key file: %s", 56 client_info->key_file); 57 } 58 else if (value[0] != '/') 59 { 60 /* default key_file path */ 61- g_snprintf(client_info->key_file, 1023, "%s/key.pem", XRDP_CFG_PATH); 62+ g_snprintf(client_info->key_file, 1023, "%s/key.pem", cfg_dir); 63 LOG(LOG_LEVEL_WARNING, 64 "X.509 key file should use absolute path, using " 65 "default instead: %s", client_info->key_file); 66@@ -277,6 +289,51 @@ xrdp_rdp_read_config(const char *xrdp_ini, struct xrdp_client_info *client_info) 67 client_info->key_file, g_get_strerror()); 68 } 69 } 70+ else if (g_strcasecmp(item, "rsakeys_ini") == 0) 71+ { 72+ if (value[0] != '/') 73+ { 74+ g_snprintf(client_info->rsakeys_ini_file, 255, "%s/rsakeys.ini", cfg_dir); 75+ log_message(LOG_LEVEL_WARNING, 76+ "rsakeys.ini file should use absolute path, using " 77+ "default instead: %s", client_info->rsakeys_ini_file); 78+ } 79+ else 80+ { 81+ /* use user defined rsakeys.ini */ 82+ g_strncpy(client_info->rsakeys_ini_file, value, 255); 83+ } 84+ } 85+ else if (g_strcasecmp(item, "xrdp_keyboard_ini") == 0) 86+ { 87+ if (value[0] != '/') 88+ { 89+ g_snprintf(client_info->xrdp_keyboard_ini_file, 255, "%s/xrdp_keyboard.ini", cfg_dir); 90+ log_message(LOG_LEVEL_WARNING, 91+ "xrdp_keyboard.ini file should use absolute path, using " 92+ "default instead: %s", client_info->xrdp_keyboard_ini_file); 93+ } 94+ else 95+ { 96+ /* use user defined xrdp_keyboard.ini */ 97+ g_strncpy(client_info->xrdp_keyboard_ini_file, value, 255); 98+ } 99+ } 100+ else if (g_strcasecmp(item, "keymaps_path") == 0) 101+ { 102+ if (value[0] != '/') 103+ { 104+ g_snprintf(client_info->keymaps_path, 255, "%s", cfg_dir); 105+ log_message(LOG_LEVEL_WARNING, 106+ "keymaps_path should use absolute path, using " 107+ "default instead: %s", client_info->keymaps_path); 108+ } 109+ else 110+ { 111+ /* use user defined xrdp_keyboard.ini */ 112+ g_strncpy(client_info->keymaps_path, value, 255); 113+ } 114+ } 115 else if (g_strcasecmp(item, "domain_user_separator") == 0 116 && g_strlen(value) > 0) 117 { 118diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c 119index 8fa34aea..da94cf95 100644 120--- a/libxrdp/xrdp_sec.c 121+++ b/libxrdp/xrdp_sec.c 122@@ -371,7 +371,6 @@ xrdp_load_keyboard_layout(struct xrdp_client_info *client_info) 123 char *item = (char *)NULL; 124 char *value = (char *)NULL; 125 char *q = (char *)NULL; 126- char keyboard_cfg_file[256] = { 0 }; 127 char rdp_layout[256] = { 0 }; 128 129 const struct xrdp_keyboard_overrides *ko = 130@@ -419,10 +418,9 @@ xrdp_load_keyboard_layout(struct xrdp_client_info *client_info) 131 client_info->keyboard_subtype = 1; 132 } 133 134- g_snprintf(keyboard_cfg_file, 255, "%s/xrdp_keyboard.ini", XRDP_CFG_PATH); 135- LOG(LOG_LEVEL_DEBUG, "keyboard_cfg_file %s", keyboard_cfg_file); 136+ LOG(LOG_LEVEL_DEBUG, "keyboard_cfg_file %s", client_info->xrdp_keyboard_ini_file); 137 138- fd = g_file_open_ro(keyboard_cfg_file); 139+ fd = g_file_open_ro(client_info->xrdp_keyboard_ini_file); 140 141 if (fd >= 0) 142 { 143@@ -594,7 +592,7 @@ xrdp_load_keyboard_layout(struct xrdp_client_info *client_info) 144 else 145 { 146 LOG(LOG_LEVEL_ERROR, "xrdp_load_keyboard_layout: error opening %s", 147- keyboard_cfg_file); 148+ client_info->xrdp_keyboard_ini_file); 149 } 150 } 151 152@@ -2759,7 +2757,6 @@ xrdp_sec_incoming(struct xrdp_sec *self) 153 int index = 0; 154 char *item = NULL; 155 char *value = NULL; 156- char key_file[256]; 157 158 iso = self->mcs_layer->iso_layer; 159 160@@ -2805,19 +2802,17 @@ xrdp_sec_incoming(struct xrdp_sec *self) 161 LOG(LOG_LEVEL_DEBUG, "Using RDP security, and " 162 "reading the server configuration"); 163 164- g_memset(key_file, 0, sizeof(char) * 256); 165 g_random(self->server_random, 32); 166 items = list_create(); 167 items->auto_free = 1; 168 values = list_create(); 169 values->auto_free = 1; 170- g_snprintf(key_file, 255, "%s/rsakeys.ini", XRDP_CFG_PATH); 171 172- if (file_by_name_read_section(key_file, "keys", items, values) != 0) 173+ if (file_by_name_read_section(self->rdp_layer->client_info.rsakeys_ini_file, "keys", items, values) != 0) 174 { 175 /* this is a show stopper */ 176 LOG(LOG_LEVEL_ERROR, "XRDP cannot read file: %s " 177- "(check permissions)", key_file); 178+ "(check permissions)", self->rdp_layer->client_info.rsakeys_ini_file); 179 list_delete(items); 180 list_delete(values); 181 return 1; 182diff --git a/sesman/libsesman/sesman_config.c b/sesman/libsesman/sesman_config.c 183index 61e9e403..0466f61a 100644 184--- a/sesman/libsesman/sesman_config.c 185+++ b/sesman/libsesman/sesman_config.c 186@@ -37,6 +37,7 @@ 187 #include "log.h" 188 #include "os_calls.h" 189 #include "string_calls.h" 190+#include <string.h> 191 //#include "chansrv/chansrv_common.h" 192 #include "scp.h" 193 194@@ -171,7 +172,7 @@ config_output_policy_string(unsigned int value, 195 * 196 */ 197 static int 198-config_read_globals(int file, struct config_sesman *cf, struct list *param_n, 199+config_read_globals(const char *base_dir, int file, struct config_sesman *cf, struct list *param_n, 200 struct list *param_v) 201 { 202 int i; 203@@ -249,14 +250,12 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n, 204 cf->default_wm = g_strdup("startwm.sh"); 205 } 206 /* if default_wm doesn't begin with '/', it's a relative path to 207- * XRDP_CFG_PATH */ 208+ * base_dir */ 209 if (cf->default_wm[0] != '/') 210 { 211 /* sizeof operator returns string length including null terminator */ 212- int length = (sizeof(XRDP_CFG_PATH) + 213- g_strlen(cf->default_wm) + 1); /* '/' */ 214- char *buf = (char *)g_malloc(length, 0); 215- g_sprintf(buf, "%s/%s", XRDP_CFG_PATH, cf->default_wm); 216+ char *buf = (char *)g_malloc(g_strlen(base_dir) + 1 + g_strlen(cf->default_wm) + 1, 0); 217+ g_sprintf(buf, "%s/%s", base_dir, cf->default_wm); 218 g_free(cf->default_wm); 219 cf->default_wm = buf; 220 } 221@@ -271,10 +270,8 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n, 222 if (cf->reconnect_sh[0] != '/') 223 { 224 /* sizeof operator returns string length including null terminator */ 225- int length = (sizeof(XRDP_CFG_PATH) + 226- g_strlen(cf->reconnect_sh) + 1); /* '/' */ 227- char *buf = (char *)g_malloc(length, 0); 228- g_sprintf(buf, "%s/%s", XRDP_CFG_PATH, cf->reconnect_sh); 229+ char *buf = (char *)g_malloc(g_strlen(base_dir) + 1 + g_strlen(cf->reconnect_sh) + 1, 0); 230+ g_sprintf(buf, "%s/%s", base_dir, cf->reconnect_sh); 231 g_free(cf->reconnect_sh); 232 cf->reconnect_sh = buf; 233 } 234@@ -580,6 +577,7 @@ struct config_sesman * 235 config_read(const char *sesman_ini) 236 { 237 struct config_sesman *cfg; 238+ char cfg_dir[256]; 239 int all_ok = 0; 240 241 if ((cfg = g_new0(struct config_sesman, 1)) != NULL) 242@@ -602,7 +600,10 @@ config_read(const char *sesman_ini) 243 all_ok = 1; 244 245 /* read global config */ 246- config_read_globals(fd, cfg, param_n, param_v); 247+ g_strcpy(cfg_dir, sesman_ini); 248+ *(strrchr(cfg_dir, '/')) = 0; // cfg_file validated to contain '/' 249+ 250+ config_read_globals(cfg_dir, fd, cfg, param_n, param_v); 251 252 /* read Xvnc/Xorg parameter list */ 253 config_read_vnc_params(fd, cfg, param_n, param_v); 254diff --git a/xrdp/lang.c b/xrdp/lang.c 255index e4c18077..06f92997 100644 256--- a/xrdp/lang.c 257+++ b/xrdp/lang.c 258@@ -229,7 +229,7 @@ km_read_section(int fd, const char *section_name, struct xrdp_key_info *keymap) 259 260 /*****************************************************************************/ 261 int 262-get_keymaps(int keylayout, struct xrdp_keymap *keymap) 263+get_keymaps(const char* keymaps_path, int keylayout, struct xrdp_keymap *keymap) 264 { 265 int fd; 266 int basic_key_layout = keylayout & 0x0000ffff; 267@@ -239,21 +239,21 @@ get_keymaps(int keylayout, struct xrdp_keymap *keymap) 268 filename = (char *)g_malloc(256, 0); 269 270 /* check if there is a keymap file e.g. km-e00100411.ini */ 271- g_snprintf(filename, 255, "%s/km-%08x.ini", XRDP_CFG_PATH, keylayout); 272+ g_snprintf(filename, 255, "%s/km-%08x.ini", keymaps_path, keylayout); 273 274 /* if the file does not exist, use only lower 16 bits instead */ 275 if (!g_file_exist(filename)) 276 { 277 LOG(LOG_LEVEL_WARNING, "Cannot find keymap file %s", filename); 278 /* e.g. km-00000411.ini */ 279- g_snprintf(filename, 255, "%s/km-%08x.ini", XRDP_CFG_PATH, basic_key_layout); 280+ g_snprintf(filename, 255, "%s/km-%08x.ini", keymaps_path, basic_key_layout); 281 } 282 283 /* finally, use 'en-us' */ 284 if (!g_file_exist(filename)) 285 { 286 LOG(LOG_LEVEL_WARNING, "Cannot find keymap file %s", filename); 287- g_snprintf(filename, 255, "%s/km-00000409.ini", XRDP_CFG_PATH); 288+ g_snprintf(filename, 255, "%s/km-00000409.ini", keymaps_path); 289 } 290 291 if (g_file_exist(filename)) 292diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c 293index e91672fb..37cef0c0 100644 294--- a/xrdp/xrdp.c 295+++ b/xrdp/xrdp.c 296@@ -384,7 +384,6 @@ xrdp_sanity_check(void) 297 { 298 int intval = 1; 299 int host_be; 300- const char *key_file = XRDP_CFG_PATH "/rsakeys.ini"; 301 302 /* check compiled endian with actual endian */ 303 host_be = !((int)(*(unsigned char *)(&intval))); 304@@ -429,12 +428,6 @@ xrdp_sanity_check(void) 305 return 1; 306 } 307 308- if (!g_file_exist(key_file)) 309- { 310- g_writeln("File %s is missing, create it using xrdp-keygen", key_file); 311- return 1; 312- } 313- 314 return 0; 315 } 316 317diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h 318index 36d8f87a..687b9dd5 100644 319--- a/xrdp/xrdp.h 320+++ b/xrdp/xrdp.h 321@@ -380,7 +380,7 @@ get_char_from_scan_code(int device_flags, int scan_code, int *keys, 322 int caps_lock, int num_lock, int scroll_lock, 323 struct xrdp_keymap *keymap); 324 int 325-get_keymaps(int keylayout, struct xrdp_keymap *keymap); 326+get_keymaps(const char* keymaps_path, int keylayout, struct xrdp_keymap *keymap); 327 328 /* xrdp_login_wnd.c */ 329 int 330diff --git a/xrdp/xrdp.ini.in b/xrdp/xrdp.ini.in 331index 3b6340f8..c05e2930 100644 332--- a/xrdp/xrdp.ini.in 333+++ b/xrdp/xrdp.ini.in 334@@ -52,6 +52,12 @@ crypt_level=high 335 ; openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 365 336 certificate= 337 key_file= 338+;directory with km-*.ini files; default is the directory of xrdp.ini 339+#keymaps_path= 340+;location of xrdp_keyboard_ini; default next to xrdp.ini 341+#xrdp_keyboard_ini= 342+;location of rsakeys.ini; default next to xrdp.ini 343+#rsakeys_ini= 344 345 ; set SSL protocols 346 ; can be comma separated list of 'SSLv3', 'TLSv1', 'TLSv1.1', 'TLSv1.2', 'TLSv1.3' 347diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c 348index 94691582..602b3ca6 100644 349--- a/xrdp/xrdp_wm.c 350+++ b/xrdp/xrdp_wm.c 351@@ -64,7 +64,7 @@ xrdp_wm_create(struct xrdp_process *owner, 352 self->mm = xrdp_mm_create(self); 353 self->default_font = xrdp_font_create(self); 354 /* this will use built in keymap or load from file */ 355- get_keymaps(self->session->client_info->keylayout, &(self->keymap)); 356+ get_keymaps(client_info->keymaps_path, self->session->client_info->keylayout, &(self->keymap)); 357 xrdp_wm_set_login_state(self, WMLS_RESET); 358 self->target_surface = self->screen; 359 self->current_surface_index = 0xffff; /* screen */ 360diff --git a/xup/xup.c b/xup/xup.c 361index e67d9477..8bc718a0 100644 362--- a/xup/xup.c 363+++ b/xup/xup.c 364@@ -318,7 +318,7 @@ lib_mod_event(struct mod *mod, int msg, tbus param1, tbus param2, 365 msg param1 param2 param3 param4 366 15 0 65507 29 0 367 16 0 65507 29 49152 */ 368- init_stream(s, 8192); 369+ init_stream(s, (int)sizeof(mod->client_info) < 8192 ? 8192 : (int)sizeof(mod->client_info)); 370 s_push_layer(s, iso_hdr, 4); 371 out_uint16_le(s, 103); 372 out_uint32_le(s, 16); /* key up */