summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/log.c547
-rw-r--r--common/log.h141
-rw-r--r--common/os_calls.c20
-rw-r--r--common/os_calls.h6
-rw-r--r--sesman/access.c26
-rw-r--r--sesman/chansrv/chansrv.c81
-rw-r--r--sesman/chansrv/clipboard.c147
-rw-r--r--sesman/config.c43
-rw-r--r--sesman/config.h5
-rw-r--r--sesman/env.c6
-rw-r--r--sesman/libscp/libscp_connection.c4
-rw-r--r--sesman/libscp/libscp_init.c10
-rw-r--r--sesman/libscp/libscp_init.h2
-rw-r--r--sesman/libscp/libscp_session.c48
-rw-r--r--sesman/libscp/libscp_tcp.c4
-rw-r--r--sesman/libscp/libscp_v0.c44
-rw-r--r--sesman/libscp/libscp_v1c_mng.c38
-rw-r--r--sesman/libscp/libscp_v1s.c80
-rw-r--r--sesman/libscp/libscp_v1s_mng.c18
-rw-r--r--sesman/lock.c16
-rw-r--r--sesman/scp.c20
-rw-r--r--sesman/scp_v0.c14
-rw-r--r--sesman/scp_v1.c36
-rw-r--r--sesman/scp_v1_mng.c22
-rw-r--r--sesman/sesman.c30
-rw-r--r--sesman/sesman.ini2
-rw-r--r--sesman/session.c112
-rw-r--r--sesman/sig.c36
-rw-r--r--sesman/thread.c30
-rw-r--r--sesman/tools/sesadmin.c8
-rw-r--r--sesman/tools/sestest.c2
-rw-r--r--sesman/verify_user.c14
-rw-r--r--vnc/vnc.c118
-rw-r--r--xrdp/lang.c8
-rw-r--r--xrdp/xrdp.c22
-rw-r--r--xrdp/xrdp.ini8
-rw-r--r--xrdp/xrdp_bitmap.c33
-rw-r--r--xrdp/xrdp_login_wnd.c5
38 files changed, 1180 insertions, 626 deletions
diff --git a/common/log.c b/common/log.c
index 7bbdfc06..040b6e18 100644
--- a/common/log.c
+++ b/common/log.c
@@ -24,11 +24,22 @@
#include <stdarg.h>
#include <stdio.h>
#include <time.h>
-
+#include "list.h"
#include "os_calls.h"
+/* Add a define here so that the log.h will hold more information
+ * when compiled from this C file.
+ * When compiled normally the log.h file only contain the public parts
+ * of the operators in this file. */
+#define LOGINTERNALSTUFF
#include "log.h"
+/* Here we store the current state and configuration of the log */
+static struct log_config* staticLogConfig = NULL;
+
+/*This file first start with all private functions.
+ In the end of the file the public functions is defined*/
+
/**
*
* @brief Opens log file
@@ -36,11 +47,15 @@
* @return see open(2) return values
*
*/
-static int DEFAULT_CC
-log_file_open(const char* fname)
+int DEFAULT_CC
+internal_log_file_open(const char* fname)
{
- return open(fname, O_WRONLY | O_CREAT | O_APPEND | O_SYNC, S_IRUSR |
- S_IWUSR);
+ int ret = -1 ;
+ if(fname!=NULL)
+ {
+ ret = open(fname, O_WRONLY | O_CREAT | O_APPEND | O_SYNC, S_IRUSR |S_IWUSR);
+ }
+ return ret ;
}
/**
@@ -50,8 +65,8 @@ log_file_open(const char* fname)
* @return syslog equivalent logging level
*
*/
-static int DEFAULT_CC
-log_xrdp2syslog(const int lvl)
+int DEFAULT_CC
+internal_log_xrdp2syslog(const enum logLevels lvl)
{
switch (lvl)
{
@@ -63,22 +78,23 @@ log_xrdp2syslog(const int lvl)
return LOG_WARNING;
case LOG_LEVEL_INFO:
return LOG_INFO;
- /* case LOG_LEVEL_DEBUG: */
+ case LOG_LEVEL_DEBUG:
+ return LOG_DEBUG;
default:
+ g_writeln("Undefined log level - programming error");
return LOG_DEBUG;
}
}
/**
- *ring
- * @brief Converts xrdp log level to syslog logging level
+ * @brief Converts xrdp log levels to textual logging levels
* @param lvl logging level
- * @param str pointer to a st
- * @return syslog equivalent logging level
+ * @param str pointer to a string, must be allocated before
+ * @return The log string in str pointer.
*
*/
-static void DEFAULT_CC
-log_lvl2str(int lvl, char* str)
+void DEFAULT_CC
+internal_log_lvl2str(const enum logLevels lvl, char* str)
{
switch (lvl)
{
@@ -94,115 +110,44 @@ log_lvl2str(int lvl, char* str)
case LOG_LEVEL_INFO:
snprintf(str, 9, "%s", "[INFO ] ");
break;
- /* case LOG_LEVEL_DEBUG: */
- default:
+ case LOG_LEVEL_DEBUG:
snprintf(str, 9, "%s", "[DEBUG] ");
break;
+ default:
+ snprintf(str, 9, "%s", "PRG ERR!");
+ g_writeln("Programming error - undefined log level!!!");
}
}
/******************************************************************************/
-int DEFAULT_CC
-log_message(struct log_config* l_cfg, const unsigned int lvl, const char* msg, ...)
-{
- char buff[LOG_BUFFER_SIZE + 31]; /* 19 (datetime) 4 (space+cr+lf+\0) */
- va_list ap;
- int len = 0;
- int rv;
- time_t now_t;
- struct tm* now;
-
- rv = 0;
- if (0 == l_cfg)
- {
- return LOG_ERROR_NO_CFG;
- }
-
- if (0 > l_cfg->fd)
- {
- return LOG_ERROR_FILE_NOT_OPEN;
- }
-
- now_t = time(&now_t);
- now = localtime(&now_t);
-
- snprintf(buff, 21, "[%.4d%.2d%.2d-%.2d:%.2d:%.2d] ", (now->tm_year) + 1900,
- (now->tm_mon) + 1, now->tm_mday, now->tm_hour, now->tm_min,
- now->tm_sec);
-
- log_lvl2str(lvl, buff + 20);
-
- va_start(ap, msg);
- len = vsnprintf(buff + 28, LOG_BUFFER_SIZE, msg, ap);
- va_end(ap);
-
- /* checking for truncated messages */
- if (len > LOG_BUFFER_SIZE)
- {
- log_message(l_cfg, LOG_LEVEL_WARNING, "next message will be truncated");
- }
-
- /* forcing the end of message string */
- #ifdef _WIN32
- buff[len + 28] = '\r';
- buff[len + 29] = '\n';
- buff[len + 30] = '\0';
- #else
- #ifdef _MACOS
- buff[len + 28] = '\r';
- buff[len + 29] = '\0';
- #else
- buff[len + 28] = '\n';
- buff[len + 29] = '\0';
- #endif
- #endif
-
- if (l_cfg->enable_syslog && (lvl <= l_cfg->log_level))
- {
- /* log to syslog */
- syslog(log_xrdp2syslog(lvl), buff + 20);
- }
-
- if (lvl <= l_cfg->log_level)
- {
- /* log to console */
- g_printf((char*)buff);
-
- /* log to application logfile */
-#ifdef LOG_ENABLE_THREAD
- pthread_mutex_lock(&(l_cfg->log_lock));
-#endif
- rv = g_file_write(l_cfg->fd, (char*)buff, g_strlen((char*)buff));
-#ifdef LOG_ENABLE_THREAD
- pthread_mutex_unlock(&(l_cfg->log_lock));
-#endif
- }
- return rv;
-}
/******************************************************************************/
-int DEFAULT_CC
-log_start(struct log_config* l_cfg)
+enum logReturns DEFAULT_CC
+internal_log_start(struct log_config* l_cfg)
{
+ enum logReturns ret = LOG_GENERAL_ERROR;
if (0 == l_cfg)
{
- return LOG_ERROR_MALLOC;
+ ret = LOG_ERROR_MALLOC;
+ return ret;
}
- /* if logfile is NULL, we use a default logfile */
+ /* if logfile is NULL, we return error */
if (0 == l_cfg->log_file)
{
- l_cfg->log_file = g_strdup("./myprogram.log");
+ g_writeln("log_file not properly assigned");
+ return ret ;
}
- /* if progname is NULL, we use a default name */
+ /* if progname is NULL, we ureturn error */
if (0 == l_cfg->program_name)
{
- l_cfg->program_name = g_strdup("myprogram");
+ g_writeln("program_name not properly assigned");
+ return ret ;
}
/* open file */
- l_cfg->fd = log_file_open(l_cfg->log_file);
+ l_cfg->fd = internal_log_file_open(l_cfg->log_file);
if (-1 == l_cfg->fd)
{
@@ -224,29 +169,24 @@ log_start(struct log_config* l_cfg)
}
/******************************************************************************/
-void DEFAULT_CC
-log_end(struct log_config* l_cfg)
+enum logReturns DEFAULT_CC
+internal_log_end(struct log_config* l_cfg)
{
+ enum logReturns ret = LOG_GENERAL_ERROR ;
/* if log is closed, quit silently */
if (0 == l_cfg)
{
- return;
+ return ret;
}
/* closing log file */
- log_message(l_cfg, LOG_LEVEL_ALWAYS, "shutting down log subsystem...");
+ log_message(LOG_LEVEL_ALWAYS, "shutting down log subsystem...");
if (0 > l_cfg->fd)
{
- /* if syslog is enabled, close it */
- if (l_cfg->enable_syslog)
- {
- closelog();
- }
- }
-
- /* closing logfile... */
- g_file_close(l_cfg->fd);
+ /* closing logfile... */
+ g_file_close(l_cfg->fd);
+ }
/* if syslog is enabled, close it */
if (l_cfg->enable_syslog)
@@ -265,11 +205,17 @@ log_end(struct log_config* l_cfg)
g_free(l_cfg->program_name);
l_cfg->program_name = 0;
}
+ ret = LOG_STARTUP_OK ;
+ return ret ;
}
-/******************************************************************************/
-int DEFAULT_CC
-log_text2level(char* buf)
+/**
+ * Converts a string representing th log level to a value
+ * @param buf
+ * @return
+ */
+enum logLevels DEFAULT_CC
+internal_log_text2level(char* buf)
{
if (0 == g_strcasecmp(buf, "0") ||
0 == g_strcasecmp(buf, "core"))
@@ -292,5 +238,372 @@ log_text2level(char* buf)
{
return LOG_LEVEL_INFO;
}
+ else if (0 == g_strcasecmp(buf, "4") ||
+ 0 == g_strcasecmp(buf, "debug"))
+ {
+ return LOG_LEVEL_DEBUG;
+ }
+ g_writeln("Your configured log level is corrupt - we use debug log level");
return LOG_LEVEL_DEBUG;
}
+
+enum logReturns DEFAULT_CC
+internalReadConfiguration(const char *inFilename,const char *applicationName)
+{
+ int fd;
+ enum logReturns ret = LOG_GENERAL_ERROR ;
+ struct list* sec;
+ struct list* param_n;
+ struct list* param_v;
+
+ if(inFilename==NULL)
+ {
+ g_writeln("The inifile is null to readConfiguration!");
+ return ret ;
+ }
+ fd = g_file_open(inFilename);
+ if (-1 == fd)
+ {
+ ret = LOG_ERROR_NO_CFG ;
+ g_writeln("We could not open the configuration file to read log parameters");
+ return ret ;
+ }
+ // we initialize the memory for the configuration and set all content to zero.
+ ret = internalInitAndAllocStruct();
+ if(ret!=LOG_STARTUP_OK){
+ return ret ;
+ }
+
+ sec = list_create();
+ sec->auto_free = 1;
+ file_read_sections(fd, sec);
+ param_n = list_create();
+ param_n->auto_free = 1;
+ param_v = list_create();
+ param_v->auto_free = 1;
+
+ /* read logging config */
+ ret = internal_config_read_logging(fd, staticLogConfig, param_n,
+ param_v, applicationName);
+ if(ret!=LOG_STARTUP_OK)
+ {
+ return ret ;
+ }
+ /* cleanup */
+ list_delete(sec);
+ list_delete(param_v);
+ list_delete(param_n);
+ g_file_close(fd);
+ return ret ;
+}
+
+
+/******************************************************************************/
+enum logReturns DEFAULT_CC
+internal_config_read_logging(int file, struct log_config* lc, struct list* param_n,
+ struct list* param_v,const char *applicationName)
+{
+ int i;
+ char* buf;
+
+ list_clear(param_v);
+ list_clear(param_n);
+
+ /* setting defaults */
+ lc->program_name = g_strdup(applicationName);
+ lc->log_file = 0;
+ lc->fd = 0;
+ lc->log_level = LOG_LEVEL_DEBUG;
+ lc->enable_syslog = 0;
+ lc->syslog_level = LOG_LEVEL_DEBUG;
+
+ file_read_section(file, SESMAN_CFG_LOGGING, param_n, param_v);
+ for (i = 0; i < param_n->count; i++)
+ {
+ buf = (char*)list_get_item(param_n, i);
+ if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_FILE))
+ {
+ lc->log_file = g_strdup((char*)list_get_item(param_v, i));
+ }
+ if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_LEVEL))
+ {
+ lc->log_level = internal_log_text2level((char*)list_get_item(param_v, i));
+ }
+ if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_ENABLE_SYSLOG))
+ {
+ lc->enable_syslog = text2bool((char*)list_get_item(param_v, i));
+ }
+ if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_SYSLOG_LEVEL))
+ {
+ lc->syslog_level = internal_log_text2level((char*)list_get_item(param_v, i));
+ }
+ }
+
+ if (0 == lc->log_file)
+ {
+ lc->log_file=g_strdup("./sesman.log");
+ }
+
+ g_printf("logging configuration:\r\n");
+ g_printf("\tLogFile: %s\r\n",lc->log_file);
+ g_printf("\tLogLevel: %i\r\n", lc->log_level);
+ g_printf("\tEnableSyslog: %i\r\n", lc->enable_syslog);
+ g_printf("\tSyslogLevel: %i\r\n", lc->syslog_level);
+ return LOG_STARTUP_OK;
+}
+
+enum logReturns DEFAULT_CC
+internalInitAndAllocStruct()
+{
+ enum logReturns ret = LOG_GENERAL_ERROR ;
+ staticLogConfig = g_malloc(sizeof(struct log_config),1);
+ if(staticLogConfig!=NULL)
+ {
+ staticLogConfig->fd = -1;
+ staticLogConfig->enable_syslog = 0 ;
+ ret = LOG_STARTUP_OK ;
+ }
+ else
+ {
+ g_writeln("could not allocate memory for log struct") ;
+ ret = LOG_ERROR_MALLOC ;
+ }
+ return ret ;
+}
+
+/*
+ * Here below the public functions
+ */
+
+
+/**
+ *
+ * @brief Reads sesman configuration
+ * @param s translates the strings "1", "true" and "yes" in 1 (true) and other strings in 0
+ * @return 0 on false, 1 on 1,true, yes
+ *
+ */
+int APP_CC
+text2bool(char* s)
+{
+ if (0 == g_strcasecmp(s, "1") ||
+ 0 == g_strcasecmp(s, "true") ||
+ 0 == g_strcasecmp(s, "yes"))
+ {
+ return 1;
+ }
+ return 0;
+}
+
+
+enum logReturns DEFAULT_CC
+log_start_from_param(const struct log_config* iniParams)
+{
+ enum logReturns ret = LOG_GENERAL_ERROR ;
+ if(staticLogConfig!=NULL)
+ {
+ log_message(LOG_LEVEL_ALWAYS,"Log already initialized");
+ return ret ;
+ }
+ if(iniParams==NULL)
+ {
+ g_writeln("inparam to log_start_from_param is NULL");
+ return ret ;
+ }
+ else
+ {
+ /*Copy the struct information*/
+ ret = internalInitAndAllocStruct();
+ if(ret!=LOG_STARTUP_OK)
+ {
+ return ret ;
+ }
+ staticLogConfig->enable_syslog = iniParams->enable_syslog;
+ staticLogConfig->fd = iniParams->fd;
+ staticLogConfig->log_file = g_strdup(iniParams->log_file);
+ staticLogConfig->log_level = iniParams->log_level ;
+ staticLogConfig->log_lock = iniParams->log_lock ;
+ staticLogConfig->log_lock_attr = iniParams->log_lock_attr ;
+ staticLogConfig->program_name = g_strdup(iniParams->program_name);
+ staticLogConfig->syslog_level = iniParams->syslog_level;
+ ret = internal_log_start(staticLogConfig);
+ if(ret!=LOG_STARTUP_OK)
+ {
+ g_writeln("Could not start log");
+ if(staticLogConfig!=NULL)
+ {
+ g_free(staticLogConfig);
+ staticLogConfig = NULL ;
+ }
+ }
+ }
+ return ret ;
+}
+
+
+/**
+ * This function initialize the log facilities according to the configuration
+ * file, that is described by the in parameter.
+ * @param iniFile
+ * @param applicationName, the name that is used in the log for the running application
+ * @return 0 on success
+ */
+enum logReturns DEFAULT_CC
+log_start(const char *iniFile, const char *applicationName)
+{
+ enum logReturns ret = LOG_GENERAL_ERROR ;
+ if(applicationName==NULL)
+ {
+ g_writeln("Programming error your application name cannot be null");
+ return ret ;
+ }
+ ret = internalReadConfiguration(iniFile, applicationName) ;
+ if(ret==LOG_STARTUP_OK)
+ {
+ ret = internal_log_start(staticLogConfig);
+ if(ret!=LOG_STARTUP_OK)
+ {
+ g_writeln("Could not start log");
+ if(staticLogConfig!=NULL){
+ g_free(staticLogConfig);
+ staticLogConfig = NULL ;
+ }
+ }
+ }
+ else
+ {
+ g_writeln("Error reading configuration for log based on config: %s",iniFile);
+ }
+ return ret ;
+}
+
+/**
+ * Function that terminates all logging
+ * @return
+ */
+enum logReturns DEFAULT_CC
+log_end()
+{
+ enum logReturns ret = LOG_GENERAL_ERROR;
+ ret = internal_log_end(staticLogConfig);
+ if(staticLogConfig!=NULL)
+ {
+ g_free(staticLogConfig);
+ staticLogConfig = NULL ;
+ }
+ return ret ;
+}
+
+enum logReturns DEFAULT_CC
+log_message( const enum logLevels lvl,
+const char* msg, ...)
+{
+ char buff[LOG_BUFFER_SIZE + 31]; /* 19 (datetime) 4 (space+cr+lf+\0) */
+ va_list ap;
+ int len = 0;
+ enum logReturns rv = LOG_STARTUP_OK;
+ int writereply = 0 ;
+ time_t now_t;
+ struct tm* now;
+ enum logReturns ret = LOG_GENERAL_ERROR;
+ if(staticLogConfig==NULL)
+ {
+ g_writeln("The log reference is NULL - log not initialized properly");
+ return LOG_ERROR_NO_CFG;
+ }
+ if (0 > staticLogConfig->fd && staticLogConfig->enable_syslog==0)
+ {
+ return LOG_ERROR_FILE_NOT_OPEN;
+ }
+
+ now_t = time(&now_t);
+ now = localtime(&now_t);
+
+ snprintf(buff, 21, "[%.4d%.2d%.2d-%.2d:%.2d:%.2d] ", (now->tm_year) + 1900,
+ (now->tm_mon) + 1, now->tm_mday, now->tm_hour, now->tm_min,
+ now->tm_sec);
+
+ internal_log_lvl2str(lvl, buff + 20);
+
+ va_start(ap, msg);
+ len = vsnprintf(buff + 28, LOG_BUFFER_SIZE, msg, ap);
+ va_end(ap);
+
+ /* checking for truncated messages */
+ if (len > LOG_BUFFER_SIZE)
+ {
+ log_message(LOG_LEVEL_WARNING,"next message will be truncated");
+ }
+
+ /* forcing the end of message string */
+ #ifdef _WIN32
+ buff[len + 28] = '\r';
+ buff[len + 29] = '\n';
+ buff[len + 30] = '\0';
+ #else
+ #ifdef _MACOS
+ buff[len + 28] = '\r';
+ buff[len + 29] = '\0';
+ #else
+ buff[len + 28] = '\n';
+ buff[len + 29] = '\0';
+ #endif
+ #endif
+
+ if (staticLogConfig->enable_syslog && (lvl <= staticLogConfig->syslog_level))
+ {
+ /* log to syslog*/
+ /* %s fix compiler warning 'not a string literal' */
+ syslog(internal_log_xrdp2syslog(lvl), "(%d)(%d)%s",g_getpid(),g_gettid(),(char *)(buff + 20));
+ }
+
+ if (lvl <= staticLogConfig->log_level)
+ {
+ /* log to console */
+ g_printf((char*)buff);
+
+ /* log to application logfile */
+#ifdef LOG_ENABLE_THREAD
+ pthread_mutex_lock(&(staticLogConfig->log_lock));
+#endif
+ if(staticLogConfig->fd>0)
+ {
+ writereply = g_file_write(staticLogConfig->fd, (char*)buff, g_strlen((char*)buff));
+ if(writereply <= 0)
+ {
+ rv = LOG_ERROR_NULL_FILE;
+ }
+ }
+#ifdef LOG_ENABLE_THREAD
+ pthread_mutex_unlock(&(staticLogConfig->log_lock));
+#endif
+ }
+ return rv;
+}
+
+
+/**
+ * Return the configured log file name
+ * @return
+ */
+char *getLogFile(char *replybuf, int bufsize)
+{
+ if(staticLogConfig )
+ {
+ if(staticLogConfig->log_file)
+ {
+ g_strncpy(replybuf, staticLogConfig->log_file,bufsize);
+ }
+ else
+ {
+ g_sprintf(replybuf,"The log_file name is NULL");
+ }
+ }
+ else
+ {
+ g_snprintf(replybuf,bufsize,"The log is not properly started");
+ }
+ return replybuf ;
+}
+
+
diff --git a/common/log.h b/common/log.h
index acb10fea..ac3b97c9 100644
--- a/common/log.h
+++ b/common/log.h
@@ -28,29 +28,41 @@
#define LOG_BUFFER_SIZE 1024
/* logging levels */
-#define LOG_LEVEL_ALWAYS 0
-#define LOG_LEVEL_ERROR 1
-#define LOG_LEVEL_WARNING 2
-#define LOG_LEVEL_INFO 3
-#define LOG_LEVEL_DEBUG 4
+enum logLevels{
+ LOG_LEVEL_ALWAYS = 0,
+ LOG_LEVEL_ERROR,
+ LOG_LEVEL_WARNING,
+ LOG_LEVEL_INFO,
+ LOG_LEVEL_DEBUG
+};
/* startup return values */
-#define LOG_STARTUP_OK 0
-#define LOG_ERROR_MALLOC 1
-#define LOG_ERROR_NULL_FILE 2
-#define LOG_ERROR_FILE_OPEN 3
-#define LOG_ERROR_NO_CFG 4
-#define LOG_ERROR_FILE_NOT_OPEN 5
+enum logReturns{
+ LOG_STARTUP_OK = 0,
+ LOG_ERROR_MALLOC,
+ LOG_ERROR_NULL_FILE,
+ LOG_ERROR_FILE_OPEN,
+ LOG_ERROR_NO_CFG,
+ LOG_ERROR_FILE_NOT_OPEN,
+ LOG_GENERAL_ERROR
+};
+
+#define SESMAN_CFG_LOGGING "Logging"
+#define SESMAN_CFG_LOG_FILE "LogFile"
+#define SESMAN_CFG_LOG_LEVEL "LogLevel"
+#define SESMAN_CFG_LOG_ENABLE_SYSLOG "EnableSyslog"
+#define SESMAN_CFG_LOG_SYSLOG_LEVEL "SyslogLevel"
/* enable threading */
/*#define LOG_ENABLE_THREAD*/
#ifdef DEBUG
- #define LOG_DBG(lcfg,args...) log_message((lcfg), LOG_LEVEL_DEBUG, args);
+ #define LOG_DBG(args...) log_message(LOG_LEVEL_DEBUG, args);
#else
- #define LOG_DBG(lcfg,args...)
+ #define LOG_DBG(args...)
#endif
+
struct log_config
{
char* program_name;
@@ -63,16 +75,8 @@ struct log_config
pthread_mutexattr_t log_lock_attr;
};
-/**
- *
- * @brief Logs a message. Optionally logs the same message on syslog
- * @param lvl The level of the logged message
- * @param msg The message to be logged
- * @return
- *
- */
-int DEFAULT_CC
-log_message(struct log_config* l_cfg, const unsigned int lvl, const char* msg, ...);
+/* internal functions, only used in log.c if this ifdef is defined.*/
+#ifdef LOGINTERNALSTUFF
/**
*
@@ -81,8 +85,8 @@ log_message(struct log_config* l_cfg, const unsigned int lvl, const char* msg, .
* @return
*
*/
-int DEFAULT_CC
-log_start(struct log_config* l_cfg);
+enum logReturns DEFAULT_CC
+internal_log_start(struct log_config* l_cfg);
/**
*
@@ -90,8 +94,16 @@ log_start(struct log_config* l_cfg);
* @param l_cfg pointer to the logging subsystem to stop
*
*/
+enum logReturns DEFAULT_CC
+internal_log_end(struct log_config* l_cfg);
+
+/**
+ * Converts a log level to a string
+ * @param lvl, the loglevel
+ * @param str pointer where the string will be stored.
+ */
void DEFAULT_CC
-log_end(struct log_config* l_cfg);
+internal_log_lvl2str(const enum logLevels lvl, char* str);
/**
*
@@ -100,8 +112,81 @@ log_end(struct log_config* l_cfg);
* @return The corresponding level or LOG_LEVEL_DEBUG if error
*
*/
-int DEFAULT_CC
-log_text2level(char* s);
+enum logLevels DEFAULT_CC
+internal_log_text2level(char* s);
+
+/**
+ * A function that init our struct that holds all state and
+ * also init its content.
+ * @return LOG_STARTUP_OK or LOG_ERROR_MALLOC
+ */
+enum logReturns DEFAULT_CC
+internalInitAndAllocStruct();
+
+/**
+ * Read configuration from a file and store the values in lists.
+ * @param file
+ * @param lc
+ * @param param_n
+ * @param param_v
+ * @param applicationName, the application name used in the log events.
+ * @return
+ */
+enum logReturns DEFAULT_CC
+internal_config_read_logging(int file, struct log_config* lc, struct list* param_n,
+ struct list* param_v,const char *applicationName) ;
+/*End of internal functions*/
+#endif
+/**
+ * This function initialize the log facilities according to the configuration
+ * file, that is described by the in parameter.
+ * @param iniFile
+ * @param applicationName, the name that is used in the log for the running application
+ * @return LOG_STARTUP_OK on success
+ */
+enum logReturns DEFAULT_CC
+log_start(const char *iniFile, const char *applicationName) ;
+
+/**
+ * An alternative log_start where the caller gives the params directly.
+ * @param iniParams
+ * @return
+ */
+enum logReturns DEFAULT_CC
+log_start_from_param(const struct log_config *iniParams);
+/**
+ * Function that terminates all logging
+ * @return
+ */
+enum logReturns DEFAULT_CC
+log_end() ;
+
+/**
+ * the log function that all files use to log an event.
+ * @param lvl, the loglevel
+ * @param msg, the logtext.
+ * @param ...
+ * @return
+ */
+enum logReturns DEFAULT_CC
+log_message(const enum logLevels lvl, const char* msg, ...) ;
+
+/**
+ *
+ * @brief Reads configuration
+ * @param s translates the strings "1", "true" and "yes" in 1 (true) and
+ * other strings in 0
+ * @return 0 on success, 1 on failure
+ *
+ */
+int APP_CC text2bool(char* s);
+/**
+ * This function returns the configured file name for the logfile
+ * @param replybuf the buffer where the reply is stored
+ * @param bufsize how big is the reply buffer.
+ * @return
+ */
+char *getLogFile(char *replybuf, int bufsize);
#endif
diff --git a/common/os_calls.c b/common/os_calls.c
index 211adc82..453c0466 100644
--- a/common/os_calls.c
+++ b/common/os_calls.c
@@ -71,6 +71,10 @@
extern char** environ;
#endif
+#if defined(__linux__)
+#include <linux/unistd.h>
+#endif
+
/* for solaris */
#if !defined(PF_LOCAL)
#define PF_LOCAL AF_UNIX
@@ -2215,6 +2219,22 @@ g_getpid(void)
}
/*****************************************************************************/
+int APP_CC
+g_gettid(void)
+{
+#if defined(_WIN32)
+ return (int)GetCurrentThreadId();
+#else
+#if defined(__linux__)
+ /* This is Linux specific way of getting the thread id.
+ * Function is not part of GLIB so therefore this syscall*/
+ return (int)syscall(__NR_gettid);
+#else
+ return (int)pthread_self();
+#endif
+#endif
+}
+/*****************************************************************************/
/* does not work in win32 */
int APP_CC
g_sigterm(int pid)
diff --git a/common/os_calls.h b/common/os_calls.h
index ddcb59d8..74c4a07b 100644
--- a/common/os_calls.h
+++ b/common/os_calls.h
@@ -252,6 +252,12 @@ int APP_CC
g_exit(int exit_code);
int APP_CC
g_getpid(void);
+/**
+ * Returns the current thread ID
+ * @return
+ */
+int APP_CC
+g_gettid(void);
int APP_CC
g_sigterm(int pid);
int APP_CC
diff --git a/sesman/access.c b/sesman/access.c
index f4bfd30a..0037de3f 100644
--- a/sesman/access.c
+++ b/sesman/access.c
@@ -38,33 +38,33 @@ access_login_allowed(char* user)
if ((0 == g_strncmp(user, "root", 5)) && (0 == g_cfg->sec.allow_root))
{
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING,
+ log_message(LOG_LEVEL_WARNING,
"ROOT login attempted, but root login is disabled");
return 0;
}
if (0 == g_cfg->sec.ts_users_enable)
{
- LOG_DBG(&(g_cfg->log), "Terminal Server Users group is disabled, allowing authentication",
+ LOG_DBG("Terminal Server Users group is disabled, allowing authentication",
1);
return 1;
}
if (0 != g_getuser_info(user, &gid, 0, 0, 0, 0))
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "Cannot read user info! - login denied");
+ log_message(LOG_LEVEL_ERROR, "Cannot read user info! - login denied");
return 0;
}
if (g_cfg->sec.ts_users == gid)
{
- LOG_DBG(&(g_cfg->log), "ts_users is user's primary group");
+ LOG_DBG("ts_users is user's primary group");
return 1;
}
if (0 != g_check_user_in_group(user, g_cfg->sec.ts_users, &ok))
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "Cannot read group info! - login denied");
+ log_message(LOG_LEVEL_ERROR, "Cannot read group info! - login denied");
return 0;
}
@@ -73,7 +73,7 @@ access_login_allowed(char* user)
return 1;
}
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "login denied for user %s", user);
+ log_message(LOG_LEVEL_INFO, "login denied for user %s", user);
return 0;
}
@@ -87,33 +87,33 @@ access_login_mng_allowed(char* user)
if ((0 == g_strncmp(user, "root", 5)) && (0 == g_cfg->sec.allow_root))
{
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING,
+ log_message(LOG_LEVEL_WARNING,
"[MNG] ROOT login attempted, but root login is disabled");
return 0;
}
if (0 == g_cfg->sec.ts_admins_enable)
{
- LOG_DBG(&(g_cfg->log), "[MNG] Terminal Server Admin group is disabled, allowing authentication",
- 1);
+ LOG_DBG("[MNG] Terminal Server Admin group is disabled,"
+ "allowing authentication",1);
return 1;
}
if (0 != g_getuser_info(user, &gid, 0, 0, 0, 0))
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "[MNG] Cannot read user info! - login denied");
+ log_message(LOG_LEVEL_ERROR, "[MNG] Cannot read user info! - login denied");
return 0;
}
if (g_cfg->sec.ts_admins == gid)
{
- LOG_DBG(&(g_cfg->log), "[MNG] ts_users is user's primary group");
+ LOG_DBG("[MNG] ts_users is user's primary group");
return 1;
}
if (0 != g_check_user_in_group(user, g_cfg->sec.ts_admins, &ok))
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "[MNG] Cannot read group info! - login denied");
+ log_message(LOG_LEVEL_ERROR, "[MNG] Cannot read group info! - login denied");
return 0;
}
@@ -122,7 +122,7 @@ access_login_mng_allowed(char* user)
return 1;
}
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "[MNG] login denied for user %s", user);
+ log_message(LOG_LEVEL_INFO, "[MNG] login denied for user %s", user);
return 0;
}
diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c
index f2ca961d..91765749 100644
--- a/sesman/chansrv/chansrv.c
+++ b/sesman/chansrv/chansrv.c
@@ -29,6 +29,7 @@
#include "list.h"
#include "file.h"
#include "file_loc.h"
+#include "log.h"
static struct trans* g_lis_trans = 0;
static struct trans* g_con_trans = 0;
@@ -107,7 +108,7 @@ send_init_response_message(void)
{
struct stream * s = (struct stream *)NULL;
- LOG(1, ("send_init_response_message:"));
+ log_message(LOG_LEVEL_INFO,"send_init_response_message:");
s = trans_get_out_s(g_con_trans, 8192);
if (s == 0)
{
@@ -128,7 +129,7 @@ send_channel_setup_response_message(void)
{
struct stream * s = (struct stream *)NULL;
- LOG(10, ("send_channel_setup_response_message:"));
+ log_message(LOG_LEVEL_DEBUG, "send_channel_setup_response_message:");
s = trans_get_out_s(g_con_trans, 8192);
if (s == 0)
{
@@ -149,7 +150,7 @@ send_channel_data_response_message(void)
{
struct stream * s = (struct stream *)NULL;
- LOG(10, ("send_channel_data_response_message:"));
+ log_message(LOG_LEVEL_DEBUG, "send_channel_data_response_message:");
s = trans_get_out_s(g_con_trans, 8192);
if (s == 0)
{
@@ -168,7 +169,7 @@ send_channel_data_response_message(void)
static int APP_CC
process_message_init(struct stream* s)
{
- LOG(10, ("process_message_init:"));
+ log_message(LOG_LEVEL_DEBUG,"process_message_init:");
return send_init_response_message();
}
@@ -189,9 +190,9 @@ process_message_channel_setup(struct stream* s)
g_cliprdr_chan_id = -1;
g_rdpsnd_chan_id = -1;
g_rdpdr_chan_id = -1;
- LOG(10, ("process_message_channel_setup:"));
+ log_message(LOG_LEVEL_DEBUG, "process_message_channel_setup:");
in_uint16_le(s, num_chans);
- LOG(10, ("process_message_channel_setup: num_chans %d", num_chans));
+ log_message(LOG_LEVEL_DEBUG,"process_message_channel_setup: num_chans %d", num_chans);
for (index = 0; index < num_chans; index++)
{
ci = &(g_chan_items[g_num_chan_items]);
@@ -199,8 +200,8 @@ process_message_channel_setup(struct stream* s)
in_uint8a(s, ci->name, 8);
in_uint16_le(s, ci->id);
in_uint16_le(s, ci->flags);
- LOG(10, ("process_message_channel_setup: chan name '%s' "
- "id %d flags %8.8x", ci->name, ci->id, ci->flags));
+ log_message(LOG_LEVEL_DEBUG, "process_message_channel_setup: chan name '%s' "
+ "id %d flags %8.8x", ci->name, ci->id, ci->flags);
if (g_strcasecmp(ci->name, "cliprdr") == 0)
{
g_cliprdr_index = g_num_chan_items;
@@ -249,8 +250,8 @@ process_message_channel_data(struct stream* s)
in_uint16_le(s, chan_flags);
in_uint16_le(s, length);
in_uint32_le(s, total_length);
- LOG(10, ("process_message_channel_data: chan_id %d "
- "chan_flags %d", chan_id, chan_flags));
+ log_message(LOG_LEVEL_DEBUG,"process_message_channel_data: chan_id %d "
+ "chan_flags %d", chan_id, chan_flags);
rv = send_channel_data_response_message();
if (rv == 0)
{
@@ -321,8 +322,8 @@ process_message(void)
rv = process_message_channel_data_response(s);
break;
default:
- LOG(0, ("process_message: error in process_message "
- "unknown msg %d", id));
+ log_message(LOG_LEVEL_ERROR, "process_message: error in process_message ",
+ "unknown msg %d", id);
break;
}
if (rv != 0)
@@ -354,7 +355,7 @@ my_trans_data_in(struct trans* trans)
{
return 1;
}
- LOG(10, ("my_trans_data_in:"));
+ log_message(LOG_LEVEL_DEBUG,"my_trans_data_in:");
s = trans_get_in_s(trans);
in_uint32_le(s, id);
in_uint32_le(s, size);
@@ -387,7 +388,7 @@ my_trans_conn_in(struct trans* trans, struct trans* new_trans)
{
return 1;
}
- LOG(10, ("my_trans_conn_in:"));
+ log_message(LOG_LEVEL_DEBUG, "my_trans_conn_in:");
g_con_trans = new_trans;
g_con_trans->trans_data_in = my_trans_data_in;
g_con_trans->header_size = 8;
@@ -422,7 +423,7 @@ setup_listen(void)
error = trans_listen(g_lis_trans, port);
if (error != 0)
{
- LOG(0, ("setup_listen: trans_listen failed for port %s", port));
+ log_message(LOG_LEVEL_ERROR, "setup_listen: trans_listen failed for port %s", port);
return 1;
}
return 0;
@@ -438,7 +439,7 @@ channel_thread_loop(void* in_val)
int error = 0;
THREAD_RV rv = 0;
- LOG(1, ("channel_thread_loop: thread start"));
+ log_message(LOG_LEVEL_INFO, "channel_thread_loop: thread start");
rv = 0;
error = setup_listen();
if (error == 0)
@@ -452,7 +453,7 @@ channel_thread_loop(void* in_val)
{
if (g_is_wait_obj_set(g_term_event))
{
- LOG(0, ("channel_thread_loop: g_term_event set"));
+ log_message(LOG_LEVEL_INFO, "channel_thread_loop: g_term_event set");
clipboard_deinit();
sound_deinit();
dev_redir_deinit();
@@ -462,15 +463,15 @@ channel_thread_loop(void* in_val)
{
if (trans_check_wait_objs(g_lis_trans) != 0)
{
- LOG(0, ("channel_thread_loop: trans_check_wait_objs error"));
+ log_message(LOG_LEVEL_INFO, "channel_thread_loop: trans_check_wait_objs error");
}
}
if (g_con_trans != 0)
{
if (trans_check_wait_objs(g_con_trans) != 0)
{
- LOG(0, ("channel_thread_loop: "
- "trans_check_wait_objs error resetting"));
+ log_message(LOG_LEVEL_INFO, "channel_thread_loop: "
+ "trans_check_wait_objs error resetting");
clipboard_deinit();
sound_deinit();
dev_redir_deinit();
@@ -503,7 +504,7 @@ channel_thread_loop(void* in_val)
g_lis_trans = 0;
trans_delete(g_con_trans);
g_con_trans = 0;
- LOG(0, ("channel_thread_loop: thread stop"));
+ log_message(LOG_LEVEL_INFO, "channel_thread_loop: thread stop");
g_set_wait_obj(g_thread_done_event);
return rv;
}
@@ -512,7 +513,7 @@ channel_thread_loop(void* in_val)
void DEFAULT_CC
term_signal_handler(int sig)
{
- LOG(1, ("term_signal_handler: got signal %d", sig));
+ log_message(LOG_LEVEL_INFO,"term_signal_handler: got signal %d", sig);
g_set_wait_obj(g_term_event);
}
@@ -520,7 +521,7 @@ term_signal_handler(int sig)
void DEFAULT_CC
nil_signal_handler(int sig)
{
- LOG(1, ("nil_signal_handler: got signal %d", sig));
+ log_message(LOG_LEVEL_INFO, "nil_signal_handler: got signal %d", sig);
g_set_wait_obj(g_term_event);
}
@@ -636,11 +637,31 @@ main(int argc, char** argv)
int pid = 0;
char text[256] = "";
char* display_text = (char *)NULL;
+ enum logReturns error ;
+ char cfg_file[256];
g_init("xrdp-chansrv"); /* os_calls */
read_ini();
pid = g_getpid();
- LOG(1, ("main: app started pid %d(0x%8.8x)", pid, pid));
+
+ /* starting logging subsystem */
+ g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);
+ error = log_start(cfg_file,"XRDP-Chansrv");
+ if (error != LOG_STARTUP_OK)
+ {
+ char buf[256] ;
+ switch (error)
+ {
+ case LOG_ERROR_MALLOC:
+ g_printf("error on malloc. cannot start logging. quitting.\n");
+ break;
+ case LOG_ERROR_FILE_OPEN:
+ g_printf("error opening log file [%s]. quitting.\n", getLogFile(buf,255));
+ break;
+ }
+ g_exit(1);
+ }
+ log_message(LOG_LEVEL_ALWAYS,"main: app started pid %d(0x%8.8x)", pid, pid);
/* set up signal handler */
g_signal_kill(term_signal_handler); /* SIGKILL */
@@ -648,14 +669,14 @@ main(int argc, char** argv)
g_signal_user_interrupt(term_signal_handler); /* SIGINT */
g_signal_pipe(nil_signal_handler); /* SIGPIPE */
display_text = g_getenv("DISPLAY");
- LOG(1, ("main: DISPLAY env var set to %s", display_text));
+ log_message(LOG_LEVEL_INFO, "main: DISPLAY env var set to %s", display_text);
get_display_num_from_display(display_text);
if (g_display_num == 0)
{
- LOG(0, ("main: error, display is zero"));
+ log_message(LOG_LEVEL_ERROR, "main: error, display is zero");
return 1;
}
- LOG(1, ("main: using DISPLAY %d", g_display_num));
+ log_message(LOG_LEVEL_INFO,"main: using DISPLAY %d", g_display_num);
g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid);
g_term_event = g_create_wait_obj(text);
g_snprintf(text, 255, "xrdp_chansrv_%8.8x_thread_done", pid);
@@ -665,7 +686,7 @@ main(int argc, char** argv)
{
if (g_obj_wait(&g_term_event, 1, 0, 0, 0) != 0)
{
- LOG(0, ("main: error, g_obj_wait failed"));
+ log_message(LOG_LEVEL_ERROR, "main: error, g_obj_wait failed");
break;
}
}
@@ -674,13 +695,13 @@ main(int argc, char** argv)
/* wait for thread to exit */
if (g_obj_wait(&g_thread_done_event, 1, 0, 0, 0) != 0)
{
- LOG(0, ("main: error, g_obj_wait failed"));
+ log_message(LOG_LEVEL_ERROR, "main: error, g_obj_wait failed");
break;
}
}
/* cleanup */
main_cleanup();
- LOG(1, ("main: app exiting pid %d(0x%8.8x)", pid, pid));
+ log_message(LOG_LEVEL_INFO, "main: app exiting pid %d(0x%8.8x)", pid, pid);
g_deinit();
return 0;
}
diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c
index cf601a8e..0afff037 100644
--- a/sesman/chansrv/clipboard.c
+++ b/sesman/chansrv/clipboard.c
@@ -29,6 +29,7 @@
#include "parse.h"
#include "os_calls.h"
#include "chansrv.h"
+#include "log.h"
static Atom g_clipboard_atom = 0;
static Atom g_clip_property_atom = 0;
@@ -78,7 +79,7 @@ clipboard_error_handler(Display* dis, XErrorEvent* xer)
char text[256];
XGetErrorText(dis, xer->error_code, text, 255);
- LOG(1, ("error [%s]", text));
+ log_message(LOG_LEVEL_ERROR,"error [%s]", text);
return 0;
}
@@ -89,7 +90,7 @@ clipboard_error_handler(Display* dis, XErrorEvent* xer)
int DEFAULT_CC
clipboard_fatal_handler(Display* dis)
{
- LOG(1, ("fatal error, exiting"));
+ log_message(LOG_LEVEL_ALWAYS,"fatal error, exiting");
main_cleanup();
return 0;
}
@@ -137,7 +138,7 @@ clipboard_init(void)
int ver_min;
Status st;
- LOG(5, ("xrdp-chansrv: in clipboard_init"));
+ log_message(LOG_LEVEL_DEBUG,"xrdp-chansrv: in clipboard_init");
if (g_clip_up)
{
return 0;
@@ -151,7 +152,7 @@ clipboard_init(void)
g_display = XOpenDisplay(0);
if (g_display == 0)
{
- LOG(0, ("clipboard_init: XOpenDisplay failed"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_init: XOpenDisplay failed");
rv = 1;
}
if (rv == 0)
@@ -159,7 +160,7 @@ clipboard_init(void)
g_x_socket = XConnectionNumber(g_display);
if (g_x_socket == 0)
{
- LOG(0, ("clipboard_init: XConnectionNumber failed"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_init: XConnectionNumber failed");
rv = 2;
}
g_x_wait_obj = g_create_wait_obj_from_socket(g_x_socket, 0);
@@ -169,7 +170,7 @@ clipboard_init(void)
g_clipboard_atom = XInternAtom(g_display, "CLIPBOARD", False);
if (g_clipboard_atom == None)
{
- LOG(0, ("clipboard_init: XInternAtom failed"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_init: XInternAtom failed");
rv = 3;
}
}
@@ -177,15 +178,15 @@ clipboard_init(void)
{
if (!XFixesQueryExtension(g_display, &g_xfixes_event_base, &dummy))
{
- LOG(0, ("clipboard_init: no xfixes"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_init: no xfixes");
rv = 5;
}
}
if (rv == 0)
{
- LOG(0, ("clipboard_init: g_xfixes_event_base %d", g_xfixes_event_base));
+ log_message(LOG_LEVEL_ERROR,"clipboard_init: g_xfixes_event_base %d", g_xfixes_event_base);
st = XFixesQueryVersion(g_display, &ver_maj, &ver_min);
- LOG(0, ("clipboard_init st %d, maj %d min %d", st, ver_maj, ver_min));
+ log_message(LOG_LEVEL_ERROR,"clipboard_init st %d, maj %d min %d", st, ver_maj, ver_min);
g_screen_num = DefaultScreen(g_display);
g_screen = ScreenOfDisplay(g_display, g_screen_num);
g_clip_property_atom = XInternAtom(g_display, "XRDP_CLIP_PROPERTY_ATOM",
@@ -219,13 +220,13 @@ clipboard_init(void)
out_uint32_le(s, 0); /* extra 4 bytes ? */
s_mark_end(s);
size = (int)(s->end - s->data);
- LOG(5, ("clipboard_init: data out, sending "
- "CLIPRDR_CONNECT (clip_msg_id = 1)"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_init: data out, sending "
+ "CLIPRDR_CONNECT (clip_msg_id = 1)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
if (rv != 0)
{
- LOG(0, ("clipboard_init: send_channel_data failed "
- "rv = %d", rv));
+ log_message(LOG_LEVEL_ERROR,"clipboard_init: send_channel_data failed "
+ "rv = %d", rv);
rv = 4;
}
free_stream(s);
@@ -238,7 +239,7 @@ clipboard_init(void)
}
else
{
- LOG(0, ("xrdp-chansrv: clipboard_init: error on exit"));
+ log_message(LOG_LEVEL_ERROR,"xrdp-chansrv: clipboard_init: error on exit");
}
return rv;
}
@@ -281,10 +282,10 @@ clipboard_send_data_request(void)
int rv;
int num_chars;
- LOG(5, ("clipboard_send_data_request:"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_send_data_request:");
if (!g_got_format_announce)
{
- LOG(0, ("clipboard_send_data_request: error, no format announce"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_send_data_request: error, no format announce");
return 0;
}
g_got_format_announce = 0;
@@ -296,8 +297,8 @@ clipboard_send_data_request(void)
out_uint32_le(s, 0x0d);
s_mark_end(s);
size = (int)(s->end - s->data);
- LOG(5, ("clipboard_send_data_request: data out, sending "
- "CLIPRDR_DATA_REQUEST (clip_msg_id = 4)"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_send_data_request: data out, sending "
+ "CLIPRDR_DATA_REQUEST (clip_msg_id = 4)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s);
return rv;
@@ -319,8 +320,8 @@ clipboard_send_format_ack(void)
out_uint32_le(s, 0); /* extra 4 bytes ? */
s_mark_end(s);
size = (int)(s->end - s->data);
- LOG(5, ("clipboard_send_format_ack: data out, sending "
- "CLIPRDR_FORMAT_ACK (clip_msg_id = 3)"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_send_format_ack: data out, sending "
+ "CLIPRDR_FORMAT_ACK (clip_msg_id = 3)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s);
return rv;
@@ -343,8 +344,8 @@ clipboard_send_format_announce(void)
out_uint8s(s, 0x90);
s_mark_end(s);
size = (int)(s->end - s->data);
- LOG(5, ("clipboard_send_format_announce: data out, sending "
- "CLIPRDR_FORMAT_ANNOUNCE (clip_msg_id = 2)"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_send_format_announce: data out, sending "
+ "CLIPRDR_FORMAT_ANNOUNCE (clip_msg_id = 2)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s);
return rv;
@@ -398,7 +399,7 @@ clipboard_send_data_response(void)
num_chars = g_mbstowcs(0, g_last_clip_data, 0);
if (num_chars < 0)
{
- LOG(0, ("clipboard_send_data_response: bad string"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_send_data_response: bad string");
num_chars = 0;
}
}
@@ -412,16 +413,16 @@ clipboard_send_data_response(void)
out_uint32_le(s, num_chars * 2 + 2); /* length */
if (clipboard_out_unicode(s, g_last_clip_data, num_chars) != num_chars * 2)
{
- LOG(0, ("clipboard_send_data_response: error "
- "clipboard_out_unicode didn't write right number of bytes"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_send_data_response: error "
+ "clipboard_out_unicode didn't write right number of bytes");
}
out_uint16_le(s, 0); /* nil for string */
out_uint32_le(s, 0);
s_mark_end(s);
size = (int)(s->end - s->data);
- LOG(5, ("clipboard_send_data_response: data out, sending "
+ log_message(LOG_LEVEL_DEBUG,"clipboard_send_data_response: data out, sending "
"CLIPRDR_DATA_RESPONSE (clip_msg_id = 5) size %d num_chars %d",
- size, num_chars));
+ size, num_chars);
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s);
return rv;
@@ -493,14 +494,14 @@ clipboard_process_format_announce(struct stream* s, int clip_msg_status,
{
Window owner;
- LOG(5, ("clipboard_process_format_announce: CLIPRDR_FORMAT_ANNOUNCE"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_process_format_announce: CLIPRDR_FORMAT_ANNOUNCE");
//g_hexdump(s->p, s->end - s->p);
clipboard_send_format_ack();
g_got_format_announce = 1;
g_data_in_up_to_date = 0;
if (clipboard_set_selection_owner() != 0)
{
- LOG(0, ("clipboard_process_format_announce: XSetSelectionOwner failed"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_process_format_announce: XSetSelectionOwner failed");
}
return 0;
}
@@ -510,7 +511,7 @@ static int APP_CC
clipboard_prcoess_format_ack(struct stream* s, int clip_msg_status,
int clip_msg_len)
{
- LOG(5, ("clipboard_prcoess_format_ack: CLIPRDR_FORMAT_ACK"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_prcoess_format_ack: CLIPRDR_FORMAT_ACK");
//g_hexdump(s->p, s->end - s->p);
return 0;
}
@@ -520,7 +521,7 @@ static int APP_CC
clipboard_process_data_request(struct stream* s, int clip_msg_status,
int clip_msg_len)
{
- LOG(5, ("clipboard_process_data_request: CLIPRDR_DATA_REQUEST"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_process_data_request: CLIPRDR_DATA_REQUEST");
//g_hexdump(s->p, s->end - s->p);
clipboard_send_data_response();
return 0;
@@ -540,7 +541,7 @@ clipboard_process_data_response(struct stream* s, int clip_msg_status,
int wtext_size;
int data_in_len;
- LOG(5, ("clipboard_process_data_response: CLIPRDR_DATA_RESPONSE"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_process_data_response: CLIPRDR_DATA_RESPONSE");
g_waiting_for_data_response = 0;
len = (int)(s->end - s->p);
if (len < 1)
@@ -591,8 +592,8 @@ clipboard_process_data_response(struct stream* s, int clip_msg_status,
lxev = &(g_selection_request_event[index]);
clipboard_provide_selection(lxev, lxev->target, 8, g_data_in,
data_in_len);
- LOG(5, ("clipboard_process_data_response: requestor %d data_in_len %d",
- lxev->requestor, data_in_len));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_process_data_response: requestor %d data_in_len %d",
+ lxev->requestor, data_in_len);
}
}
g_selection_request_event_count = 0;
@@ -658,7 +659,7 @@ clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length,
clip_msg_len);
break;
default:
- LOG(0, ("clipboard_data_in: unknown clip_msg_id %d", clip_msg_id));
+ log_message(LOG_LEVEL_ERROR,"clipboard_data_in: unknown clip_msg_id %d", clip_msg_id);
break;
}
XFlush(g_display);
@@ -686,13 +687,13 @@ clipboard_event_selection_owner_notify(XEvent* xevent)
XFixesSelectionNotifyEvent* lxevent;
lxevent = (XFixesSelectionNotifyEvent*)xevent;
- LOG(5, ("clipboard_event_selection_owner_notify: "
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_owner_notify: "
"window %d subtype %d owner %d g_wnd %d",
- lxevent->window, lxevent->subtype, lxevent->owner, g_wnd));
+ lxevent->window, lxevent->subtype, lxevent->owner, g_wnd);
if (lxevent->owner == g_wnd)
{
- LOG(5, ("clipboard_event_selection_owner_notify: skipping, "
- "onwer == g_wnd"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_owner_notify: skipping, "
+ "onwer == g_wnd");
g_got_selection = 1;
return 0;
}
@@ -812,7 +813,7 @@ clipboard_event_selection_notify(XEvent* xevent)
int* atoms;
Atom type;
- LOG(5, ("clipboard_event_selection_notify:"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_notify:");
convert_to_string = 0;
convert_to_utf8 = 0;
send_format_announce = 0;
@@ -822,8 +823,8 @@ clipboard_event_selection_notify(XEvent* xevent)
lxevent = (XSelectionEvent*)xevent;
if (lxevent->property == None)
{
- LOG(0, ("clipboard_event_selection_notify: clip could "
- "not be converted"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_notify: clip could "
+ "not be converted");
rv = 1;
}
if (rv == 0)
@@ -833,8 +834,8 @@ clipboard_event_selection_notify(XEvent* xevent)
&n_items, &data, &data_size);
if (rv != 0)
{
- LOG(0, ("clipboard_event_selection_notify: "
- "clipboard_get_window_property failed error %d", rv));
+ log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_notify: "
+ "clipboard_get_window_property failed error %d", rv);
}
XDeleteProperty(g_display, lxevent->requestor, lxevent->property);
}
@@ -850,8 +851,8 @@ clipboard_event_selection_notify(XEvent* xevent)
for (index = 0; index < n_items; index++)
{
atom = atoms[index];
- LOG(5, ("clipboard_event_selection_notify: %d %s %d", atom,
- XGetAtomName(g_display, atom), XA_STRING));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_notify: %d %s %d", atom,
+ XGetAtomName(g_display, atom), XA_STRING);
if (atom == g_utf8_atom)
{
convert_to_utf8 = 1;
@@ -864,15 +865,15 @@ clipboard_event_selection_notify(XEvent* xevent)
}
else
{
- LOG(0, ("clipboard_event_selection_notify: error, target is "
+ log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_notify: error, target is "
"'TARGETS' and type[%d] or fmt[%d] not right, should be "
- "type[%d], fmt[%d]", type, fmt, XA_ATOM, 32));
+ "type[%d], fmt[%d]", type, fmt, XA_ATOM, 32);
}
}
else if (lxevent->target == g_utf8_atom)
{
- LOG(5, ("clipboard_event_selection_notify: UTF8_STRING data_size %d",
- data_size));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_notify: UTF8_STRING data_size %d",
+ data_size);
g_free(g_last_clip_data);
g_last_clip_size = data_size;
g_last_clip_data = g_malloc(g_last_clip_size + 1, 0);
@@ -883,8 +884,8 @@ clipboard_event_selection_notify(XEvent* xevent)
}
else if (lxevent->target == XA_STRING)
{
- LOG(5, ("clipboard_event_selection_notify: XA_STRING data_size %d",
- data_size));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_notify: XA_STRING data_size %d",
+ data_size);
g_free(g_last_clip_data);
g_last_clip_size = data_size;
g_last_clip_data = g_malloc(g_last_clip_size + 1, 0);
@@ -895,12 +896,12 @@ clipboard_event_selection_notify(XEvent* xevent)
}
else
{
- LOG(0, ("clipboard_event_selection_notify: unknown target"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_notify: unknown target");
}
}
else
{
- LOG(0, ("clipboard_event_selection_notify: unknown selection"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_notify: unknown selection");
}
}
if (convert_to_utf8)
@@ -952,19 +953,19 @@ clipboard_event_selection_request(XEvent* xevent)
char* xdata;
lxev = (XSelectionRequestEvent*)xevent;
- LOG(5, ("clipboard_event_selection_request: g_wnd %d, "
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: g_wnd %d, "
".requestor %d .owner %d .selection %d '%s' .target %d .property %d",
g_wnd, lxev->requestor, lxev->owner, lxev->selection,
XGetAtomName(g_display, lxev->selection),
- lxev->target, lxev->property));
+ lxev->target, lxev->property);
if (lxev->property == None)
{
- LOG(5, ("clipboard_event_selection_request: lxev->property is None"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: lxev->property is None");
}
else if (lxev->target == g_targets_atom)
{
/* requestor is asking what the selection can be converted to */
- LOG(5, ("clipboard_event_selection_request: g_targets_atom"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: g_targets_atom");
ui32[0] = g_targets_atom;
ui32[1] = g_timestamp_atom;
ui32[2] = g_multiple_atom;
@@ -975,29 +976,29 @@ clipboard_event_selection_request(XEvent* xevent)
else if (lxev->target == g_timestamp_atom)
{
/* requestor is asking the time I got the selection */
- LOG(5, ("clipboard_event_selection_request: g_timestamp_atom"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: g_timestamp_atom");
ui32[0] = g_selection_time;
return clipboard_provide_selection(lxev, XA_INTEGER, 32, (char*)ui32, 1);
}
else if (lxev->target == g_multiple_atom)
{
/* target, property pairs */
- LOG(5, ("clipboard_event_selection_request: g_multiple_atom"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: g_multiple_atom");
if (clipboard_get_window_property(xev.xselection.requestor,
xev.xselection.property,
&type, &fmt, &n_items, &xdata,
&xdata_size) == 0)
{
- LOG(5, ("clipboard_event_selection_request: g_multiple_atom "
- "n_items %d", n_items));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: g_multiple_atom "
+ "n_items %d", n_items);
/* todo */
g_free(xdata);
}
}
else if ((lxev->target == XA_STRING) || (lxev->target == g_utf8_atom))
{
- LOG(5, ("clipboard_event_selection_request: %s",
- XGetAtomName(g_display, lxev->target)));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: %s",
+ XGetAtomName(g_display, lxev->target));
if (g_data_in_up_to_date)
{
return clipboard_provide_selection(lxev, lxev->target, 8,
@@ -1005,7 +1006,7 @@ clipboard_event_selection_request(XEvent* xevent)
}
if (g_selection_request_event_count > 10)
{
- LOG(0, ("clipboard_event_selection_request: error, too many requests"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_request: error, too many requests");
}
else
{
@@ -1023,8 +1024,8 @@ clipboard_event_selection_request(XEvent* xevent)
}
else
{
- LOG(0, ("clipboard_event_selection_request: unknown "
- "target %s", XGetAtomName(g_display, lxev->target)));
+ log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_request: unknown "
+ "target %s", XGetAtomName(g_display, lxev->target));
}
clipboard_refuse_selection(lxev);
return 0;
@@ -1045,7 +1046,7 @@ clipboard_event_selection_request(XEvent* xevent)
static int APP_CC
clipboard_event_selection_clear(XEvent* xevent)
{
- LOG(5, ("clipboard_event_selection_clear:"));
+ log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_clear:");
return 0;
}
@@ -1106,7 +1107,7 @@ clipboard_check_wait_objs(void)
if (XPending(g_display) < 1)
{
/* something is wrong, should not get here */
- LOG(0, ("clipboard_check_wait_objs: sck closed"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_check_wait_objs: sck closed");
return 0;
}
if (g_waiting_for_data_response)
@@ -1115,8 +1116,8 @@ clipboard_check_wait_objs(void)
g_waiting_for_data_response_time;
if (time_diff > 1000)
{
- LOG(0, ("clipboard_check_wait_objs: warning, waiting for "
- "data response too long"));
+ log_message(LOG_LEVEL_ERROR,"clipboard_check_wait_objs: warning, waiting for "
+ "data response too long");
}
}
while (XPending(g_display) > 0)
@@ -1145,8 +1146,8 @@ clipboard_check_wait_objs(void)
clipboard_event_selection_owner_notify(&xevent);
break;
}
- LOG(0, ("clipboard_check_wait_objs unknown type %d",
- xevent.type));
+ log_message(LOG_LEVEL_ERROR,"clipboard_check_wait_objs unknown type %d",
+ xevent.type);
break;
}
}
diff --git a/sesman/config.c b/sesman/config.c
index d81f7968..a4342676 100644
--- a/sesman/config.c
+++ b/sesman/config.c
@@ -29,28 +29,11 @@
#include "list.h"
#include "file.h"
#include "sesman.h"
+#include "log.h"
extern struct config_sesman* g_cfg; /* in sesman.c */
-/******************************************************************************/
-/**
- *
- * @brief Reads sesman configuration
- * @param s translates the strings "1", "true" and "yes" in 1 (true) and other strings in 0
- * @return 0 on success, 1 on failure
- *
- */
-static int APP_CC
-text2bool(char* s)
-{
- if (0 == g_strcasecmp(s, "1") ||
- 0 == g_strcasecmp(s, "true") ||
- 0 == g_strcasecmp(s, "yes"))
- {
- return 1;
- }
- return 0;
-}
+
/******************************************************************************/
int DEFAULT_CC
@@ -66,16 +49,16 @@ config_read(struct config_sesman* cfg)
fd = g_file_open(cfg_file);
if (-1 == fd)
{
- if (g_cfg->log.fd >= 0)
- {
+ //if (g_cfg->log.fd >= 0)
+ //{
/* logging is already active */
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "error opening %s in \
+ log_message(LOG_LEVEL_ALWAYS, "error opening %s in \
config_read", cfg_file);
- }
- else
- {
+ //}
+ //else
+ //{
g_printf("error opening %s in config_read", cfg_file);
- }
+ //}
return 1;
}
g_memset(cfg, 0, sizeof(struct config_sesman));
@@ -95,7 +78,7 @@ config_read(struct config_sesman* cfg)
config_read_rdp_params(fd, cfg, param_n, param_v);
/* read logging config */
- config_read_logging(fd, &(cfg->log), param_n, param_v);
+ // config_read_logging(fd, &(cfg->log), param_n, param_v);
/* read security config */
config_read_security(fd, &(cfg->sec), param_n, param_v);
@@ -190,7 +173,7 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n,
return 0;
}
-/******************************************************************************/
+/******************************************************************************
int DEFAULT_CC
config_read_logging(int file, struct log_config* lc, struct list* param_n,
struct list* param_v)
@@ -201,7 +184,7 @@ config_read_logging(int file, struct log_config* lc, struct list* param_n,
list_clear(param_v);
list_clear(param_n);
- /* setting defaults */
+ // setting defaults
lc->program_name = g_strdup("sesman");
lc->log_file = 0;
lc->fd = 0;
@@ -244,7 +227,7 @@ config_read_logging(int file, struct log_config* lc, struct list* param_n,
return 0;
}
-
+*/
/******************************************************************************/
int DEFAULT_CC
config_read_security(int file, struct config_security* sc,
diff --git a/sesman/config.h b/sesman/config.h
index 2a4ebd28..73fab38f 100644
--- a/sesman/config.h
+++ b/sesman/config.h
@@ -45,12 +45,13 @@
#define SESMAN_CFG_RDP_PARAMS "X11rdp"
#define SESMAN_CFG_VNC_PARAMS "Xvnc"
+/*
#define SESMAN_CFG_LOGGING "Logging"
#define SESMAN_CFG_LOG_FILE "LogFile"
#define SESMAN_CFG_LOG_LEVEL "LogLevel"
#define SESMAN_CFG_LOG_ENABLE_SYSLOG "EnableSyslog"
#define SESMAN_CFG_LOG_SYSLOG_LEVEL "SyslogLevel"
-
+*/
#define SESMAN_CFG_SECURITY "Security"
#define SESMAN_CFG_SEC_LOGIN_RETRY "MaxLoginRetry"
#define SESMAN_CFG_SEC_ALLOW_ROOT "AllowRootLogin"
@@ -186,7 +187,7 @@ struct config_sesman
* @var log
* @brief Log configuration struct
*/
- struct log_config log;
+ //struct log_config log;
/**
* @var sec
* @brief Security configuration options struct
diff --git a/sesman/env.c b/sesman/env.c
index 4bcb22e8..f7abe120 100644
--- a/sesman/env.c
+++ b/sesman/env.c
@@ -47,7 +47,7 @@ env_check_password_file(char* filename, char* password)
fd = g_file_open(filename);
if (fd == -1)
{
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING,
+ log_message(LOG_LEVEL_WARNING,
"can't read vnc password file - %s",
filename);
return 1;
@@ -112,13 +112,13 @@ env_set_user(char* username, char* passwd_file, int display)
/* we use auth_file_path as requested */
g_sprintf(passwd_file, g_cfg->auth_file_path, username);
}
- LOG_DBG(&(g_cfg->log), "pass file: %s", passwd_file);
+ LOG_DBG("pass file: %s", passwd_file);
}
}
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR,
+ log_message(LOG_LEVEL_ERROR,
"error getting user info for user %s", username);
}
return error;
diff --git a/sesman/libscp/libscp_connection.c b/sesman/libscp/libscp_connection.c
index 0b09852e..bf49fb84 100644
--- a/sesman/libscp/libscp_connection.c
+++ b/sesman/libscp/libscp_connection.c
@@ -27,7 +27,7 @@
#include "libscp_connection.h"
-extern struct log_config* s_log;
+//extern struct log_config* s_log;
struct SCP_CONNECTION*
scp_connection_create(int sck)
@@ -38,7 +38,7 @@ scp_connection_create(int sck)
if (0 == conn)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[connection:%d] connection create: malloc error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[connection:%d] connection create: malloc error", __LINE__);
return 0;
}
diff --git a/sesman/libscp/libscp_init.c b/sesman/libscp/libscp_init.c
index 22497ac2..4c48fb1f 100644
--- a/sesman/libscp/libscp_init.c
+++ b/sesman/libscp/libscp_init.c
@@ -27,22 +27,24 @@
#include "libscp_init.h"
-struct log_config* s_log;
+//struct log_config* s_log;
/* server API */
int DEFAULT_CC
-scp_init(struct log_config* log)
+scp_init()
{
+/*
if (0 == log)
{
return 1;
}
+*/
- s_log = log;
+ //s_log = log;
scp_lock_init();
- log_message(s_log, LOG_LEVEL_WARNING, "[init:%d] libscp initialized", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[init:%d] libscp initialized", __LINE__);
return 0;
}
diff --git a/sesman/libscp/libscp_init.h b/sesman/libscp/libscp_init.h
index 5ac0ba02..92dbc659 100644
--- a/sesman/libscp/libscp_init.h
+++ b/sesman/libscp/libscp_init.h
@@ -42,7 +42,7 @@
*
*/
int DEFAULT_CC
-scp_init(struct log_config* log);
+scp_init();
#endif
diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c
index 8ac94d25..244f188a 100644
--- a/sesman/libscp/libscp_session.c
+++ b/sesman/libscp/libscp_session.c
@@ -31,7 +31,7 @@
#include <sys/socket.h>
#include <arpa/inet.h>
-extern struct log_config* s_log;
+//extern struct log_config* s_log;
/*******************************************************************/
struct SCP_SESSION*
@@ -42,7 +42,7 @@ scp_session_create()
s = (struct SCP_SESSION*)g_malloc(sizeof(struct SCP_SESSION), 1);
if (0 == s)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] session create: malloc error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] session create: malloc error", __LINE__);
return 0;
}
return s;
@@ -65,12 +65,12 @@ scp_session_set_type(struct SCP_SESSION* s, tui8 type)
s->mng = (struct SCP_MNG_DATA*)g_malloc(sizeof(struct SCP_MNG_DATA), 1);
if (NULL == s->mng)
{
- log_message(s_log, LOG_LEVEL_ERROR, "[session:%d] set_type: internal error", __LINE__);
+ log_message(LOG_LEVEL_ERROR, "[session:%d] set_type: internal error", __LINE__);
return 1;
}
break;
default:
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_type: unknown type", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_type: unknown type", __LINE__);
return 1;
}
return 0;
@@ -89,7 +89,7 @@ scp_session_set_version(struct SCP_SESSION* s, tui32 version)
s->version = 1;
break;
default:
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_version: unknown version", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_version: unknown version", __LINE__);
return 1;
}
return 0;
@@ -149,7 +149,7 @@ scp_session_set_locale(struct SCP_SESSION* s, char* str)
{
if (0 == str)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_locale: null locale", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_locale: null locale", __LINE__);
s->locale[0]='\0';
return 1;
}
@@ -164,7 +164,7 @@ scp_session_set_username(struct SCP_SESSION* s, char* str)
{
if (0 == str)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_username: null username", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_username: null username", __LINE__);
return 1;
}
if (0 != s->username)
@@ -174,7 +174,7 @@ scp_session_set_username(struct SCP_SESSION* s, char* str)
s->username = g_strdup(str);
if (0 == s->username)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_username: strdup error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_username: strdup error", __LINE__);
return 1;
}
return 0;
@@ -186,7 +186,7 @@ scp_session_set_password(struct SCP_SESSION* s, char* str)
{
if (0 == str)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_password: null password", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_password: null password", __LINE__);
return 1;
}
if (0 != s->password)
@@ -196,7 +196,7 @@ scp_session_set_password(struct SCP_SESSION* s, char* str)
s->password = g_strdup(str);
if (0 == s->password)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_password: strdup error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_password: strdup error", __LINE__);
return 1;
}
return 0;
@@ -208,7 +208,7 @@ scp_session_set_domain(struct SCP_SESSION* s, char* str)
{
if (0 == str)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_domain: null domain", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_domain: null domain", __LINE__);
return 1;
}
if (0 != s->domain)
@@ -218,7 +218,7 @@ scp_session_set_domain(struct SCP_SESSION* s, char* str)
s->domain = g_strdup(str);
if (0 == s->domain)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_domain: strdup error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_domain: strdup error", __LINE__);
return 1;
}
return 0;
@@ -230,7 +230,7 @@ scp_session_set_program(struct SCP_SESSION* s, char* str)
{
if (0 == str)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_program: null program", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_program: null program", __LINE__);
return 1;
}
if (0 != s->program)
@@ -240,7 +240,7 @@ scp_session_set_program(struct SCP_SESSION* s, char* str)
s->program = g_strdup(str);
if (0 == s->program)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_program: strdup error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_program: strdup error", __LINE__);
return 1;
}
return 0;
@@ -252,7 +252,7 @@ scp_session_set_directory(struct SCP_SESSION* s, char* str)
{
if (0 == str)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_directory: null directory", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_directory: null directory", __LINE__);
return 1;
}
if (0 != s->directory)
@@ -262,7 +262,7 @@ scp_session_set_directory(struct SCP_SESSION* s, char* str)
s->directory = g_strdup(str);
if (0 == s->directory)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_directory: strdup error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_directory: strdup error", __LINE__);
return 1;
}
return 0;
@@ -274,7 +274,7 @@ scp_session_set_client_ip(struct SCP_SESSION* s, char* str)
{
if (0 == str)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_client_ip: null ip", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: null ip", __LINE__);
return 1;
}
if (0 != s->client_ip)
@@ -284,7 +284,7 @@ scp_session_set_client_ip(struct SCP_SESSION* s, char* str)
s->client_ip = g_strdup(str);
if (0 == s->client_ip)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_client_ip: strdup error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: strdup error", __LINE__);
return 1;
}
return 0;
@@ -296,7 +296,7 @@ scp_session_set_hostname(struct SCP_SESSION* s, char* str)
{
if (0 == str)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_hostname: null hostname", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_hostname: null hostname", __LINE__);
return 1;
}
if (0 != s->hostname)
@@ -306,7 +306,7 @@ scp_session_set_hostname(struct SCP_SESSION* s, char* str)
s->hostname = g_strdup(str);
if (0 == s->hostname)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_hostname: strdup error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_hostname: strdup error", __LINE__);
return 1;
}
return 0;
@@ -318,7 +318,7 @@ scp_session_set_errstr(struct SCP_SESSION* s, char* str)
{
if (0 == str)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_errstr: null string", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_errstr: null string", __LINE__);
return 1;
}
if (0 != s->errstr)
@@ -328,7 +328,7 @@ scp_session_set_errstr(struct SCP_SESSION* s, char* str)
s->errstr = g_strdup(str);
if (0 == s->errstr)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_errstr: strdup error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_errstr: strdup error", __LINE__);
return 1;
}
return 0;
@@ -359,7 +359,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
ret = inet_pton(AF_INET, addr, &ip4);
if (ret == 0)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__);
inet_pton(AF_INET, "127.0.0.1", &ip4);
g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4);
return 1;
@@ -375,7 +375,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
ret = inet_pton(AF_INET6, addr, &ip6);
if (ret == 0)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__);
inet_pton(AF_INET, "::1", &ip6);
g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16);
return 1;
diff --git a/sesman/libscp/libscp_tcp.c b/sesman/libscp/libscp_tcp.c
index 6ffa4693..459992fe 100644
--- a/sesman/libscp/libscp_tcp.c
+++ b/sesman/libscp/libscp_tcp.c
@@ -42,7 +42,7 @@ scp_tcp_force_recv(int sck, char* data, int len)
int rcvd;
int block;
- LOG_DBG(s_log, "scp_tcp_force_recv()");
+ LOG_DBG("scp_tcp_force_recv()");
block = scp_lock_fork_critical_section_start();
while (len > 0)
@@ -84,7 +84,7 @@ scp_tcp_force_send(int sck, char* data, int len)
int sent;
int block;
- LOG_DBG(s_log, "scp_tcp_force_send()");
+ LOG_DBG("scp_tcp_force_send()");
block = scp_lock_fork_critical_section_start();
while (len > 0)
diff --git a/sesman/libscp/libscp_v0.c b/sesman/libscp/libscp_v0.c
index d46d6afa..69dd4afa 100644
--- a/sesman/libscp/libscp_v0.c
+++ b/sesman/libscp/libscp_v0.c
@@ -43,7 +43,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
init_stream(c->in_s, c->in_s->size);
init_stream(c->out_s, c->in_s->size);
- LOG_DBG(s_log, "[v0:%d] starting connection", __LINE__);
+ LOG_DBG("[v0:%d] starting connection", __LINE__);
g_tcp_set_non_blocking(c->in_sck);
g_tcp_set_no_delay(c->in_sck);
s_push_layer(c->out_s, channel_hdr, 8);
@@ -59,7 +59,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
}
else
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
return SCP_CLIENT_STATE_INTERNAL_ERR;
}
sz = g_strlen(s->username);
@@ -83,27 +83,27 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
return SCP_CLIENT_STATE_NETWORK_ERR;
}
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (0 != version)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__);
return SCP_CLIENT_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size < 14)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: packet size error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: packet size error", __LINE__);
return SCP_CLIENT_STATE_SIZE_ERR;
}
@@ -111,7 +111,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
init_stream(c->in_s, c->in_s->size);
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
return SCP_CLIENT_STATE_NETWORK_ERR;
}
@@ -119,7 +119,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
in_uint16_be(c->in_s, sz);
if (3 != sz)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__);
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
@@ -127,14 +127,14 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
in_uint16_be(c->in_s, sz);
if (1 != sz)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: connection denied", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: connection denied", __LINE__);
return SCP_CLIENT_STATE_CONNECTION_DENIED;
}
in_uint16_be(c->in_s, sz);
s->display = sz;
- LOG_DBG(s_log, "[v0:%d] connection terminated", __LINE__);
+ LOG_DBG("[v0:%d] connection terminated", __LINE__);
return SCP_CLIENT_STATE_END;
}
@@ -152,20 +152,20 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
if (!skipVchk)
{
- LOG_DBG(s_log, "[v0:%d] starting connection", __LINE__);
+ LOG_DBG("[v0:%d] starting connection", __LINE__);
if (0 == scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
c->in_s->end = c->in_s->data + 8;
in_uint32_be(c->in_s, version);
if (version != 0)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__);
return SCP_SERVER_STATE_VERSION_ERR;
}
}
else
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
}
@@ -175,7 +175,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
init_stream(c->in_s, 8196);
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
c->in_s->end = c->in_s->data + (size - 8);
@@ -187,7 +187,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
session = scp_session_create();
if (0 == session)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
@@ -208,7 +208,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
if (0 != scp_session_set_username(session, buf))
{
scp_session_destroy(session);
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting username", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting username", __LINE__);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
@@ -219,7 +219,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
if (0 != scp_session_set_password(session, buf))
{
scp_session_destroy(session);
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting password", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting password", __LINE__);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
@@ -279,7 +279,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
}
else
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
@@ -300,11 +300,11 @@ scp_v0s_allow_connection(struct SCP_CONNECTION* c, SCP_DISPLAY d)
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
- LOG_DBG(s_log, "[v0:%d] connection terminated (allowed)", __LINE__);
+ LOG_DBG("[v0:%d] connection terminated (allowed)", __LINE__);
return SCP_SERVER_STATE_OK;
}
@@ -321,10 +321,10 @@ scp_v0s_deny_connection(struct SCP_CONNECTION* c)
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
- LOG_DBG(s_log, "[v0:%d] connection terminated (denied)", __LINE__);
+ LOG_DBG("[v0:%d] connection terminated (denied)", __LINE__);
return SCP_SERVER_STATE_OK;
}
diff --git a/sesman/libscp/libscp_v1c_mng.c b/sesman/libscp/libscp_v1c_mng.c
index bb54bc79..88f86f4f 100644
--- a/sesman/libscp/libscp_v1c_mng.c
+++ b/sesman/libscp/libscp_v1c_mng.c
@@ -30,7 +30,7 @@
#include <stdlib.h>
#include <stdio.h>
-extern struct log_config* s_log;
+//extern struct log_config* s_log;
static enum SCP_CLIENT_STATES_E
_scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
@@ -91,7 +91,7 @@ scp_v1c_mng_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, size))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
return SCP_CLIENT_STATE_NETWORK_ERR;
}
@@ -127,7 +127,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, size))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
return SCP_CLIENT_STATE_NETWORK_ERR;
}
@@ -137,42 +137,42 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
init_stream(c->in_s, c->in_s->size);
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version != 1)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__);
return SCP_CLIENT_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size < 12)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: size error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: size error", __LINE__);
return SCP_CLIENT_STATE_SIZE_ERR;
}
init_stream(c->in_s, c->in_s->size);
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != SCP_COMMAND_SET_MANAGE)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != SCP_CMD_MNG_LIST) /* session list */
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
@@ -188,14 +188,14 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
(*scount) = sescnt;
(*s) = NULL;
- LOG_DBG(s_log, "[v1c_mng] end list - no session on TS");
+ LOG_DBG("[v1c_mng] end list - no session on TS");
return SCP_CLIENT_STATE_LIST_OK;
}
ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0);
if (ds == 0)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: internal error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: internal error", __LINE__);
return SCP_CLIENT_STATE_INTERNAL_ERR;
}
}
@@ -240,7 +240,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
(*scount) = sescnt;
(*s) = ds;
- LOG_DBG(s_log, "[v1c_mng] end list");
+ LOG_DBG("[v1c_mng] end list");
return SCP_CLIENT_STATE_LIST_OK;
}
@@ -350,14 +350,14 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
init_stream(c->in_s, c->in_s->size);
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version != 1)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__);
return SCP_CLIENT_STATE_VERSION_ERR;
}
@@ -367,21 +367,21 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
/* read the rest of the packet */
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != SCP_COMMAND_SET_MANAGE)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd == SCP_CMD_MNG_LOGIN_ALLOW) /* connection ok */
{
- log_message(s_log, LOG_LEVEL_INFO, "[v1c_mng:%d] connection ok", __LINE__);
+ log_message(LOG_LEVEL_INFO, "[v1c_mng:%d] connection ok", __LINE__);
return SCP_CLIENT_STATE_OK;
}
else if (cmd == SCP_CMD_MNG_LOGIN_DENY) /* connection denied */
@@ -391,10 +391,10 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
in_uint8a(c->in_s, buf, dim);
scp_session_set_errstr(s, buf);
- log_message(s_log, LOG_LEVEL_INFO, "[v1c_mng:%d] connection denied: %s", __LINE__ , s->errstr);
+ log_message(LOG_LEVEL_INFO, "[v1c_mng:%d] connection denied: %s", __LINE__ , s->errstr);
return SCP_CLIENT_STATE_CONNECTION_DENIED;
}
- log_message(s_log, LOG_LEVEL_WARNING, "[v1c-mng:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1c-mng:%d] connection aborted: sequence error", __LINE__);
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
diff --git a/sesman/libscp/libscp_v1s.c b/sesman/libscp/libscp_v1s.c
index e57a907e..6b54a14b 100644
--- a/sesman/libscp/libscp_v1s.c
+++ b/sesman/libscp/libscp_v1s.c
@@ -30,7 +30,7 @@
#include "libscp_v1s.h"
-extern struct log_config* s_log;
+//extern struct log_config* s_log;
/* server API */
enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
@@ -51,13 +51,13 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
in_uint32_be(c->in_s, version);
if (version != 1)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
return SCP_SERVER_STATE_VERSION_ERR;
}
}
else
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
}
@@ -65,14 +65,14 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
in_uint32_be(c->in_s, size);
if (size < 12)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
return SCP_SERVER_STATE_SIZE_ERR;
}
init_stream(c->in_s, c->in_s->size);
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
@@ -82,7 +82,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
/* if we are starting a management session */
if (cmdset == SCP_COMMAND_SET_MANAGE)
{
- log_message(s_log, LOG_LEVEL_DEBUG, "[v1s:%d] requested management connection", __LINE__);
+ log_message(LOG_LEVEL_DEBUG, "[v1s:%d] requested management connection", __LINE__);
/* should return SCP_SERVER_STATE_START_MANAGE */
return scp_v1s_mng_accept(c, s);
}
@@ -90,7 +90,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
/* if we started with resource sharing... */
if (cmdset == SCP_COMMAND_SET_RSR)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
@@ -98,14 +98,14 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
in_uint16_be(c->in_s, cmd);
if (cmd != 1)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
session = scp_session_create();
if (0 == session)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (malloc returned NULL)", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (malloc returned NULL)", __LINE__);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
scp_session_set_version(session, 1);
@@ -114,7 +114,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
if ((sz != SCP_SESSION_TYPE_XVNC) && (sz != SCP_SESSION_TYPE_XRDP))
{
scp_session_destroy(session);
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: unknown session type", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: unknown session type", __LINE__);
return SCP_SERVER_STATE_SESSION_TYPE_ERR;
}
scp_session_set_type(session, sz);
@@ -151,7 +151,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
if (0 != scp_session_set_hostname(session, buf))
{
scp_session_destroy(session);
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
@@ -162,7 +162,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
if (0 != scp_session_set_username(session, buf))
{
scp_session_destroy(session);
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
@@ -173,7 +173,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
if (0 != scp_session_set_password(session, buf))
{
scp_session_destroy(session);
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
@@ -208,7 +208,7 @@ scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason)
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, rlen+14))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
@@ -250,49 +250,49 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, 14+rlen))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
/* receive password & username */
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version!=1)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
return SCP_SERVER_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size<12)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
return SCP_SERVER_STATE_SIZE_ERR;
}
init_stream(c->in_s, c->in_s->size);
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmdset);
if (cmdset != SCP_COMMAND_SET_DEFAULT)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != 4)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
@@ -304,7 +304,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
if (0 != scp_session_set_username(s, buf))
{
scp_session_destroy(s);
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
@@ -315,7 +315,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
if (0 != scp_session_set_password(s, buf))
{
scp_session_destroy(s);
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
@@ -356,7 +356,7 @@ scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d)
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, 14))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
@@ -410,7 +410,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, size))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
@@ -420,42 +420,42 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
init_stream(c->in_s, c->in_s->size);
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version!=1)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
return SCP_SERVER_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size<12)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
return SCP_SERVER_STATE_SIZE_ERR;
}
init_stream(c->in_s, c->in_s->size);
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != SCP_COMMAND_SET_DEFAULT)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != 41)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
@@ -542,7 +542,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, size))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
}
@@ -551,21 +551,21 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
init_stream(c->in_s, c->in_s->size);
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (8)))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version != 1)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
return SCP_SERVER_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size < 12)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
return SCP_SERVER_STATE_SIZE_ERR;
}
@@ -573,14 +573,14 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
init_stream(c->in_s, c->in_s->size);
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != SCP_COMMAND_SET_DEFAULT)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
@@ -603,7 +603,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
/* if we got here, the requested sid wasn't one from the list we sent */
/* we should kill the connection */
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (no such session in list)", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (no such session in list)", __LINE__);
return SCP_CLIENT_STATE_INTERNAL_ERR;
}
else if (cmd == 44)
@@ -619,7 +619,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
else
{
/* wrong response */
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
@@ -656,7 +656,7 @@ scp_v1s_reconnect_session(struct SCP_CONNECTION* c, SCP_DISPLAY d)
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, size))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
diff --git a/sesman/libscp/libscp_v1s_mng.c b/sesman/libscp/libscp_v1s_mng.c
index 266c9962..599545ab 100644
--- a/sesman/libscp/libscp_v1s_mng.c
+++ b/sesman/libscp/libscp_v1s_mng.c
@@ -30,7 +30,7 @@
#include "libscp_v1s_mng.h"
-extern struct log_config* s_log;
+//extern struct log_config* s_log;
static enum SCP_SERVER_STATES_E
_scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
@@ -259,7 +259,7 @@ scp_v1s_mng_list_sessions(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, size))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
}
@@ -279,14 +279,14 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
init_stream(c->in_s, c->in_s->size);
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version != 1)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: version error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: version error", __LINE__);
return SCP_SERVER_STATE_VERSION_ERR;
}
@@ -296,21 +296,21 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
/* read the rest of the packet */
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__);
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != SCP_COMMAND_SET_MANAGE)
{
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd == SCP_CMD_MNG_LIST_REQ) /* request session list */
{
- log_message(s_log, LOG_LEVEL_INFO, "[v1s_mng:%d] request session list", __LINE__);
+ log_message(LOG_LEVEL_INFO, "[v1s_mng:%d] request session list", __LINE__);
return SCP_SERVER_STATE_MNG_LISTREQ;
}
else if (cmd == SCP_CMD_MNG_ACTION) /* execute an action */
@@ -320,7 +320,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
in_uint8a(c->in_s, buf, dim);
scp_session_set_errstr(s, buf);*/
- log_message(s_log, LOG_LEVEL_INFO, "[v1s_mng:%d] action request", __LINE__);
+ log_message(LOG_LEVEL_INFO, "[v1s_mng:%d] action request", __LINE__);
return SCP_SERVER_STATE_MNG_ACTION;
}
/* else if (cmd == 20) / * password change * /
@@ -334,7 +334,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
return SCP_SERVER_STATE_SESSION_LIST;
}*/
- log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: sequence error", __LINE__);
+ log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: sequence error", __LINE__);
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
diff --git a/sesman/lock.c b/sesman/lock.c
index d5a91af6..83023cba 100644
--- a/sesman/lock.c
+++ b/sesman/lock.c
@@ -55,7 +55,7 @@ void APP_CC
lock_chain_acquire(void)
{
/* lock the chain */
- LOG_DBG(&(g_cfg->log), "lock_chain_acquire()");
+ LOG_DBG("lock_chain_acquire()");
tc_mutex_lock(g_lock_chain);
}
@@ -64,7 +64,7 @@ void APP_CC
lock_chain_release(void)
{
/* unlock the chain */
- LOG_DBG(&(g_cfg->log), "lock_chain_release()");
+ LOG_DBG("lock_chain_release()");
tc_mutex_unlock(g_lock_chain);
}
@@ -73,7 +73,7 @@ void APP_CC
lock_socket_acquire(void)
{
/* lock socket variable */
- LOG_DBG(&(g_cfg->log), "lock_socket_acquire()");
+ LOG_DBG("lock_socket_acquire()");
tc_sem_dec(g_lock_socket);
}
@@ -82,7 +82,7 @@ void APP_CC
lock_socket_release(void)
{
/* unlock socket variable */
- LOG_DBG(&(g_cfg->log), "lock_socket_release()");
+ LOG_DBG("lock_socket_release()");
tc_sem_inc(g_lock_socket);
}
@@ -91,7 +91,7 @@ void APP_CC
lock_sync_acquire(void)
{
/* lock sync variable */
- LOG_DBG(&(g_cfg->log), "lock_sync_acquire()");
+ LOG_DBG("lock_sync_acquire()");
tc_mutex_lock(g_sync_mutex);
}
@@ -100,7 +100,7 @@ void APP_CC
lock_sync_release(void)
{
/* unlock socket variable */
- LOG_DBG(&(g_cfg->log), "lock_sync_release()");
+ LOG_DBG("lock_sync_release()");
tc_mutex_unlock(g_sync_mutex);
}
@@ -109,7 +109,7 @@ void APP_CC
lock_sync_sem_acquire(void)
{
/* dec sem */
- LOG_DBG(&(g_cfg->log), "lock_sync_sem_acquire()");
+ LOG_DBG("lock_sync_sem_acquire()");
tc_sem_dec(g_sync_sem);
}
@@ -118,6 +118,6 @@ void APP_CC
lock_sync_sem_release(void)
{
/* inc sem */
- LOG_DBG(&(g_cfg->log), "lock_sync_sem_release()");
+ LOG_DBG("lock_sync_sem_release()");
tc_sem_inc(g_sync_sem);
}
diff --git a/sesman/scp.c b/sesman/scp.c
index 439c046c..bbe495ea 100644
--- a/sesman/scp.c
+++ b/sesman/scp.c
@@ -43,7 +43,7 @@ scp_process_start(void* sck)
/* making a local copy of the socket (it's on the stack) */
/* probably this is just paranoia */
scon.in_sck = g_thread_sck;
- LOG_DBG(&(g_cfg->log), "started scp thread on socket %d", scon.in_sck);
+ LOG_DBG("started scp thread on socket %d", scon.in_sck);
/* unlocking g_thread_sck */
lock_socket_release();
@@ -60,40 +60,40 @@ scp_process_start(void* sck)
if (sdata->version == 0)
{
/* starts processing an scp v0 connection */
- LOG_DBG(&(g_cfg->log), "accept ok, go on with scp v0\n",0);
+ LOG_DBG("accept ok, go on with scp v0\n",0);
scp_v0_process(&scon, sdata);
}
else
{
- LOG_DBG(&(g_cfg->log), "accept ok, go on with scp v1\n",0);
- /*LOG_DBG(&(g_cfg->log), "user: %s\npass: %s",sdata->username, sdata->password);*/
+ LOG_DBG("accept ok, go on with scp v1\n",0);
+ /*LOG_DBG("user: %s\npass: %s",sdata->username, sdata->password);*/
scp_v1_process(&scon, sdata);
}
break;
case SCP_SERVER_STATE_START_MANAGE:
/* starting a management session */
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING,
+ log_message(LOG_LEVEL_WARNING,
"starting a sesman management session...");
scp_v1_mng_process(&scon, sdata);
break;
case SCP_SERVER_STATE_VERSION_ERR:
/* an unknown scp version was requested, so we shut down the */
/* connection (and log the fact) */
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING,
+ log_message(LOG_LEVEL_WARNING,
"unknown protocol version specified. connection refused.");
break;
case SCP_SERVER_STATE_NETWORK_ERR:
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp network error.");
+ log_message(LOG_LEVEL_WARNING, "libscp network error.");
break;
case SCP_SERVER_STATE_SEQUENCE_ERR:
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp sequence error.");
+ log_message(LOG_LEVEL_WARNING, "libscp sequence error.");
break;
case SCP_SERVER_STATE_INTERNAL_ERR:
/* internal error occurred (eg. malloc() error, ecc.) */
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "libscp internal error occurred.");
+ log_message(LOG_LEVEL_ERROR, "libscp internal error occurred.");
break;
default:
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "unknown return from scp_vXs_accept()");
+ log_message(LOG_LEVEL_ALWAYS, "unknown return from scp_vXs_accept()");
}
g_tcp_close(scon.in_sck);
free_stream(scon.in_s);
diff --git a/sesman/scp_v0.c b/sesman/scp_v0.c
index 0b4dc791..e36aeaf6 100644
--- a/sesman/scp_v0.c
+++ b/sesman/scp_v0.c
@@ -47,39 +47,39 @@ scp_v0_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
display = s_item->display;
if (0 != s->client_ip)
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, s_item->pid, s->client_ip);
+ log_message( LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, s_item->pid, s->client_ip);
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d", s->username, display, s_item->pid);
+ log_message(LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d", s->username, display, s_item->pid);
}
auth_end(data);
/* don't set data to null here */
}
else
{
- LOG_DBG(&(g_cfg->log), "pre auth");
+ LOG_DBG("pre auth");
if (1 == access_login_allowed(s->username))
{
if (0 != s->client_ip)
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ created session (access granted): username %s, ip %s", s->username, s->client_ip);
+ log_message(LOG_LEVEL_INFO, "++ created session (access granted): username %s, ip %s", s->username, s->client_ip);
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ created session (access granted): username %s", s->username);
+ log_message(LOG_LEVEL_INFO, "++ created session (access granted): username %s", s->username);
}
if (SCP_SESSION_TYPE_XVNC == s->type)
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting Xvnc session...");
+ log_message( LOG_LEVEL_INFO, "starting Xvnc session...");
display = session_start(s->width, s->height, s->bpp, s->username,
s->password, data, SESMAN_SESSION_TYPE_XVNC,
s->domain, s->program, s->directory, s->client_ip);
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting X11rdp session...");
+ log_message(LOG_LEVEL_INFO, "starting X11rdp session...");
display = session_start(s->width, s->height, s->bpp, s->username,
s->password, data, SESMAN_SESSION_TYPE_XRDP,
s->domain, s->program, s->directory, s->client_ip);
diff --git a/sesman/scp_v1.c b/sesman/scp_v1.c
index 5c303bb2..d1509224 100644
--- a/sesman/scp_v1.c
+++ b/sesman/scp_v1.c
@@ -56,7 +56,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
while ((!data) && ((retries == 0) || (current_try > 0)))
{
- LOG_DBG(&(g_cfg->log), "data %d - retry %d - currenttry %d - expr %d", data, retries, current_try, ((!data) && ((retries==0) || (current_try>0))));
+ LOG_DBG("data %d - retry %d - currenttry %d - expr %d", data, retries, current_try, ((!data) && ((retries==0) || (current_try>0))));
e=scp_v1s_request_password(c,s,"Wrong username and/or password");
@@ -83,7 +83,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
if (!data)
{
scp_v1s_deny_connection(c, "Login failed");
- log_message(&(g_cfg->log), LOG_LEVEL_INFO,
+ log_message( LOG_LEVEL_INFO,
"Login failed for user %s. Connection terminated", s->username);
scp_session_destroy(s);
return;
@@ -93,7 +93,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
if (0 == access_login_allowed(s->username))
{
scp_v1s_deny_connection(c, "Access to Terminal Server not allowed.");
- log_message(&(g_cfg->log), LOG_LEVEL_INFO,
+ log_message(LOG_LEVEL_INFO,
"User %s not allowed on TS. Connection terminated", s->username);
scp_session_destroy(s);
return;
@@ -107,24 +107,26 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
if (scount == 0)
{
/* no disconnected sessions - start a new one */
+ log_message(LOG_LEVEL_DEBUG,"No disconnected sessions for this user"
+ "- we create a new one");
if (0 != s->client_ip)
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ created session (access granted): username %s, ip %s", s->username, s->client_ip);
+ log_message(LOG_LEVEL_INFO, "++ created session (access granted): username %s, ip %s", s->username, s->client_ip);
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ created session (access granted): username %s", s->username);
+ log_message(LOG_LEVEL_INFO, "++ created session (access granted): username %s", s->username);
}
if (SCP_SESSION_TYPE_XVNC == s->type)
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting Xvnc session...");
+ log_message(LOG_LEVEL_INFO, "starting Xvnc session...");
display = session_start(s->width, s->height, s->bpp, s->username,
s->password, data, SESMAN_SESSION_TYPE_XVNC,
s->domain, s->program, s->directory, s->client_ip);
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting X11rdp session...");
+ log_message(LOG_LEVEL_INFO, "starting X11rdp session...");
display = session_start(s->width, s->height, s->bpp, s->username,
s->password, data, SESMAN_SESSION_TYPE_XRDP,
s->domain, s->program, s->directory, s->client_ip);
@@ -152,7 +154,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
/*case SCP_SERVER_STATE_FORCE_NEW:*/
/* we should check for MaxSessions */
case SCP_SERVER_STATE_SELECTION_CANCEL:
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "Connection cancelled after session listing");
+ log_message( LOG_LEVEL_INFO, "Connection cancelled after session listing");
break;
case SCP_SERVER_STATE_OK:
/* ok, reconnecting... */
@@ -160,7 +162,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
if (0==sitem)
{
e=scp_v1s_connection_error(c, "Internal error");
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "Cannot find session item on the chain");
+ log_message(LOG_LEVEL_INFO, "Cannot find session item on the chain");
}
else
{
@@ -169,11 +171,11 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
e=scp_v1s_reconnect_session(c, display);
if (0 != s->client_ip)
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, sitem->pid, s->client_ip);
+ log_message(LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, sitem->pid, s->client_ip);
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d", s->username, display, sitem->pid);
+ log_message(LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d", s->username, display, sitem->pid);
}
g_free(sitem);
}
@@ -202,27 +204,27 @@ static void parseCommonStates(enum SCP_SERVER_STATES_E e, char* f)
switch (e)
{
case SCP_SERVER_STATE_VERSION_ERR:
- LOG_DBG(&(g_cfg->log), "version error")
+ LOG_DBG("version error")
case SCP_SERVER_STATE_SIZE_ERR:
/* an unknown scp version was requested, so we shut down the */
/* connection (and log the fact) */
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING,
+ log_message(LOG_LEVEL_WARNING,
"protocol violation. connection closed.");
break;
case SCP_SERVER_STATE_NETWORK_ERR:
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp network error.");
+ log_message(LOG_LEVEL_WARNING, "libscp network error.");
break;
case SCP_SERVER_STATE_SEQUENCE_ERR:
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp sequence error.");
+ log_message(LOG_LEVEL_WARNING, "libscp sequence error.");
break;
case SCP_SERVER_STATE_INTERNAL_ERR:
/* internal error occurred (eg. malloc() error, ecc.) */
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "libscp internal error occurred.");
+ log_message(LOG_LEVEL_ERROR, "libscp internal error occurred.");
break;
default:
/* dummy: scp_v1s_request_password won't generate any other */
/* error other than the ones before */
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "unknown return from %s", f);
+ log_message(LOG_LEVEL_ALWAYS, "unknown return from %s", f);
break;
}
}
diff --git a/sesman/scp_v1_mng.c b/sesman/scp_v1_mng.c
index a1773225..e4d97b77 100644
--- a/sesman/scp_v1_mng.c
+++ b/sesman/scp_v1_mng.c
@@ -49,7 +49,7 @@ scp_v1_mng_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
if (!data)
{
scp_v1s_mng_deny_connection(c, "Login failed");
- log_message(&(g_cfg->log), LOG_LEVEL_INFO,
+ log_message(LOG_LEVEL_INFO,
"[MNG] Login failed for user %s. Connection terminated", s->username);
scp_session_destroy(s);
auth_end(data);
@@ -60,7 +60,7 @@ scp_v1_mng_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
if (0 == access_login_mng_allowed(s->username))
{
scp_v1s_mng_deny_connection(c, "Access to Terminal Server not allowed.");
- log_message(&(g_cfg->log), LOG_LEVEL_INFO,
+ log_message(LOG_LEVEL_INFO,
"[MNG] User %s not allowed on TS. Connection terminated", s->username);
scp_session_destroy(s);
auth_end(data);
@@ -75,18 +75,18 @@ scp_v1_mng_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
switch (e)
{
case SCP_SERVER_STATE_MNG_ACTION:
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "Connection cancelled after session listing");
+ log_message(LOG_LEVEL_INFO, "Connection cancelled after session listing");
break;
case SCP_SERVER_STATE_MNG_LISTREQ:
/* list disconnected sessions */
slist = session_get_byuser(NULL, &scount, SESMAN_SESSION_STATUS_ALL);
- LOG_DBG(&(g_cfg->log), "sessions on TS: %d (slist: %x)", scount, slist);
+ LOG_DBG("sessions on TS: %d (slist: %x)", scount, slist);
if (0 == slist)
{
// e=scp_v1s_connection_error(c, "Internal error");
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "No sessions on Terminal Server");
+ log_message(LOG_LEVEL_INFO, "No sessions on Terminal Server");
end = 0;
}
else
@@ -114,27 +114,27 @@ static void parseCommonStates(enum SCP_SERVER_STATES_E e, char* f)
switch (e)
{
case SCP_SERVER_STATE_VERSION_ERR:
- LOG_DBG(&(g_cfg->log), "version error")
+ LOG_DBG("version error")
case SCP_SERVER_STATE_SIZE_ERR:
/* an unknown scp version was requested, so we shut down the */
/* connection (and log the fact) */
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING,
+ log_message(LOG_LEVEL_WARNING,
"protocol violation. connection closed.");
break;
case SCP_SERVER_STATE_NETWORK_ERR:
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp network error.");
+ log_message(LOG_LEVEL_WARNING, "libscp network error.");
break;
case SCP_SERVER_STATE_SEQUENCE_ERR:
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp sequence error.");
+ log_message(LOG_LEVEL_WARNING, "libscp sequence error.");
break;
case SCP_SERVER_STATE_INTERNAL_ERR:
/* internal error occurred (eg. malloc() error, ecc.) */
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "libscp internal error occurred.");
+ log_message(LOG_LEVEL_ERROR, "libscp internal error occurred.");
break;
default:
/* dummy: scp_v1s_request_password won't generate any other */
/* error other than the ones before */
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "unknown return from %s", f);
+ log_message(LOG_LEVEL_ALWAYS, "unknown return from %s", f);
break;
}
}
diff --git a/sesman/sesman.c b/sesman/sesman.c
index 5a230417..1d60626c 100644
--- a/sesman/sesman.c
+++ b/sesman/sesman.c
@@ -54,7 +54,7 @@ sesman_main_loop(void)
tbus robjs[8];
/*main program loop*/
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "listening...");
+ log_message(LOG_LEVEL_INFO, "listening...");
g_sck = g_tcp_socket();
g_tcp_set_non_blocking(g_sck);
error = scp_tcp_bind(g_sck, g_cfg->listen_address, g_cfg->listen_port);
@@ -103,7 +103,7 @@ sesman_main_loop(void)
else
{
/* we've got a connection, so we pass it to scp code */
- LOG_DBG(&(g_cfg->log), "new connection");
+ LOG_DBG("new connection");
thread_scp_start(in_sck);
/* todo, do we have to wait here ? */
}
@@ -113,13 +113,13 @@ sesman_main_loop(void)
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "listen error %d (%s)",
+ log_message(LOG_LEVEL_ERROR, "listen error %d (%s)",
g_get_errno(), g_get_strerror());
}
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "bind error on "
+ log_message(LOG_LEVEL_ERROR, "bind error on "
"port '%s': %d (%s)", g_cfg->listen_port,
g_get_errno(), g_get_strerror());
}
@@ -131,12 +131,13 @@ int DEFAULT_CC
main(int argc, char** argv)
{
int fd;
- int error;
+ enum logReturns error;
int daemon = 1;
int pid;
char pid_s[8];
char text[256];
char pid_file[256];
+ char cfg_file[256];
g_init("xrdp-sesman");
g_snprintf(pid_file, 255, "%s/xrdp-sesman.pid", XRDP_PID_PATH);
@@ -242,7 +243,7 @@ main(int argc, char** argv)
g_deinit();
g_exit(1);
}
- g_cfg->log.fd = -1; /* don't use logging before reading its config */
+ //g_cfg->log.fd = -1; /* don't use logging before reading its config */
if (0 != config_read(g_cfg))
{
g_printf("error reading config: %s\nquitting.\n", g_get_strerror());
@@ -250,18 +251,21 @@ main(int argc, char** argv)
g_exit(1);
}
+ g_snprintf(cfg_file,255,"%s/sesman.ini",XRDP_CFG_PATH);
+
/* starting logging subsystem */
- error = log_start(&(g_cfg->log));
+ 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");
break;
case LOG_ERROR_FILE_OPEN:
- g_printf("error opening log file [%s]. quitting.\n", g_cfg->log.log_file);
+ g_printf("error opening log file [%s]. quitting.\n", getLogFile(buf,255));
break;
}
g_deinit();
@@ -269,7 +273,7 @@ main(int argc, char** argv)
}
/* libscp initialization */
- scp_init(&(g_cfg->log));
+ scp_init();
if (daemon)
{
@@ -317,10 +321,10 @@ main(int argc, char** argv)
fd = g_file_open(pid_file);
if (-1 == fd)
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR,
+ log_message(LOG_LEVEL_ERROR,
"error opening pid file[%s]: %s",
pid_file, g_get_strerror());
- log_end(&(g_cfg->log));
+ log_end();
g_deinit();
g_exit(1);
}
@@ -330,7 +334,7 @@ main(int argc, char** argv)
}
/* start program main loop */
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,
+ log_message(LOG_LEVEL_ALWAYS,
"starting sesman with pid %d", g_pid);
/* make sure the /tmp/.X11-unix directory exist */
@@ -358,7 +362,7 @@ main(int argc, char** argv)
if (!daemon)
{
- log_end(&(g_cfg->log));
+ log_end();
}
g_deinit();
diff --git a/sesman/sesman.ini b/sesman/sesman.ini
index 9aa58581..88252a18 100644
--- a/sesman/sesman.ini
+++ b/sesman/sesman.ini
@@ -21,7 +21,7 @@ DisconnectedTimeLimit=0
[Logging]
LogFile=/var/log/xrdp-sesman.log
LogLevel=DEBUG
-EnableSyslog=0
+EnableSyslog=1
SyslogLevel=DEBUG
[X11rdp]
diff --git a/sesman/session.c b/sesman/session.c
index 2960a7f7..1557f2da 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -50,6 +50,39 @@ static tbus g_sync_data;
static tui8 g_sync_type;
static int g_sync_result;
+/**
+ * Creates a string consisting of all parameters that is hosted in the param list
+ * @param self
+ * @param outstr, allocate this buffer before you use this function
+ * @param len the allocated len for outstr
+ * @return
+ */
+char* APP_CC
+dumpItemsToString(struct list* self, char *outstr, int len)
+{
+ g_memset(outstr,0,len);
+ int index;
+ tbus item;
+ int totalLen= 0;
+
+ if (self->count == 0)
+ {
+ g_writeln("List is empty");
+ }
+ for (index = 0; index < self->count; index++)
+ {
+ /* +1 = one space*/
+ totalLen = totalLen + g_strlen((char*)list_get_item(self, index))+1;
+ if(len>totalLen)
+ {
+ g_strcat(outstr,(char*)list_get_item(self, index));
+ g_strcat(outstr," ");
+ }
+ }
+ return outstr ;
+}
+
+
/******************************************************************************/
struct session_item* DEFAULT_CC
session_get_bydata(char* name, int width, int height, int bpp, int type)
@@ -196,7 +229,7 @@ session_start_sessvc(int xpid, int wmpid, long data)
/* new style waiting for clients */
g_sprintf(wmpid_str, "%d", wmpid);
g_sprintf(xpid_str, "%d", xpid);
- log_message(&(g_cfg->log), LOG_LEVEL_INFO,
+ log_message(LOG_LEVEL_INFO,
"starting xrdp-sessvc - xpid=%s - wmpid=%s",
xpid_str, wmpid_str);
@@ -215,19 +248,19 @@ session_start_sessvc(int xpid, int wmpid, long data)
g_execvp(exe_path, ((char**)sessvc_params->items));
/* should not get here */
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,
+ log_message(LOG_LEVEL_ALWAYS,
"error starting xrdp-sessvc - pid %d - xpid=%s - wmpid=%s",
g_getpid(), xpid_str, wmpid_str);
/* logging parameters */
/* no problem calling strerror for thread safety: other threads
are blocked */
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "errno: %d, description: %s",
+ log_message(LOG_LEVEL_DEBUG, "errno: %d, description: %s",
errno, g_get_strerror());
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "execve parameter list:");
+ log_message(LOG_LEVEL_DEBUG, "execve parameter list:");
for (i = 0; i < (sessvc_params->count); i++)
{
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[%d] = %s", i,
+ log_message(LOG_LEVEL_DEBUG, " argv[%d] = %s", i,
(char*)list_get_item(sessvc_params, i));
}
list_delete(sessvc_params);
@@ -285,7 +318,7 @@ session_get_aval_display_from_chain(void)
display++;
}
lock_chain_release();
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "X server -- no display in range is available");
+ log_message(LOG_LEVEL_ERROR, "X server -- no display in range is available");
return 0;
}
@@ -303,7 +336,7 @@ wait_for_xserver(int display)
i++;
if (i > 40)
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR,
+ log_message(LOG_LEVEL_ERROR,
"X server for display %d startup timeout",
display);
break;
@@ -335,6 +368,7 @@ session_start_fork(int width, int height, int bpp, char* username,
struct list * xserver_params = (struct list *)NULL;
time_t ltime;
struct tm stime;
+ char execvpparams[2048];
/* initialize (zero out) local variables: */
g_memset(&ltime,0,sizeof(time_t));
@@ -348,7 +382,7 @@ session_start_fork(int width, int height, int bpp, char* username,
/* check to limit concurrent sessions */
if (g_session_count >= g_cfg->sess.max_sessions)
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "max concurrent session limit "
+ log_message(LOG_LEVEL_INFO, "max concurrent session limit "
"exceeded. login for user %s denied", username);
return 0;
}
@@ -356,7 +390,7 @@ session_start_fork(int width, int height, int bpp, char* username,
temp = (struct session_chain*)g_malloc(sizeof(struct session_chain), 0);
if (temp == 0)
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "cannot create new chain "
+ log_message(LOG_LEVEL_ERROR, "cannot create new chain "
"element - user %s", username);
return 0;
}
@@ -364,7 +398,7 @@ session_start_fork(int width, int height, int bpp, char* username,
if (temp->item == 0)
{
g_free(temp);
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "cannot create new session "
+ log_message(LOG_LEVEL_ERROR, "cannot create new session "
"item - user %s", username);
return 0;
}
@@ -408,7 +442,7 @@ session_start_fork(int width, int height, int bpp, char* username,
if (program[0] != 0)
{
g_execlp3(program, program, 0);
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,
+ log_message(LOG_LEVEL_ALWAYS,
"error starting program %s for user %s - pid %d",
program, username, g_getpid());
}
@@ -420,16 +454,16 @@ session_start_fork(int width, int height, int bpp, char* username,
if (g_file_exist(text))
{
g_execlp3(text, g_cfg->user_wm, 0);
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,"error starting user "
+ log_message(LOG_LEVEL_ALWAYS,"error starting user "
"wm for user %s - pid %d", username, g_getpid());
/* logging parameters */
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "errno: %d, "
+ log_message(LOG_LEVEL_DEBUG, "errno: %d, "
"description: %s", errno, g_get_strerror());
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG,"execlp3 parameter "
+ log_message(LOG_LEVEL_DEBUG,"execlp3 parameter "
"list:");
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[0] = %s",
+ log_message(LOG_LEVEL_DEBUG, " argv[0] = %s",
text);
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[1] = %s",
+ log_message(LOG_LEVEL_DEBUG, " argv[1] = %s",
g_cfg->user_wm);
}
}
@@ -438,33 +472,33 @@ session_start_fork(int width, int height, int bpp, char* username,
g_sprintf(text, "%s/%s", XRDP_CFG_PATH, g_cfg->default_wm);
g_execlp3(text, g_cfg->default_wm, 0);
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,"error starting default "
+ log_message( LOG_LEVEL_ALWAYS,"error starting default "
"wm for user %s - pid %d", username, g_getpid());
/* logging parameters */
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "errno: %d, description: "
+ log_message( LOG_LEVEL_DEBUG, "errno: %d, description: "
"%s", errno, g_get_strerror());
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG,"execlp3 parameter list:");
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[0] = %s",
+ log_message(LOG_LEVEL_DEBUG,"execlp3 parameter list:");
+ log_message(LOG_LEVEL_DEBUG, " argv[0] = %s",
text);
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[1] = %s",
+ log_message(LOG_LEVEL_DEBUG, " argv[1] = %s",
g_cfg->default_wm);
/* still a problem starting window manager just start xterm */
g_execlp3("xterm", "xterm", 0);
/* should not get here */
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,"error starting xterm "
+ log_message(LOG_LEVEL_ALWAYS,"error starting xterm "
"for user %s - pid %d", username, g_getpid());
/* logging parameters */
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "errno: %d, description: "
+ log_message(LOG_LEVEL_DEBUG, "errno: %d, description: "
"%s", errno, g_get_strerror());
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "another Xserver is "
- "already active on display %d", display);
+ log_message(LOG_LEVEL_ERROR, "another Xserver might "
+ "already be active on display %d - see log", display);
}
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG,"aborting connection...");
+ log_message(LOG_LEVEL_DEBUG,"aborting connection...");
g_exit(0);
}
else /* parent (child sesman) */
@@ -499,6 +533,7 @@ session_start_fork(int width, int height, int bpp, char* username,
/* make sure it ends with a zero */
list_add_item(xserver_params, 0);
pp1 = (char**)xserver_params->items;
+ log_message(LOG_LEVEL_INFO,"Xvnc start:%s",dumpItemsToString(xserver_params, execvpparams, 2048));
g_execvp("Xvnc", pp1);
}
else if (type == SESMAN_SESSION_TYPE_XRDP)
@@ -521,28 +556,29 @@ session_start_fork(int width, int height, int bpp, char* username,
/* make sure it ends with a zero */
list_add_item(xserver_params, 0);
pp1 = (char**)xserver_params->items;
+ log_message(LOG_LEVEL_INFO,"X11rdp start:%s",dumpItemsToString(xserver_params, execvpparams, 2048));
g_execvp("X11rdp", pp1);
}
else
{
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "bad session type - "
+ log_message(LOG_LEVEL_ALWAYS, "bad session type - "
"user %s - pid %d", username, g_getpid());
g_exit(1);
}
/* should not get here */
- log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "error starting X server "
+ log_message(LOG_LEVEL_ALWAYS, "error starting X server "
"- user %s - pid %d", username, g_getpid());
/* logging parameters */
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "errno: %d, description: "
+ log_message(LOG_LEVEL_DEBUG, "errno: %d, description: "
"%s", errno, g_get_strerror());
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "execve parameter list: "
+ log_message(LOG_LEVEL_DEBUG, "execve parameter list size: "
"%d", (xserver_params)->count);
for (i=0; i<(xserver_params->count); i++)
{
- log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[%d] = %s",
+ log_message(LOG_LEVEL_DEBUG, " argv[%d] = %s",
i, (char*)list_get_item(xserver_params, i));
}
list_delete(xserver_params);
@@ -656,7 +692,7 @@ session_kill(int pid)
{
if (tmp->item == 0)
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "session descriptor for "
+ log_message(LOG_LEVEL_ERROR, "session descriptor for "
"pid %d is null!", pid);
if (prev == 0)
{
@@ -676,7 +712,7 @@ session_kill(int pid)
if (tmp->item->pid == pid)
{
/* deleting the session */
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ terminated session: username %s, display :%d.0, session_pid %d, ip %s", tmp->item->name, tmp->item->display, tmp->item->pid, tmp->item->client_ip);
+ log_message(LOG_LEVEL_INFO, "++ terminated session: username %s, display :%d.0, session_pid %d, ip %s", tmp->item->name, tmp->item->display, tmp->item->pid, tmp->item->client_ip);
g_free(tmp->item);
if (prev == 0)
{
@@ -720,7 +756,7 @@ session_sigkill_all()
{
if (tmp->item == 0)
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "found null session "
+ log_message(LOG_LEVEL_ERROR, "found null session "
"descriptor!");
}
else
@@ -746,7 +782,7 @@ session_get_bypid(int pid)
dummy = g_malloc(sizeof(struct session_item), 1);
if (0 == dummy)
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "internal error", pid);
+ log_message(LOG_LEVEL_ERROR, "internal error", pid);
return 0;
}
@@ -758,7 +794,7 @@ session_get_bypid(int pid)
{
if (tmp->item == 0)
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "session descriptor for "
+ log_message(LOG_LEVEL_ERROR, "session descriptor for "
"pid %d is null!", pid);
/*THREAD-FIX release chain lock */
lock_chain_release();
@@ -800,10 +836,10 @@ session_get_byuser(char* user, int* cnt, unsigned char flags)
tmp = g_sessions;
while (tmp != 0)
{
- LOG_DBG(&(g_cfg->log), "user: %s", user);
+ LOG_DBG("user: %s", user);
if ((NULL == user) || (!g_strncasecmp(user, tmp->item->name, 256)))
{
- LOG_DBG(&(g_cfg->log), "session_get_byuser: status=%d, flags=%d, "
+ LOG_DBG("session_get_byuser: status=%d, flags=%d, "
"result=%d", (tmp->item->status), flags,
((tmp->item->status) & flags));
if ((tmp->item->status) & flags)
diff --git a/sesman/sig.c b/sesman/sig.c
index 24f2e81c..151c0c57 100644
--- a/sesman/sig.c
+++ b/sesman/sig.c
@@ -40,15 +40,15 @@ sig_sesman_shutdown(int sig)
{
char pid_file[256];
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "shutting down sesman %d", 1);
+ log_message(LOG_LEVEL_INFO, "shutting down sesman %d", 1);
if (g_getpid() != g_pid)
{
- LOG_DBG(&(g_cfg->log), "g_getpid() [%d] differs from g_pid [%d]", (g_getpid()), g_pid);
+ LOG_DBG("g_getpid() [%d] differs from g_pid [%d]", (g_getpid()), g_pid);
return;
}
- LOG_DBG(&(g_cfg->log), " - getting signal %d pid %d", sig, g_getpid());
+ LOG_DBG(" - getting signal %d pid %d", sig, g_getpid());
g_set_wait_obj(g_term_event);
@@ -66,51 +66,55 @@ sig_sesman_reload_cfg(int sig)
{
int error;
struct config_sesman *cfg;
+ char cfg_file[256];
- log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "receiving SIGHUP %d", 1);
+ log_message(LOG_LEVEL_WARNING, "receiving SIGHUP %d", 1);
if (g_getpid() != g_pid)
{
- LOG_DBG(&(g_cfg->log), "g_getpid() [%d] differs from g_pid [%d]", g_getpid(), g_pid);
+ LOG_DBG("g_getpid() [%d] differs from g_pid [%d]", g_getpid(), g_pid);
return;
}
cfg = g_malloc(sizeof(struct config_sesman), 1);
if (0 == cfg)
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "error creating new config: - keeping old cfg");
+ log_message(LOG_LEVEL_ERROR, "error creating new config: - keeping old cfg");
return;
}
if (config_read(cfg) != 0)
{
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "error reading config - keeping old cfg");
+ log_message(LOG_LEVEL_ERROR, "error reading config - keeping old cfg");
return;
}
/* stop logging subsystem */
- log_end(&(g_cfg->log));
+ log_end();
/* replace old config with new readed one */
g_cfg = cfg;
+
+ g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);
/* start again logging subsystem */
- error = log_start(&(g_cfg->log));
+ 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 restart logging. log stops here, sorry.\n");
break;
case LOG_ERROR_FILE_OPEN:
- g_printf("error reopening log file [%s]. log stops here, sorry.\n", g_cfg->log.log_file);
+ g_printf("error reopening log file [%s]. log stops here, sorry.\n", getLogFile(buf,255));
break;
}
}
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "configuration reloaded, log subsystem restarted");
+ log_message(LOG_LEVEL_INFO, "configuration reloaded, log subsystem restarted");
}
/******************************************************************************/
@@ -166,27 +170,27 @@ sig_handler_thread(void* arg)
case SIGHUP:
//reload cfg
//we must stop & restart logging, or copy logging cfg!!!!
- LOG_DBG(&(g_cfg->log), "sesman received SIGHUP", 0);
+ LOG_DBG("sesman received SIGHUP", 0);
//return 0;
break;
case SIGCHLD:
/* a session died */
- LOG_DBG(&(g_cfg->log), "sesman received SIGCHLD", 0);
+ LOG_DBG("sesman received SIGCHLD", 0);
sig_sesman_session_end(SIGCHLD);
break;
case SIGINT:
/* we die */
- LOG_DBG(&(g_cfg->log), "sesman received SIGINT", 0);
+ LOG_DBG("sesman received SIGINT", 0);
sig_sesman_shutdown(recv_signal);
break;
case SIGKILL:
/* we die */
- LOG_DBG(&(g_cfg->log), "sesman received SIGKILL", 0);
+ LOG_DBG("sesman received SIGKILL", 0);
sig_sesman_shutdown(recv_signal);
break;
case SIGTERM:
/* we die */
- LOG_DBG(&(g_cfg->log), "sesman received SIGTERM", 0);
+ LOG_DBG("sesman received SIGTERM", 0);
sig_sesman_shutdown(recv_signal);
break;
}
diff --git a/sesman/thread.c b/sesman/thread.c
index 986a5d27..4c266637 100644
--- a/sesman/thread.c
+++ b/sesman/thread.c
@@ -62,14 +62,14 @@ thread_sighandler_start(void)
sigaddset(&waitmask, SIGFPE);
pthread_sigmask(SIG_UNBLOCK, &waitmask, NULL);
- log_message(&(g_cfg->log), LOG_LEVEL_INFO,"starting signal handling thread...");
+ log_message(LOG_LEVEL_INFO,"starting signal handling thread...");
ret = pthread_create(&g_thread_sighandler, NULL, sig_handler_thread, "");
pthread_detach(g_thread_sighandler);
if (ret == 0)
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "signal handler thread started successfully");
+ log_message(LOG_LEVEL_INFO, "signal handler thread started successfully");
return 0;
}
@@ -77,16 +77,16 @@ thread_sighandler_start(void)
switch (ret)
{
case EINVAL:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid attributes for signal handling thread (creation returned EINVAL)");
+ log_message(LOG_LEVEL_ERROR, "invalid attributes for signal handling thread (creation returned EINVAL)");
break;
case EAGAIN:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "not enough resources to start signal handling thread (creation returned EAGAIN)");
+ log_message(LOG_LEVEL_ERROR, "not enough resources to start signal handling thread (creation returned EAGAIN)");
break;
case EPERM:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid permissions for signal handling thread (creation returned EPERM)");
+ log_message(LOG_LEVEL_ERROR, "invalid permissions for signal handling thread (creation returned EPERM)");
break;
default:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "unknown error starting signal handling thread");
+ log_message(LOG_LEVEL_ERROR, "unknown error starting signal handling thread");
}
return 1;
@@ -116,16 +116,16 @@ thread_session_update_start(void)
switch (ret)
{
case EINVAL:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid attributes for session update thread (creation returned EINVAL)");
+ log_message(LOG_LEVEL_ERROR, "invalid attributes for session update thread (creation returned EINVAL)");
break;
case EAGAIN:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "not enough resources to start session update thread (creation returned EAGAIN)");
+ log_message(LOG_LEVEL_ERROR, "not enough resources to start session update thread (creation returned EAGAIN)");
break;
case EPERM:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid permissions for session update thread (creation returned EPERM)");
+ log_message(LOG_LEVEL_ERROR, "invalid permissions for session update thread (creation returned EPERM)");
break;
default:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "unknown error starting session update thread");
+ log_message(LOG_LEVEL_ERROR, "unknown error starting session update thread");
}
return 1;
@@ -150,7 +150,7 @@ thread_scp_start(int skt)
if (ret == 0)
{
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "scp thread on sck %d started successfully", skt);
+ log_message(LOG_LEVEL_INFO, "scp thread on sck %d started successfully", skt);
return 0;
}
@@ -158,16 +158,16 @@ thread_scp_start(int skt)
switch (ret)
{
case EINVAL:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid attributes for scp thread on sck %d (creation returned EINVAL)", skt);
+ log_message(LOG_LEVEL_ERROR, "invalid attributes for scp thread on sck %d (creation returned EINVAL)", skt);
break;
case EAGAIN:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "not enough resources to start scp thread on sck %d (creation returned EAGAIN)", skt);
+ log_message(LOG_LEVEL_ERROR, "not enough resources to start scp thread on sck %d (creation returned EAGAIN)", skt);
break;
case EPERM:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid permissions for scp thread on sck %d (creation returned EPERM)", skt);
+ log_message(LOG_LEVEL_ERROR, "invalid permissions for scp thread on sck %d (creation returned EPERM)", skt);
break;
default:
- log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "unknown error starting scp thread on sck %d");
+ log_message(LOG_LEVEL_ERROR, "unknown error starting scp thread on sck %d");
}
return 1;
diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c
index 4c612316..7fac3d47 100644
--- a/sesman/tools/sesadmin.c
+++ b/sesman/tools/sesadmin.c
@@ -50,7 +50,7 @@ int main(int argc, char** argv)
logging.log_file = g_strdup("xrdp-sesadmin.log");
logging.log_level = LOG_LEVEL_DEBUG;
logging.enable_syslog = 0;
- log_start(&logging);
+ log_start_from_param(&logging);
for (idx = 0; idx < argc; idx++)
{
@@ -110,11 +110,11 @@ int main(int argc, char** argv)
s = scp_session_create();
c = scp_connection_create(sock);
- LOG_DBG(&logging, "Connecting to %s:%s with user %s (%s)\n", serv, port, user, pass);
+ LOG_DBG("Connecting to %s:%s with user %s (%s)\n", serv, port, user, pass);
if (0 != g_tcp_connect(sock, serv, port))
{
- LOG_DBG(&logging, "g_tcp_connect() error\n");
+ LOG_DBG("g_tcp_connect() error\n");
return 1;
}
@@ -127,7 +127,7 @@ int main(int argc, char** argv)
if (SCP_CLIENT_STATE_OK != e)
{
- LOG_DBG(&logging, "libscp error connecting: %s %d\n", s->errstr, (int)e);
+ LOG_DBG("libscp error connecting: %s %d\n", s->errstr, (int)e);
}
if (0 == g_strncmp(cmnd, "list", 5))
diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c
index 4382e160..1ba119e0 100644
--- a/sesman/tools/sestest.c
+++ b/sesman/tools/sestest.c
@@ -34,7 +34,7 @@ int main(int argc, char** argv)
log.log_level=99;
log.program_name=g_strdup("sestest");
log.log_file=g_strdup("sestest.log");
- log_start(&log);
+ log_start_from_param(&log);
scp_init(&log);
sock=g_tcp_socket();
diff --git a/sesman/verify_user.c b/sesman/verify_user.c
index cdc60b47..ffe1c04d 100644
--- a/sesman/verify_user.c
+++ b/sesman/verify_user.c
@@ -310,13 +310,13 @@ auth_account_disabled(struct spwd* stp)
today=g_time1()/SECS_PER_DAY;
- LOG_DBG(&(g_cfg->log), "last %d",stp->sp_lstchg);
- LOG_DBG(&(g_cfg->log), "min %d",stp->sp_min);
- LOG_DBG(&(g_cfg->log), "max %d",stp->sp_max);
- LOG_DBG(&(g_cfg->log), "inact %d",stp->sp_inact);
- LOG_DBG(&(g_cfg->log), "warn %d",stp->sp_warn);
- LOG_DBG(&(g_cfg->log), "expire %d",stp->sp_expire);
- LOG_DBG(&(g_cfg->log), "today %d",today);
+ LOG_DBG("last %d",stp->sp_lstchg);
+ LOG_DBG("min %d",stp->sp_min);
+ LOG_DBG("max %d",stp->sp_max);
+ LOG_DBG("inact %d",stp->sp_inact);
+ LOG_DBG("warn %d",stp->sp_warn);
+ LOG_DBG("expire %d",stp->sp_expire);
+ LOG_DBG("today %d",today);
if ((stp->sp_expire != -1) && (today >= stp->sp_expire))
{
diff --git a/vnc/vnc.c b/vnc/vnc.c
index e198b833..12c89a14 100644
--- a/vnc/vnc.c
+++ b/vnc/vnc.c
@@ -21,6 +21,7 @@
*/
#include "vnc.h"
+#include "log.h"
/******************************************************************************/
/* taken from vncauth.c */
@@ -63,6 +64,7 @@ lib_recv(struct vnc* v, char* data, int len)
}
else
{
+ log_message(LOG_LEVEL_DEBUG,"VNC lib_recv return 1");
return 1;
}
}
@@ -199,12 +201,16 @@ lib_process_channel_data(struct vnc* v, int chanid, int flags, int size,
length, 3);
free_stream(out_s);
break;
+ default:{
+ log_message(LOG_LEVEL_DEBUG,"VNC clip information unhandled");
+ break;
+ }
}
}
else
{
- g_writeln("lib_process_channel_data: unknown chanid %d v->clip_chanid %d",
- chanid, v->clip_chanid);
+ log_message(LOG_LEVEL_DEBUG,"lib_process_channel_data: unknown chanid:",
+ "%d :(v->clip_chanid) %d",chanid,v->clip_chanid);
}
return 0;
}
@@ -381,7 +387,7 @@ get_pixel_safe(char* data, int x, int y, int width, int height, int bpp)
}
else
{
- g_writeln("error in get_pixel_safe bpp %d", bpp);
+ log_message(LOG_LEVEL_ERROR,"error in get_pixel_safe bpp %d", bpp);
}
return 0;
}
@@ -436,7 +442,7 @@ set_pixel_safe(char* data, int x, int y, int width, int height, int bpp,
}
else
{
- g_writeln("error in set_pixel_safe bpp %d", bpp);
+ log_message(LOG_LEVEL_ERROR,"error in set_pixel_safe bpp %d", bpp);
}
}
@@ -473,7 +479,7 @@ split_color(int pixel, int* r, int* g, int* b, int bpp, int* palette)
}
else
{
- g_writeln("error in split_color bpp %d", bpp);
+ log_message(LOG_LEVEL_ERROR,"error in split_color bpp %d", bpp);
}
return 0;
}
@@ -488,7 +494,7 @@ make_color(int r, int g, int b, int bpp)
}
else
{
- g_writeln("error in make_color bpp %d", bpp);
+ log_message(LOG_LEVEL_ERROR,"error in make_color bpp %d", bpp);
}
return 0;
}
@@ -629,7 +635,7 @@ lib_framebuffer_update(struct vnc* v)
}
else
{
- g_sprintf(text, "error in lib_framebuffer_update encoding = %8.8x",
+ g_sprintf(text, "VNC error in lib_framebuffer_update encoding = %8.8x",
encoding);
v->server_msg(v, text, 1);
}
@@ -784,18 +790,18 @@ lib_mod_signal(struct vnc* v)
{
error = lib_palette_update(v);
}
- else if (type == 2) /* bell */
+ else if (type == 2) /* bell */
{
error = lib_bell_trigger(v);
}
else if (type == 3) /* clipboard */
{
- g_writeln("got clip data");
+ log_message(LOG_LEVEL_DEBUG,"VNC got clip data");
error = lib_clip_data(v);
}
else
{
- g_sprintf(text, "unknown in lib_mod_signal %d", type);
+ g_sprintf(text, "VNC unknown in lib_mod_signal %d", type);
v->server_msg(v, text, 1);
}
}
@@ -847,19 +853,19 @@ lib_mod_connect(struct vnc* v)
int i;
int check_sec_result;
- v->server_msg(v, "started connecting", 0);
+ v->server_msg(v, "VNC started connecting", 0);
check_sec_result = 1;
/* only support 8 and 16 bpp connections from rdp client */
if ((v->server_bpp != 8) && (v->server_bpp != 15) &&
(v->server_bpp != 16) && (v->server_bpp != 24))
{
- v->server_msg(v, "error - only supporting 8, 15, 16 and 24 bpp rdp \
+ v->server_msg(v, "VNC error - only supporting 8, 15, 16 and 24 bpp rdp \
connections", 0);
return 1;
}
if (g_strcmp(v->ip, "") == 0)
{
- v->server_msg(v, "error - no ip set", 0);
+ v->server_msg(v, "VNC error - no ip set", 0);
return 1;
}
make_stream(s);
@@ -868,19 +874,19 @@ connections", 0);
v->sck = g_tcp_socket();
v->sck_obj = g_create_wait_obj_from_socket(v->sck, 0);
v->sck_closed = 0;
- g_sprintf(text, "connecting to %s %s", v->ip, con_port);
+ g_sprintf(text, "VNC connecting to %s %s", v->ip, con_port);
v->server_msg(v, text, 0);
error = g_tcp_connect(v->sck, v->ip, con_port);
if (error == 0)
{
- v->server_msg(v, "tcp connected", 0);
+ v->server_msg(v, "VNC tcp connected", 0);
g_tcp_set_non_blocking(v->sck);
g_tcp_set_no_delay(v->sck);
/* protocal version */
init_stream(s, 8192);
error = lib_recv(v, s->data, 12);
if (error == 0)
- {
+ {
error = lib_send(v, "RFB 003.003\n", 12);
}
/* sec type */
@@ -892,7 +898,7 @@ connections", 0);
if (error == 0)
{
in_uint32_be(s, i);
- g_sprintf(text, "security level is %d (1 = none, 2 = standard)", i);
+ g_sprintf(text, "VNC security level is %d (1 = none, 2 = standard)", i);
v->server_msg(v, text, 0);
if (i == 1) /* none */
{
@@ -903,63 +909,90 @@ connections", 0);
init_stream(s, 8192);
error = lib_recv(v, s->data, 16);
if (error == 0)
- {
- rfbEncryptBytes(s->data, v->password);
- error = lib_send(v, s->data, 16);
- }
+ {
+ rfbEncryptBytes(s->data, v->password);
+ error = lib_send(v, s->data, 16);
+ check_sec_result = 1 ; // not needed
+ }
}
- else
- {
+ else if(i==0)
+ {
+ log_message(LOG_LEVEL_DEBUG,"VNC Server will disconnect");
error = 1;
}
+ else
+ {
+ log_message(LOG_LEVEL_DEBUG,"VNC unsupported security level");
+ error = 1;
+ }
}
}
+ if (error!=0)
+ {
+ log_message(LOG_LEVEL_DEBUG,"VNC Error after security negotiation");
+ }
if (error == 0 && check_sec_result)
{
/* sec result */
- init_stream(s, 8192);
- error = lib_recv(v, s->data, 4);
+ init_stream(s, 8192);
+ error = lib_recv(v, s->data, 4);
if (error == 0)
{
in_uint32_be(s, i);
if (i != 0)
{
- v->server_msg(v, "password failed", 0);
+ v->server_msg(v, "VNC password failed", 0);
error = 2;
}
else
{
- v->server_msg(v, "password ok", 0);
+ v->server_msg(v, "VNC password ok", 0);
}
}
}
if (error == 0)
{
- v->server_msg(v, "sending share flag", 0);
+ v->server_msg(v, "VNC sending share flag", 0);
init_stream(s, 8192);
s->data[0] = 1;
error = lib_send(v, s->data, 1); /* share flag */
}
+ else
+ {
+ log_message(LOG_LEVEL_DEBUG,"VNC error before sending share flag");
+ }
if (error == 0)
{
- v->server_msg(v, "receiving server init", 0);
+ v->server_msg(v, "VNC receiving server init", 0);
error = lib_recv(v, s->data, 4); /* server init */
}
+ else
+ {
+ log_message(LOG_LEVEL_DEBUG,"VNC error before receiving server init");
+ }
if (error == 0)
{
in_uint16_be(s, v->mod_width);
in_uint16_be(s, v->mod_height);
init_stream(pixel_format, 8192);
- v->server_msg(v, "receiving pixel format", 0);
+ v->server_msg(v, "VNC receiving pixel format", 0);
error = lib_recv(v, pixel_format->data, 16);
}
+ else
+ {
+ log_message(LOG_LEVEL_DEBUG,"VNC error before receiving pixel format");
+ }
if (error == 0)
{
v->mod_bpp = v->server_bpp;
init_stream(s, 8192);
- v->server_msg(v, "receiving name length", 0);
+ v->server_msg(v, "VNC receiving name length", 0);
error = lib_recv(v, s->data, 4); /* name len */
}
+ else
+ {
+ log_message(LOG_LEVEL_DEBUG,"VNC error before receiving name length");
+ }
if (error == 0)
{
in_uint32_be(s, i);
@@ -969,11 +1002,15 @@ connections", 0);
}
else
{
- v->server_msg(v, "receiving name", 0);
+ v->server_msg(v, "VNC receiving name", 0);
error = lib_recv(v, v->mod_name, i);
v->mod_name[i] = 0;
}
}
+ else
+ {
+ log_message(LOG_LEVEL_DEBUG,"VNC error before receiving name");
+ }
/* should be connected */
if (error == 0)
{
@@ -1057,7 +1094,7 @@ connections", 0);
out_uint8s(pixel_format, 3); /* pad */
}
out_uint8a(s, pixel_format->data, 16);
- v->server_msg(v, "sending pixel format", 0);
+ v->server_msg(v, "VNC sending pixel format", 0);
error = lib_send(v, s->data, 20);
}
if (error == 0)
@@ -1071,7 +1108,7 @@ connections", 0);
out_uint32_be(s, 1); /* copy rect */
out_uint32_be(s, 0xffffff11); /* cursor */
out_uint32_be(s, 0xffffff21); /* desktop size */
- v->server_msg(v, "sending encodings", 0);
+ v->server_msg(v, "VNC sending encodings", 0);
error = lib_send(v, s->data, 4 + 4 * 4);
}
if (error == 0)
@@ -1088,14 +1125,14 @@ connections", 0);
out_uint16_be(s, 0);
out_uint16_be(s, v->mod_width);
out_uint16_be(s, v->mod_height);
- v->server_msg(v, "sending framebuffer update request", 0);
+ v->server_msg(v, "VNC sending framebuffer update request", 0);
error = lib_send(v, s->data, 10);
}
if (error == 0)
{
if (v->server_bpp != v->mod_bpp)
{
- v->server_msg(v, "error - server bpp and client bpp do not match", 0);
+ v->server_msg(v, "VNC error - server bpp and client bpp do not match", 0);
error = 1;
}
}
@@ -1107,20 +1144,20 @@ connections", 0);
g_memset(cursor_data + (32 * (32 * 3) - 2 * 32 * 3), 0xff, 9);
g_memset(cursor_data + (32 * (32 * 3) - 3 * 32 * 3), 0xff, 9);
g_memset(cursor_mask, 0xff, 32 * (32 / 8));
- v->server_msg(v, "sending cursor", 0);
+ v->server_msg(v, "VNC sending cursor", 0);
error = v->server_set_cursor(v, 3, 3, cursor_data, cursor_mask);
}
free_stream(s);
free_stream(pixel_format);
if (error == 0)
{
- v->server_msg(v, "connection complete, connected ok", 0);
+ v->server_msg(v, "VNC connection complete, connected ok", 0);
lib_open_clip_channel(v);
}
else
{
- v->server_msg(v, "error - problem connecting", 0);
- }
+ v->server_msg(v, "VNC error - problem connecting", 0);
+ }
return error;
}
@@ -1231,6 +1268,7 @@ mod_init(void)
int EXPORT_CC
mod_exit(struct vnc* v)
{
+ log_message(LOG_LEVEL_DEBUG,"VNC mod_exit");
if (v == 0)
{
return 0;
diff --git a/xrdp/lang.c b/xrdp/lang.c
index 6bcf7ebe..1c13839f 100644
--- a/xrdp/lang.c
+++ b/xrdp/lang.c
@@ -22,6 +22,7 @@
*/
#include "xrdp.h"
+#include "log.h"
/* map for rdp to x11 scancodes
code1 is regular scancode, code2 is extended scancode */
@@ -232,13 +233,18 @@ get_keymaps(int keylayout, struct xrdp_keymap* keymap)
km_read_section(fd, "shiftcapslock", keymap->keys_shiftcapslock);
if (g_memcmp(lkeymap, keymap, sizeof(struct xrdp_keymap)) != 0)
{
- g_writeln("local keymap file for 0x%4.4x found and dosen't match "
+ log_message(LOG_LEVEL_WARNING,
+ "local keymap file for 0x%4.4x found and dosen't match "
"built in keymap, using local keymap file", keylayout);
}
g_free(lkeymap);
g_file_close(fd);
}
}
+ else
+ {
+ log_message(LOG_LEVEL_WARNING,"File does not exist: %s",filename);
+ }
g_free(filename);
return 0;
}
diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c
index 95936cef..83d2f0a2 100644
--- a/xrdp/xrdp.c
+++ b/xrdp/xrdp.c
@@ -21,6 +21,7 @@
*/
#include "xrdp.h"
+#include "log.h"
static struct xrdp_listen* g_listen = 0;
static long g_threadid = 0; /* main threadid */
@@ -261,6 +262,8 @@ main(int argc, char** argv)
{
int test;
int host_be;
+ char cfg_file[256];
+ enum logReturns error;
struct xrdp_startup_params* startup_params;
int pid;
int fd;
@@ -304,6 +307,25 @@ main(int argc, char** argv)
g_writeln("unusable tui64 size, must be 8");
return 0;
}
+ g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
+
+ /* starting logging subsystem */
+ error = log_start(cfg_file,"XRDP");
+
+ if (error != LOG_STARTUP_OK)
+ {
+ char buf[256] ;
+ switch (error)
+ {
+ case LOG_ERROR_MALLOC:
+ g_printf("error on malloc. cannot start logging. quitting.\n");
+ break;
+ case LOG_ERROR_FILE_OPEN:
+ g_printf("error opening log file [%s]. quitting.\n", getLogFile(buf,255));
+ break;
+ }
+ g_exit(1);
+ }
startup_params = (struct xrdp_startup_params*)
g_malloc(sizeof(struct xrdp_startup_params), 1);
diff --git a/xrdp/xrdp.ini b/xrdp/xrdp.ini
index af5f2650..115d2708 100644
--- a/xrdp/xrdp.ini
+++ b/xrdp/xrdp.ini
@@ -19,6 +19,14 @@ fork=yes
#autorun=xrdp7
#hidelogwindow=yes
+[Logging]
+LogFile=/var/log/xrdp.log
+LogLevel=DEBUG
+EnableSyslog=1
+SyslogLevel=DEBUG
+# LogLevel and SysLogLevel could by any of: core, error, warning, info or debug
+
+
[xrdp1]
name=sesman-Xvnc
lib=libvnc.so
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c
index cee6f40b..d568345f 100644
--- a/xrdp/xrdp_bitmap.c
+++ b/xrdp/xrdp_bitmap.c
@@ -24,6 +24,7 @@
*/
#include "xrdp.h"
+#include "log.h"
static int g_crc_seed = 0xffffffff;
static int g_crc_table[256] =
@@ -351,8 +352,8 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, const char* filename, int* palette)
if (!g_file_exist(filename))
{
- g_writeln("xrdp_bitmap_load: error bitmap file [%s] does not exist",
- filename);
+ log_message(LOG_LEVEL_ERROR,
+ "xrdp_bitmap_load: error bitmap file [%s] does not exist",filename);
return 1;
}
s = (struct stream *)NULL;
@@ -362,15 +363,15 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, const char* filename, int* palette)
/* read file type */
if (g_file_read(fd, type1, 2) != 2)
{
- g_writeln("xrdp_bitmap_load: error bitmap file [%s] read error",
- filename);
+ log_message(LOG_LEVEL_ERROR,
+ "xrdp_bitmap_load: error bitmap file [%s] read error",filename);
g_file_close(fd);
return 1;
}
if ((type1[0] != 'B') || (type1[1] != 'M'))
{
- g_writeln("xrdp_bitmap_load: error bitmap file [%s] not BMP file",
- filename);
+ log_message(LOG_LEVEL_ERROR,
+ "xrdp_bitmap_load: error bitmap file [%s] not BMP file", filename);
g_file_close(fd);
return 1;
}
@@ -397,8 +398,8 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, const char* filename, int* palette)
if ((header.bit_count != 4) && (header.bit_count != 8) &&
(header.bit_count != 24))
{
- g_writeln("xrdp_bitmap_load: error bitmap file [%s] bad bpp %d",
- filename, header.bit_count);
+ log_message(LOG_LEVEL_ERROR,
+ "xrdp_bitmap_load: error bitmap file [%s] bad bpp %d",filename, header.bit_count);
free_stream(s);
g_file_close(fd);
return 1;
@@ -416,8 +417,8 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, const char* filename, int* palette)
k = g_file_read(fd, s->data + i * size, size);
if (k != size)
{
- g_writeln("xrdp_bitmap_load: error bitmap file [%s] read",
- filename);
+ log_message(LOG_LEVEL_ERROR,
+ "xrdp_bitmap_load: error bitmap file [%s] read",filename);
}
}
for (i = 0; i < self->height; i++)
@@ -470,8 +471,8 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, const char* filename, int* palette)
k = g_file_read(fd, s->data + i * size, size);
if (k != size)
{
- g_writeln("xrdp_bitmap_load: error bitmap file [%s] read",
- filename);
+ log_message(LOG_LEVEL_ERROR,
+ "xrdp_bitmap_load: error bitmap file [%s] read", filename);
}
}
for (i = 0; i < self->height; i++)
@@ -520,8 +521,8 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, const char* filename, int* palette)
k = g_file_read(fd, s->data + i * size, size);
if (k != size)
{
- g_writeln("xrdp_bitmap_load: error bitmap file [%s] read",
- filename);
+ log_message(LOG_LEVEL_ERROR,
+ "xrdp_bitmap_load: error bitmap file [%s] read",filename);
}
}
for (i = 0; i < self->height; i++)
@@ -563,8 +564,8 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, const char* filename, int* palette)
}
else
{
- g_writeln("xrdp_bitmap_load: error loading bitmap from file [%s]",
- filename);
+ log_message(LOG_LEVEL_ERROR,
+ "xrdp_bitmap_load: error loading bitmap from file [%s]", filename);
return 1;
}
return 0;
diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c
index 2b394837..0ea45b0e 100644
--- a/xrdp/xrdp_login_wnd.c
+++ b/xrdp/xrdp_login_wnd.c
@@ -21,6 +21,7 @@
*/
#include "xrdp.h"
+#include "log.h"
/*****************************************************************************/
/* all login help screen events go here */
@@ -403,14 +404,14 @@ xrdp_wm_login_fill_in_combo(struct xrdp_wm* self, struct xrdp_bitmap* b)
fd = g_file_open(cfg_file); /* xrdp.ini */
if (fd < 1)
{
- g_writeln("Could not read xrdp ini file %s", cfg_file);
+ log_message(LOG_LEVEL_ERROR,"Could not read xrdp ini file %s", cfg_file);
}
file_read_sections(fd, sections);
for (i = 0; i < sections->count; i++)
{
p = (char*)list_get_item(sections, i);
file_read_section(fd, p, section_names, section_values);
- if (g_strncmp(p, "globals", 255) == 0)
+ if ((g_strncmp(p, "globals", 255) == 0) || (g_strncmp(p,"Logging",255) == 0))
{
}
else