From 099a421c7706ea5d7706890d7a3f12a4ccf7c126 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sun, 10 Jun 2012 21:50:57 -0700 Subject: [PATCH] log: added path for when --prefix is used --- common/Makefile.am | 3 ++- common/log.c | 17 ++++++++++++++++- sesman/sesman.c | 9 ++++----- sesman/sesman.ini | 2 +- xrdp/xrdp.c | 7 ++++--- xrdp/xrdp.ini | 2 +- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/common/Makefile.am b/common/Makefile.am index 1bc5eeb6..33cfc1e5 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -5,7 +5,8 @@ AM_CFLAGS = \ -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \ -DXRDP_SBIN_PATH=\"${sbindir}\" \ -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \ - -DXRDP_PID_PATH=\"${localstatedir}/run\" + -DXRDP_PID_PATH=\"${localstatedir}/run\" \ + -DXRDP_LOG_PATH=\"${localstatedir}/log\" lib_LTLIBRARIES = \ libcommon.la diff --git a/common/log.c b/common/log.c index cdf250ea..390b2bff 100644 --- a/common/log.c +++ b/common/log.c @@ -313,6 +313,7 @@ internal_config_read_logging(int file, struct log_config* lc, { int i; char* buf; + char* temp_buf; list_clear(param_v); list_clear(param_n); @@ -332,6 +333,16 @@ internal_config_read_logging(int file, struct log_config* lc, if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_FILE)) { lc->log_file = g_strdup((char*)list_get_item(param_v, i)); + if (lc->log_file != NULL) + { + if (lc->log_file[0] != '/') + { + temp_buf = (char*)g_malloc(512, 0); + g_snprintf(temp_buf, 511, "%s/%s", XRDP_LOG_PATH, lc->log_file); + g_free(lc->log_file); + lc->log_file = temp_buf; + } + } } if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_LEVEL)) { @@ -352,6 +363,9 @@ internal_config_read_logging(int file, struct log_config* lc, lc->log_file = g_strdup("./sesman.log"); } + /* try to create path if not exist */ + g_create_path(lc->log_file); + g_printf("logging configuration:\r\n"); g_printf("\tLogFile: %s\r\n", lc->log_file); g_printf("\tLogLevel: %i\r\n", lc->log_level); @@ -423,7 +437,8 @@ log_start_from_param(const struct log_config* iniParams) ret = internalInitAndAllocStruct(); if (ret != LOG_STARTUP_OK) { - return ret; + g_writeln("internalInitAndAllocStruct failed"); + return ret; } staticLogConfig->enable_syslog = iniParams->enable_syslog; staticLogConfig->fd = iniParams->fd; diff --git a/sesman/sesman.c b/sesman/sesman.c index 1d60626c..b882c49d 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -252,20 +252,20 @@ main(int argc, char** argv) } g_snprintf(cfg_file,255,"%s/sesman.ini",XRDP_CFG_PATH); - + /* starting logging subsystem */ error = log_start(cfg_file,"XRDP-sesman"); if (error != LOG_STARTUP_OK) { - char buf[256] ; switch (error) { case LOG_ERROR_MALLOC: - g_printf("error on malloc. cannot start logging. quitting.\n"); + g_writeln("error on malloc. cannot start logging. quitting."); break; case LOG_ERROR_FILE_OPEN: - g_printf("error opening log file [%s]. quitting.\n", getLogFile(buf,255)); + g_writeln("error opening log file [%s]. quitting.", + getLogFile(text, 255)); break; } g_deinit(); @@ -368,4 +368,3 @@ main(int argc, char** argv) g_deinit(); return 0; } - diff --git a/sesman/sesman.ini b/sesman/sesman.ini index 88252a18..f2a210a4 100644 --- a/sesman/sesman.ini +++ b/sesman/sesman.ini @@ -19,7 +19,7 @@ IdleTimeLimit=0 DisconnectedTimeLimit=0 [Logging] -LogFile=/var/log/xrdp-sesman.log +LogFile=xrdp-sesman.log LogLevel=DEBUG EnableSyslog=1 SyslogLevel=DEBUG diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index 83d2f0a2..ac20fd72 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -314,16 +314,17 @@ main(int argc, char** argv) if (error != LOG_STARTUP_OK) { - char buf[256] ; switch (error) { case LOG_ERROR_MALLOC: - g_printf("error on malloc. cannot start logging. quitting.\n"); + g_writeln("error on malloc. cannot start logging. quitting."); break; case LOG_ERROR_FILE_OPEN: - g_printf("error opening log file [%s]. quitting.\n", getLogFile(buf,255)); + g_writeln("error opening log file [%s]. quitting.", + getLogFile(text, 255)); break; } + g_deinit(); g_exit(1); } diff --git a/xrdp/xrdp.ini b/xrdp/xrdp.ini index 115d2708..7cab7000 100644 --- a/xrdp/xrdp.ini +++ b/xrdp/xrdp.ini @@ -20,7 +20,7 @@ fork=yes #hidelogwindow=yes [Logging] -LogFile=/var/log/xrdp.log +LogFile=xrdp.log LogLevel=DEBUG EnableSyslog=1 SyslogLevel=DEBUG