From b1527b7947b867a8dc6dd22bda9147713c10620b Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:16 -0700 Subject: Check string format in log_message Move "printflike" definition to arch.h, it's used both by log.h and os_calls.h. --- common/log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/log.h') diff --git a/common/log.h b/common/log.h index 15307588..6654028b 100644 --- a/common/log.h +++ b/common/log.h @@ -171,7 +171,7 @@ log_end(void); * @return */ enum logReturns DEFAULT_CC -log_message(const enum logLevels lvl, const char *msg, ...); +log_message(const enum logLevels lvl, const char *msg, ...) printflike(2, 3); /** * -- cgit v1.2.3 From 951e6327576988251a9a479494e20d605efaad71 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:17 -0700 Subject: Make program_name constant, don't duplicate or free it --- common/log.c | 10 ++-------- common/log.h | 2 +- sesman/tools/sesadmin.c | 2 +- sesman/tools/sestest.c | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) (limited to 'common/log.h') diff --git a/common/log.c b/common/log.c index 54f625d7..1338287a 100644 --- a/common/log.c +++ b/common/log.c @@ -212,12 +212,6 @@ internal_log_end(struct log_config *l_cfg) l_cfg->log_file = 0; } - if (0 != l_cfg->program_name) - { - g_free(l_cfg->program_name); - l_cfg->program_name = 0; - } - ret = LOG_STARTUP_OK; return ret; } @@ -336,7 +330,7 @@ internal_config_read_logging(int file, struct log_config *lc, list_clear(param_n); /* setting defaults */ - lc->program_name = g_strdup(applicationName); + lc->program_name = applicationName; lc->log_file = 0; lc->fd = 0; lc->log_level = LOG_LEVEL_DEBUG; @@ -455,7 +449,7 @@ log_start_from_param(const struct log_config *iniParams) g_staticLogConfig->log_level = iniParams->log_level; g_staticLogConfig->log_lock = iniParams->log_lock; g_staticLogConfig->log_lock_attr = iniParams->log_lock_attr; - g_staticLogConfig->program_name = g_strdup(iniParams->program_name); + g_staticLogConfig->program_name = iniParams->program_name; g_staticLogConfig->syslog_level = iniParams->syslog_level; ret = internal_log_start(g_staticLogConfig); diff --git a/common/log.h b/common/log.h index 6654028b..b90ac660 100644 --- a/common/log.h +++ b/common/log.h @@ -65,7 +65,7 @@ enum logReturns struct log_config { - char *program_name; + const char *program_name; char *log_file; int fd; unsigned int log_level; diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c index 3ee230a5..98f727e6 100644 --- a/sesman/tools/sesadmin.c +++ b/sesman/tools/sesadmin.c @@ -59,7 +59,7 @@ int main(int argc, char **argv) serv[0] = '\0'; port[0] = '\0'; - logging.program_name = g_strdup("sesadmin"); + logging.program_name = "sesadmin"; logging.log_file = g_strdup("xrdp-sesadmin.log"); logging.log_level = LOG_LEVEL_DEBUG; logging.enable_syslog = 0; diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c index 0653355c..17795dfc 100644 --- a/sesman/tools/sestest.c +++ b/sesman/tools/sestest.c @@ -45,7 +45,7 @@ int main(int argc, char **argv) log.enable_syslog = 0; log.log_level = 99; - log.program_name = g_strdup("sestest"); + log.program_name = "sestest"; log.log_file = g_strdup("sestest.log"); log_start_from_param(&log); scp_init(); -- cgit v1.2.3 From 2c13ef5c6dd90ee2dcbcba282b2ee702e2ee9f84 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 8 Jul 2016 01:47:31 +0000 Subject: Use enum logLevels consistently for log levels --- common/log.h | 4 ++-- sesman/chansrv/chansrv.c | 10 +++++----- sesman/tools/sestest.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'common/log.h') diff --git a/common/log.h b/common/log.h index b90ac660..61a05d9c 100644 --- a/common/log.h +++ b/common/log.h @@ -68,9 +68,9 @@ struct log_config const char *program_name; char *log_file; int fd; - unsigned int log_level; + enum logLevels log_level; int enable_syslog; - unsigned int syslog_level; + enum logLevels syslog_level; pthread_mutex_t log_lock; pthread_mutexattr_t log_lock_attr; }; diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index 0596b5ff..d272806c 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -1401,8 +1401,8 @@ get_log_path() } /*****************************************************************************/ -static unsigned int APP_CC -get_log_level(const char* level_str, unsigned int default_level) +static enum logLevels APP_CC +get_log_level(const char* level_str, enum logLevels default_level) { static const char* levels[] = { "LOG_LEVEL_ALWAYS", @@ -1421,7 +1421,7 @@ get_log_level(const char* level_str, unsigned int default_level) { if (g_strcasecmp(levels[i], level_str) == 0) { - return i; + return (enum logLevels) i; } } return default_level; @@ -1466,7 +1466,7 @@ main(int argc, char **argv) char log_file[256]; enum logReturns error; struct log_config logconfig; - unsigned int log_level; + enum logLevels log_level; g_init("xrdp-chansrv"); /* os_calls */ @@ -1498,7 +1498,7 @@ main(int argc, char **argv) logconfig.fd = -1; logconfig.log_level = log_level; logconfig.enable_syslog = 0; - logconfig.syslog_level = 0; + logconfig.syslog_level = LOG_LEVEL_ALWAYS; error = log_start_from_param(&logconfig); if (error != LOG_STARTUP_OK) diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c index 17795dfc..081bc88b 100644 --- a/sesman/tools/sestest.c +++ b/sesman/tools/sestest.c @@ -44,7 +44,7 @@ int main(int argc, char **argv) int sock; log.enable_syslog = 0; - log.log_level = 99; + log.log_level = LOG_LEVEL_DEBUG; log.program_name = "sestest"; log.log_file = g_strdup("sestest.log"); log_start_from_param(&log); -- cgit v1.2.3