chansrv: include display number in chansrv log filename

since xrdp-chansrv may be run multiple instances per user. For example,
Xvnc backend creates one session per screen geometry.
This commit is contained in:
Koichiro IWAO 2017-07-04 17:05:00 +09:00 committed by metalefty
parent 3a27631826
commit 9065964bd9

View File

@ -1522,13 +1522,17 @@ main(int argc, char **argv)
read_ini(); read_ini();
pid = g_getpid(); pid = g_getpid();
display_text = g_getenv("DISPLAY");
if (display_text)
get_display_num_from_display(display_text);
log_level = get_log_level(g_getenv("CHANSRV_LOG_LEVEL"), LOG_LEVEL_INFO); log_level = get_log_level(g_getenv("CHANSRV_LOG_LEVEL"), LOG_LEVEL_INFO);
/* starting logging subsystem */ /* starting logging subsystem */
g_memset(&logconfig, 0, sizeof(struct log_config)); g_memset(&logconfig, 0, sizeof(struct log_config));
logconfig.program_name = "xrdp-chansrv"; logconfig.program_name = "xrdp-chansrv";
g_snprintf(log_file, 255, "%s/xrdp-chansrv.log", log_path); g_snprintf(log_file, 255, "%s/xrdp-chansrv.%d.log", log_path, g_display_num);
g_writeln("chansrv::main: using log file [%s]", log_file); g_writeln("chansrv::main: using log file [%s]", log_file);
if (g_file_exist(log_file)) if (g_file_exist(log_file))
@ -1571,12 +1575,8 @@ main(int argc, char **argv)
g_signal_child_stop(child_signal_handler); /* SIGCHLD */ g_signal_child_stop(child_signal_handler); /* SIGCHLD */
g_signal_segfault(segfault_signal_handler); g_signal_segfault(segfault_signal_handler);
display_text = g_getenv("DISPLAY");
LOGM((LOG_LEVEL_INFO, "main: DISPLAY env var set to %s", display_text)); LOGM((LOG_LEVEL_INFO, "main: DISPLAY env var set to %s", display_text));
if (display_text)
get_display_num_from_display(display_text);
if (g_display_num == 0) if (g_display_num == 0)
{ {
LOGM((LOG_LEVEL_ERROR, "main: error, display is zero")); LOGM((LOG_LEVEL_ERROR, "main: error, display is zero"));