From 104304aad1cabd03b989aeab7bc7848fbb9303d8 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Fri, 25 Mar 2022 13:29:44 +0000 Subject: [PATCH] Open log in sesman before reading config --- sesman/sesman.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/sesman/sesman.c b/sesman/sesman.c index 54a2267e..b5c78f4c 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -674,21 +674,13 @@ main(int argc, char **argv) g_exit(1); } - /* reading config */ - if ((g_cfg = config_read(startup_params.sesman_ini)) == NULL) + /* starting logging subsystem */ + if (!g_file_exist(startup_params.sesman_ini)) { - g_printf("error reading config %s: %s\nquitting.\n", - startup_params.sesman_ini, g_get_strerror()); + g_printf("Config file %s does not exist\n", startup_params.sesman_ini); g_deinit(); g_exit(1); } - - if (startup_params.dump_config) - { - config_dump(g_cfg); - } - - /* starting logging subsystem */ log_error = log_start( startup_params.sesman_ini, "xrdp-sesman", (startup_params.dump_config) ? LOG_START_DUMP_CONFIG : 0); @@ -705,15 +697,29 @@ main(int argc, char **argv) getLogFile(text, 255)); break; default: - g_writeln("error"); + // Assume sufficient messages have already been generated break; } - config_free(g_cfg); g_deinit(); g_exit(1); } + /* reading config */ + if ((g_cfg = config_read(startup_params.sesman_ini)) == NULL) + { + LOG(LOG_LEVEL_ALWAYS, "error reading config %s: %s", + startup_params.sesman_ini, g_get_strerror()); + log_end(); + g_deinit(); + g_exit(1); + } + + if (startup_params.dump_config) + { + config_dump(g_cfg); + } + LOG(LOG_LEVEL_TRACE, "config loaded in %s at %s:%d", __func__, __FILE__, __LINE__); LOG(LOG_LEVEL_TRACE, " sesman_ini = %s", g_cfg->sesman_ini); LOG(LOG_LEVEL_TRACE, " listen_address = %s", g_cfg->listen_address);