summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/Makefile.am3
-rw-r--r--common/list.c1
-rw-r--r--common/log.c603
-rw-r--r--common/log.h179
-rw-r--r--common/os_calls.c10
-rw-r--r--common/rail.h147
-rw-r--r--common/xrdp_client_info.h6
-rw-r--r--freerdp1/xrdp-freerdp.c83
-rw-r--r--libxrdp/Makefile.am3
-rw-r--r--libxrdp/libxrdp.h2
-rw-r--r--libxrdp/xrdp_fastpath.c6
-rw-r--r--libxrdp/xrdp_orders.c3
-rw-r--r--libxrdp/xrdp_orders_rail.c625
-rw-r--r--libxrdp/xrdp_orders_rail.h50
-rw-r--r--libxrdp/xrdp_rdp.c66
-rw-r--r--sesman/access.c26
-rw-r--r--sesman/chansrv/chansrv.c111
-rw-r--r--sesman/chansrv/clipboard.c157
-rw-r--r--sesman/chansrv/sound.c2
-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.c82
-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.c46
-rw-r--r--sesman/scp_v1_mng.c22
-rw-r--r--sesman/sesman.c33
-rw-r--r--sesman/sesman.ini4
-rw-r--r--sesman/session.c122
-rw-r--r--sesman/sig.c36
-rw-r--r--sesman/thread.c41
-rw-r--r--sesman/tools/sesadmin.c10
-rw-r--r--sesman/tools/sestest.c4
-rw-r--r--sesman/verify_user.c18
-rw-r--r--vnc/vnc.c100
-rw-r--r--xorg/X11R7.6/rdp/rdp.h15
-rw-r--r--xorg/X11R7.6/rdp/rdpdraw.c87
-rw-r--r--xorg/X11R7.6/rdp/rdpmain.c10
-rw-r--r--xrdp/lang.c8
-rw-r--r--xrdp/xrdp.c26
-rw-r--r--xrdp/xrdp.ini8
-rw-r--r--xrdp/xrdp_bitmap.c33
-rw-r--r--xrdp/xrdp_listen.c1
-rw-r--r--xrdp/xrdp_login_wnd.c5
-rw-r--r--xrdp/xrdp_mm.c8
-rw-r--r--xrdp/xrdp_painter.c4
56 files changed, 2346 insertions, 732 deletions
diff --git a/common/Makefile.am b/common/Makefile.am
index 1bc5eeb6..33cfc1e5 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -5,7 +5,8 @@ AM_CFLAGS = \
-DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
-DXRDP_SBIN_PATH=\"${sbindir}\" \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
- -DXRDP_PID_PATH=\"${localstatedir}/run\"
+ -DXRDP_PID_PATH=\"${localstatedir}/run\" \
+ -DXRDP_LOG_PATH=\"${localstatedir}/log\"
lib_LTLIBRARIES = \
libcommon.la
diff --git a/common/list.c b/common/list.c
index 9df7f6a1..f67a08ab 100644
--- a/common/list.c
+++ b/common/list.c
@@ -205,7 +205,6 @@ void APP_CC
list_dump_items(struct list* self)
{
int index;
- tbus item;
if (self->count == 0)
{
diff --git a/common/log.c b/common/log.c
index 7bbdfc06..390b2bff 100644
--- a/common/log.c
+++ b/common/log.c
@@ -1,20 +1,24 @@
/*
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2005-2010
+ Copyright (c) 2005-2012 Jay Sorg
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
*/
#include <sys/types.h>
@@ -24,23 +28,41 @@
#include <stdarg.h>
#include <stdio.h>
#include <time.h>
-
+#include "list.h"
+#include "file.h"
#include "os_calls.h"
+#include "thread_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
* @param fname log file name
* @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 +72,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 +85,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 +117,42 @@ 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,30 +174,25 @@ 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 +210,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 +243,387 @@ 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;
+ char* temp_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 (lc->log_file != NULL)
+ {
+ if (lc->log_file[0] != '/')
+ {
+ temp_buf = (char*)g_malloc(512, 0);
+ g_snprintf(temp_buf, 511, "%s/%s", XRDP_LOG_PATH, lc->log_file);
+ g_free(lc->log_file);
+ lc->log_file = temp_buf;
+ }
+ }
+ }
+ if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_LEVEL))
+ {
+ 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");
+ }
+
+ /* try to create path if not exist */
+ g_create_path(lc->log_file);
+
+ g_printf("logging configuration:\r\n");
+ g_printf("\tLogFile: %s\r\n", lc->log_file);
+ g_printf("\tLogLevel: %i\r\n", lc->log_level);
+ 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(void)
+{
+ 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)
+ {
+ g_writeln("internalInitAndAllocStruct failed");
+ 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(void)
+{
+ 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;
+ 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)(%ld)%s", g_getpid(),
+ tc_get_threadid(), buff + 20);
+ }
+
+ if (lvl <= staticLogConfig->log_level)
+ {
+ /* log to console */
+ g_printf(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, buff, g_strlen(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* DEFAULT_CC
+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..cc355b18 100644
--- a/common/log.h
+++ b/common/log.h
@@ -1,20 +1,24 @@
/*
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2005-2010
+ Copyright (c) 2005-2012 Jay Sorg
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
*/
#ifndef LOG_H
@@ -28,27 +32,40 @@
#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
@@ -63,16 +80,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 +90,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 +99,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 +117,82 @@ 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(void);
+/**
+ * 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(void);
+
+/**
+ * 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 2a97fc69..c713bfaa 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
@@ -566,7 +570,11 @@ g_write_ip_address(int rcv_sck, char* ip_address, int bytes)
{
struct sockaddr_in s;
struct in_addr in;
+#if defined(_WIN32)
int len;
+#else
+ unsigned int len;
+#endif
int ip_port;
int ok;
@@ -1338,7 +1346,7 @@ g_mkdir(const char* dirname)
/*****************************************************************************/
/* gets the current working directory and puts up to maxlen chars in
- dirname
+ dirname
always returns 0 */
char* APP_CC
g_get_current_dir(char* dirname, int maxlen)
diff --git a/common/rail.h b/common/rail.h
new file mode 100644
index 00000000..deed3a9e
--- /dev/null
+++ b/common/rail.h
@@ -0,0 +1,147 @@
+/**
+ * xrdp: A Remote Desktop Protocol server.
+ *
+ * Copyright (C) Jay Sorg 2012
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if !defined(_RAIL_H)
+#define _RAIL_H
+
+/*
+ ORDER_TYPE_WINDOW
+ WINDOW_ORDER_TYPE_WINDOW
+ WINDOW_ORDER_ICON
+ WINDOW_ORDER_CACHED_ICON
+ WINDOW_ORDER_STATE_DELETED
+ WINDOW_ORDER_STATE_NEW on
+ WINDOW_ORDER_STATE_NEW off
+ WINDOW_ORDER_TYPE_NOTIFY
+ WINDOW_ORDER_STATE_DELETED
+ WINDOW_ORDER_STATE_NEW on
+ WINDOW_ORDER_STATE_NEW off
+ WINDOW_ORDER_TYPE_DESKTOP
+ WINDOW_ORDER_FIELD_DESKTOP_NONE on
+ WINDOW_ORDER_FIELD_DESKTOP_NONE off
+*/
+
+/* Window Order Header Flags */
+#define WINDOW_ORDER_TYPE_WINDOW 0x01000000
+#define WINDOW_ORDER_TYPE_NOTIFY 0x02000000
+#define WINDOW_ORDER_TYPE_DESKTOP 0x04000000
+#define WINDOW_ORDER_STATE_NEW 0x10000000
+#define WINDOW_ORDER_STATE_DELETED 0x20000000
+#define WINDOW_ORDER_FIELD_OWNER 0x00000002
+#define WINDOW_ORDER_FIELD_STYLE 0x00000008
+#define WINDOW_ORDER_FIELD_SHOW 0x00000010
+#define WINDOW_ORDER_FIELD_TITLE 0x00000004
+#define WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET 0x00004000
+#define WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE 0x00010000
+#define WINDOW_ORDER_FIELD_RP_CONTENT 0x00020000
+#define WINDOW_ORDER_FIELD_ROOT_PARENT 0x00040000
+#define WINDOW_ORDER_FIELD_WND_OFFSET 0x00000800
+#define WINDOW_ORDER_FIELD_WND_CLIENT_DELTA 0x00008000
+#define WINDOW_ORDER_FIELD_WND_SIZE 0x00000400
+#define WINDOW_ORDER_FIELD_WND_RECTS 0x00000100
+#define WINDOW_ORDER_FIELD_VIS_OFFSET 0x00001000
+#define WINDOW_ORDER_FIELD_VISIBILITY 0x00000200
+#define WINDOW_ORDER_FIELD_ICON_BIG 0x00002000
+#define WINDOW_ORDER_ICON 0x40000000
+#define WINDOW_ORDER_CACHED_ICON 0x80000000
+#define WINDOW_ORDER_FIELD_NOTIFY_VERSION 0x00000008
+#define WINDOW_ORDER_FIELD_NOTIFY_TIP 0x00000001
+#define WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP 0x00000002
+#define WINDOW_ORDER_FIELD_NOTIFY_STATE 0x00000004
+#define WINDOW_ORDER_FIELD_DESKTOP_NONE 0x00000001
+#define WINDOW_ORDER_FIELD_DESKTOP_HOOKED 0x00000002
+#define WINDOW_ORDER_FIELD_DESKTOP_ARC_COMPLETED 0x00000004
+#define WINDOW_ORDER_FIELD_DESKTOP_ARC_BEGAN 0x00000008
+#define WINDOW_ORDER_FIELD_DESKTOP_ZORDER 0x00000010
+#define WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND 0x00000020
+
+struct rail_icon_info
+{
+ int bpp;
+ int width;
+ int height;
+ int cmap_bytes;
+ int mask_bytes;
+ int data_bytes;
+ char* mask;
+ char* cmap;
+ char* data;
+};
+
+struct rail_window_rect
+{
+ short left;
+ short top;
+ short right;
+ short bottom;
+};
+
+struct rail_notify_icon_infotip
+{
+ int timeout;
+ int flags;
+ char* text;
+ char* title;
+};
+
+struct rail_window_state_order
+{
+ int owner_window_id;
+ int style;
+ int extended_style;
+ int show_state;
+ char* title_info;
+ int client_offset_x;
+ int client_offset_y;
+ int client_area_width;
+ int client_area_height;
+ int rp_content;
+ int root_parent_handle;
+ int window_offset_x;
+ int window_offset_y;
+ int window_client_delta_x;
+ int window_client_delta_y;
+ int window_width;
+ int window_height;
+ int num_window_rects;
+ struct rail_window_rect* window_rects;
+ int visible_offset_x;
+ int visible_offset_y;
+ int num_visibility_rects;
+ struct rail_window_rect* visibility_rects;
+};
+
+struct rail_notify_state_order
+{
+ int version;
+ char* tool_tip;
+ struct rail_notify_icon_infotip infotip;
+ int state;
+ int icon_cache_entry;
+ int icon_cache_id;
+ struct rail_icon_info icon_info;
+};
+
+struct rail_monitored_desktop_order
+{
+ int active_window_id;
+ int num_window_ids;
+ int* window_ids;
+};
+
+#endif
diff --git a/common/xrdp_client_info.h b/common/xrdp_client_info.h
index 7fe93c26..cdd77921 100644
--- a/common/xrdp_client_info.h
+++ b/common/xrdp_client_info.h
@@ -74,6 +74,12 @@ struct xrdp_client_info
int offscreen_cache_size;
int offscreen_cache_entries;
int rfx;
+ /* CAPSETTYPE_RAIL */
+ int rail_support_level;
+ /* CAPSETTYPE_WINDOW */
+ int wnd_support_level;
+ int wnd_num_icon_caches;
+ int wnd_num_icon_cache_entries;
};
#endif
diff --git a/freerdp1/xrdp-freerdp.c b/freerdp1/xrdp-freerdp.c
index bad9d4ad..45d1a18d 100644
--- a/freerdp1/xrdp-freerdp.c
+++ b/freerdp1/xrdp-freerdp.c
@@ -87,34 +87,41 @@ lxrdp_connect(struct mod* mod)
switch (connectErrorCode)
{
case PREECONNECTERROR:
- snprintf(buf, 128, "The error code from connect is PREECONNECTERROR");
+ snprintf(buf, 128, "The error code from connect is "
+ "PREECONNECTERROR");
break;
case UNDEFINEDCONNECTERROR:
- snprintf(buf, 128, "The error code from connect is UNDEFINEDCONNECTERROR");
+ snprintf(buf, 128, "The error code from connect is "
+ "UNDEFINEDCONNECTERROR");
break;
case POSTCONNECTERROR:
- snprintf(buf, 128, "The error code from connect is POSTCONNECTERROR");
+ snprintf(buf, 128, "The error code from connect is "
+ "POSTCONNECTERROR");
break;
case DNSERROR:
snprintf(buf, 128, "The DNS system generated an error");
break;
case DNSNAMENOTFOUND:
- snprintf(buf, 128, "The DNS system could not find the specified name");
+ snprintf(buf, 128, "The DNS system could not find the "
+ "specified name");
break;
case CONNECTERROR:
snprintf(buf, 128, "A general connect error was returned");
break;
case MCSCONNECTINITIALERROR:
- snprintf(buf, 128, "The error code from connect is MCSCONNECTINITIALERROR");
+ snprintf(buf, 128, "The error code from connect is "
+ "MCSCONNECTINITIALERROR");
break;
case TLSCONNECTERROR:
snprintf(buf, 128, "Error in TLS handshake");
break;
case AUTHENTICATIONERROR:
- snprintf(buf, 128, "Authentication error check your password and username");
+ snprintf(buf, 128, "Authentication error check your password "
+ "and username");
break;
default:
- snprintf(buf, 128, "Unhandled Errorcode from connect : %d", connectErrorCode);
+ snprintf(buf, 128, "Unhandled Errorcode from connect : %d",
+ connectErrorCode);
break;
}
}
@@ -214,9 +221,48 @@ lxrdp_event(struct mod* mod, int msg, long param1, long param2,
case 110:
break;
case 200:
- /* Currently there are no (?) invalidate API in freeRDP that can receive this request*/
- LLOGLN(0, ("Invalidate request sent from client - Ignored"));
- break ;
+ LLOGLN(10, ("Invalidate request sent from client"));
+ RECTANGLE_16 *rectangle = (RECTANGLE_16 *) g_malloc(sizeof(RECTANGLE_16), 0);
+ /* The parameters are coded as follows param1 = MAKELONG(y, x), param2 =MAKELONG(h, w)
+ * #define MAKELONG(lo, hi) ((((hi) & 0xffff) << 16) | ((lo) & 0xffff))
+ */
+ rectangle->left = (param1 >> 16) & 0xffff;
+ rectangle->top = param1 & 0xffff;
+ rectangle->right = (param2 >> 16) & 0xffff + rectangle->left - 1;
+ rectangle->bottom = param2 & 0xffff + rectangle->top - 1;
+ if (mod->inst->settings->refresh_rect)
+ {
+ if (mod->inst->update != NULL)
+ {
+ if (mod->inst->update->RefreshRect != NULL)
+ {
+ if (mod->inst->context != NULL)
+ {
+ LLOGLN(0, ("update rectangle left: %d top: %d bottom: %d right: %d",
+ rectangle->left, rectangle->top, rectangle->bottom, rectangle->right));
+ mod->inst->update->RefreshRect(mod->inst->context, 1, rectangle);
+ }
+ else
+ {
+ LLOGLN(0, ("Invalidate request -The context is null"));
+ }
+ }
+ else
+ {
+ LLOGLN(0, ("Invalidate request - RefreshRect is Null"));
+ }
+ }
+ else
+ {
+ LLOGLN(0, ("Invalidate request -the update pointer is null"));
+ }
+ }
+ else
+ {
+ LLOGLN(0, ("Invalidate request - warning - update rectangle is disabled"));
+ }
+ g_free(rectangle);
+ break;
case 0x5555:
chanid = LOWORD(param1);
flags = HIWORD(param1);
@@ -727,13 +773,13 @@ lfreerdp_upsidedown(uint8* destination, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_o
tui8* src;
tui8* dst;
int line_bytes;
- int j ;
- if(destination==NULL)
+ int j;
+
+ if (destination == NULL)
{
- LLOGLN(0, ("lfreerdp_upsidedown : destination pointer is NULL !!!"));
- return ;
+ LLOGLN(0, ("lfreerdp_upsidedown: destination pointer is NULL !!!"));
+ return;
}
-
line_bytes = server_Bpp * cache_bitmap_v2_order->bitmapWidth;
src = cache_bitmap_v2_order->bitmapDataStream;
dst = destination + ((cache_bitmap_v2_order->bitmapHeight) * line_bytes);
@@ -804,11 +850,10 @@ lfreerdp_cache_bitmapV2(rdpContext* context,
server_bpp, server_bpp);
}
else
- {
- /* Uncompressed bitmaps are upside down */
- lfreerdp_upsidedown(dst_data, cache_bitmap_v2_order,server_Bpp);
+ {
+ /* Uncompressed bitmaps are upside down */
+ lfreerdp_upsidedown(dst_data, cache_bitmap_v2_order, server_Bpp);
LLOGLN(10, ("lfreerdp_cache_bitmapV2: upside down progressed"));
- /* old: g_memcpy(dst_data, cache_bitmap_v2_order->bitmapDataStream,width * height * server_Bpp);*/
}
dst_data1 = convert_bitmap(server_bpp, client_bpp, dst_data,
width, height, mod->colormap);
diff --git a/libxrdp/Makefile.am b/libxrdp/Makefile.am
index 08fb7130..ad891bd8 100644
--- a/libxrdp/Makefile.am
+++ b/libxrdp/Makefile.am
@@ -50,7 +50,8 @@ libxrdp_la_SOURCES = \
xrdp_sec.c \
xrdp_tcp.c \
xrdp_bitmap_compress.c \
- xrdp_jpeg_compress.c
+ xrdp_jpeg_compress.c \
+ xrdp_orders_rail.c
libxrdp_la_LDFLAGS = \
$(EXTRA_FLAGS)
diff --git a/libxrdp/libxrdp.h b/libxrdp/libxrdp.h
index 7aae38b5..7792d157 100644
--- a/libxrdp/libxrdp.h
+++ b/libxrdp/libxrdp.h
@@ -325,6 +325,8 @@ xrdp_orders_send(struct xrdp_orders* self);
int APP_CC
xrdp_orders_force_send(struct xrdp_orders* self);
int APP_CC
+xrdp_orders_check(struct xrdp_orders* self, int max_size);
+int APP_CC
xrdp_orders_rect(struct xrdp_orders* self, int x, int y, int cx, int cy,
int color, struct xrdp_rect* rect);
int APP_CC
diff --git a/libxrdp/xrdp_fastpath.c b/libxrdp/xrdp_fastpath.c
index 5ce07861..9a147b1b 100644
--- a/libxrdp/xrdp_fastpath.c
+++ b/libxrdp/xrdp_fastpath.c
@@ -76,7 +76,7 @@ xrdp_fastpath_send_update_pdu(struct xrdp_fastpath* self, tui8 updateCode,
compression = 0;
s_send = self->out_s;
- maxLen = FASTPATH_MAX_PACKET_SIZE - 6 ; /* 6 bytes for header */
+ maxLen = FASTPATH_MAX_PACKET_SIZE - 6; /* 6 bytes for header */
payloadLeft = (s->end - s->data);
for (i = 0; payloadLeft > 0; i++)
{
@@ -143,7 +143,7 @@ xrdp_fastpath_process_update(struct xrdp_fastpath* self, tui8 updateCode,
}
return 0;
-}
+}
/*****************************************************************************/
int APP_CC
@@ -192,5 +192,5 @@ xrdp_fastpath_process_data(struct xrdp_fastpath* self, struct stream* s,
return 1;
}
in_uint16_le(s, size);
- return xrdp_fastpath_process_update(self, updateCode, size, s);
+ return xrdp_fastpath_process_update(self, updateCode, size, s);
}
diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c
index a52c5f92..d068c39a 100644
--- a/libxrdp/xrdp_orders.c
+++ b/libxrdp/xrdp_orders.c
@@ -152,7 +152,7 @@ xrdp_orders_force_send(struct xrdp_orders* self)
/* check if the current order will fit in packet size of 16384, if not */
/* send what we got and init a new one */
/* returns error */
-static int APP_CC
+int APP_CC
xrdp_orders_check(struct xrdp_orders* self, int max_size)
{
int size;
@@ -1987,7 +1987,6 @@ xrdp_orders_send_create_os_surface(struct xrdp_orders* self, int id,
bytes = 7;
num_del_list = del_list->count;
- g_writeln("xrdp_orders_send_create_os_surface: num_del_list %d", num_del_list);
if (num_del_list > 0)
{
bytes += 2;
diff --git a/libxrdp/xrdp_orders_rail.c b/libxrdp/xrdp_orders_rail.c
new file mode 100644
index 00000000..087cf42e
--- /dev/null
+++ b/libxrdp/xrdp_orders_rail.c
@@ -0,0 +1,625 @@
+/**
+ * xrdp: A Remote Desktop Protocol server.
+ *
+ * Copyright (C) Jay Sorg 2012
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "libxrdp.h"
+#include "rail.h"
+
+/* [MS-RDPERP]: Remote Desktop Protocol:
+ Remote Programs Virtual Channel Extension
+ http://msdn.microsoft.com/en-us/library/cc242568(v=prot.10) */
+
+/*****************************************************************************/
+/* RAIL */
+/* returns error */
+int APP_CC
+xrdp_orders_send_window_delete(struct xrdp_orders* self, int window_id)
+{
+ int order_size;
+ int order_flags;
+ int field_present_flags;
+
+ order_size = 11;
+ xrdp_orders_check(self, order_size);
+ self->order_count++;
+ order_flags = RDP_ORDER_SECONDARY;
+ order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
+ out_uint8(self->out_s, order_flags);
+ /* orderSize (2 bytes) */
+ out_uint16_le(self->out_s, order_size);
+ /* FieldsPresentFlags (4 bytes) */
+ field_present_flags = WINDOW_ORDER_TYPE_WINDOW | WINDOW_ORDER_STATE_DELETED;
+ out_uint32_le(self->out_s, field_present_flags);
+ /* windowId (4 bytes) */
+ out_uint32_le(self->out_s, window_id);
+ return 0;
+}
+
+/*****************************************************************************/
+/* RAIL */
+/* returns error */
+/* flags can contain WINDOW_ORDER_STATE_NEW and/or
+ WINDOW_ORDER_FIELD_ICON_BIG */
+int APP_CC
+xrdp_orders_send_window_cached_icon(struct xrdp_orders* self,
+ int window_id, int cache_entry,
+ int cache_id, int flags)
+{
+ int order_size;
+ int order_flags;
+ int field_present_flags;
+
+ order_size = 14;
+ xrdp_orders_check(self, order_size);
+ self->order_count++;
+ order_flags = RDP_ORDER_SECONDARY;
+ order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
+ out_uint8(self->out_s, order_flags);
+ /* orderSize (2 bytes) */
+ out_uint16_le(self->out_s, order_size);
+ /* FieldsPresentFlags (4 bytes) */
+ field_present_flags = flags | WINDOW_ORDER_TYPE_WINDOW |
+ WINDOW_ORDER_CACHED_ICON;
+ out_uint32_le(self->out_s, field_present_flags);
+ /* windowId (4 bytes) */
+ out_uint32_le(self->out_s, window_id);
+ /* CacheEntry (2 bytes) */
+ out_uint16_le(self->out_s, cache_entry);
+ /* CacheId (1 byte) */
+ out_uint8(self->out_s, cache_id);
+ return 0;
+}
+
+/*****************************************************************************/
+/* RAIL */
+/* returns error */
+static int APP_CC
+xrdp_orders_send_ts_icon(struct stream* s, int cache_entry, int cache_id,
+ struct rail_icon_info* icon_info)
+{
+ int use_cmap;
+
+ use_cmap = 0;
+ if ((icon_info->bpp == 1) || (icon_info->bpp == 2) || (icon_info->bpp == 4))
+ {
+ use_cmap = 1;
+ }
+
+ /* TS_ICON_INFO */
+ out_uint16_le(s, cache_entry);
+ out_uint8(s, cache_id);
+ out_uint8(s, icon_info->bpp);
+ out_uint16_le(s, icon_info->width);
+ out_uint16_le(s, icon_info->height);
+ if (use_cmap)
+ {
+ out_uint16_le(s, icon_info->cmap_bytes);
+ }
+ out_uint16_le(s, icon_info->mask_bytes);
+ out_uint16_le(s, icon_info->data_bytes);
+ out_uint8p(s, icon_info->mask, icon_info->mask_bytes);
+ if (use_cmap)
+ {
+ out_uint8p(s, icon_info->cmap, icon_info->cmap_bytes);
+ }
+ out_uint8p(s, icon_info->data, icon_info->data_bytes);
+ return 0;
+}
+
+/*****************************************************************************/
+/* RAIL */
+/* returns error */
+/* flags can contain WINDOW_ORDER_STATE_NEW and/or
+ WINDOW_ORDER_FIELD_ICON_BIG */
+int APP_CC
+xrdp_orders_send_window_icon(struct xrdp_orders* self,
+ int window_id, int cache_entry, int cache_id,
+ struct rail_icon_info* icon_info,
+ int flags)
+{
+ int order_size;
+ int order_flags;
+ int field_present_flags;
+ int use_cmap;
+
+ use_cmap = 0;
+ if ((icon_info->bpp == 1) || (icon_info->bpp == 2) || (icon_info->bpp == 4))
+ {
+ use_cmap = 1;
+ }
+ order_size = 23 + icon_info->mask_bytes + icon_info->data_bytes;
+ if (use_cmap)
+ {
+ order_size += icon_info->cmap_bytes + 2;
+ }
+ xrdp_orders_check(self, order_size);
+ self->order_count++;
+ order_flags = RDP_ORDER_SECONDARY;
+ order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
+ out_uint8(self->out_s, order_flags);
+ /* orderSize (2 bytes) */
+ out_uint16_le(self->out_s, order_size);
+ /* FieldsPresentFlags (4 bytes) */
+ field_present_flags = flags | WINDOW_ORDER_TYPE_WINDOW |
+ WINDOW_ORDER_ICON;
+ out_uint32_le(self->out_s, field_present_flags);
+ /* windowId (4 bytes) */
+ out_uint32_le(self->out_s, window_id);
+
+ xrdp_orders_send_ts_icon(self->out_s, cache_entry, cache_id, icon_info);
+
+ return 0;
+}
+
+/*****************************************************************************/
+/* returns error */
+static int APP_CC
+xrdp_orders_send_as_unicode(struct stream* s, const char* text)
+{
+ int str_chars;
+ int index;
+ int i32;
+ twchar wdst[256];
+
+ str_chars = g_mbstowcs(wdst, text, 255);
+ if (str_chars > 0)
+ {
+ i32 = str_chars * 2;
+ out_uint16_le(s, i32);
+ for (index = 0; index < str_chars; index++)
+ {
+ i32 = wdst[index];
+ out_uint16_le(s, i32);
+ }
+ }
+ else
+ {
+ out_uint16_le(s, 0);
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+/* RAIL */
+/* returns error */
+/* flags can contain WINDOW_ORDER_STATE_NEW */
+int APP_CC
+xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
+ struct rail_window_state_order* window_state,
+ int flags)
+{
+ int order_size;
+ int order_flags;
+ int field_present_flags;
+ int num_chars;
+ int index;
+
+ order_size = 11;
+ field_present_flags = flags | WINDOW_ORDER_TYPE_WINDOW;
+ if (field_present_flags & WINDOW_ORDER_FIELD_OWNER)
+ {
+ /* ownerWindowId (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_STYLE)
+ {
+ /* style (4 bytes) */
+ order_size += 4;
+ /* extendedStyle (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_SHOW)
+ {
+ /* showState (1 byte) */
+ order_size += 1;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_TITLE)
+ {
+ /* titleInfo */
+ num_chars = g_mbstowcs(0, window_state->title_info, 0);
+ order_size += 2 * num_chars + 2;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
+ {
+ /* clientOffsetX (4 bytes) */
+ order_size += 4;
+ /* clientOffsetY (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
+ {
+ /* clientAreaWidth (4 bytes) */
+ order_size += 4;
+ /* clientAreaHeight (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_RP_CONTENT)
+ {
+ /* RPContent (1 byte) */
+ order_size += 1;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_ROOT_PARENT)
+ {
+ /* rootParentHandle (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_WND_OFFSET)
+ {
+ /* windowOffsetX (4 bytes) */
+ order_size += 4;
+ /* windowOffsetY (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
+ {
+ /* windowClientDeltaX (4 bytes) */
+ order_size += 4;
+ /* windowClientDeltaY (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_WND_SIZE)
+ {
+ /* windowWidth (4 bytes) */
+ order_size += 4;
+ /* windowHeight (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_WND_RECTS)
+ {
+ /* numWindowRects (2 bytes) */
+ order_size += 2;
+ order_size += 8 * window_state->num_window_rects;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_VIS_OFFSET)
+ {
+ /* visibleOffsetX (4 bytes) */
+ order_size += 4;
+ /* visibleOffsetY (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_VISIBILITY)
+ {
+ /* numVisibilityRects (2 bytes) */
+ order_size += 2;
+ order_size += 8 * window_state->num_visibility_rects;
+ }
+
+ xrdp_orders_check(self, order_size);
+ self->order_count++;
+ order_flags = RDP_ORDER_SECONDARY;
+ order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
+ out_uint8(self->out_s, order_flags);
+ /* orderSize (2 bytes) */
+ out_uint16_le(self->out_s, order_size);
+ /* FieldsPresentFlags (4 bytes) */
+ out_uint32_le(self->out_s, field_present_flags);
+ /* windowId (4 bytes) */
+ out_uint32_le(self->out_s, window_id);
+
+ if (field_present_flags & WINDOW_ORDER_FIELD_OWNER)
+ {
+ /* ownerWindowId (4 bytes) */
+ out_uint32_le(self->out_s, window_state->owner_window_id);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_STYLE)
+ {
+ /* style (4 bytes) */
+ out_uint32_le(self->out_s, window_state->style);
+ /* extendedStyle (4 bytes) */
+ out_uint32_le(self->out_s, window_state->extended_style);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_SHOW)
+ {
+ /* showState (1 byte) */
+ out_uint8(self->out_s, window_state->show_state);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_TITLE)
+ {
+ /* titleInfo */
+ xrdp_orders_send_as_unicode(self->out_s, window_state->title_info);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
+ {
+ /* clientOffsetX (4 bytes) */
+ out_uint32_le(self->out_s, window_state->client_offset_x);
+ /* clientOffsetY (4 bytes) */
+ out_uint32_le(self->out_s, window_state->client_offset_y);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
+ {
+ /* clientAreaWidth (4 bytes) */
+ out_uint32_le(self->out_s, window_state->client_area_width);
+ /* clientAreaHeight (4 bytes) */
+ out_uint32_le(self->out_s, window_state->client_area_height);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_RP_CONTENT)
+ {
+ /* RPContent (1 byte) */
+ out_uint8(self->out_s, window_state->rp_content);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_ROOT_PARENT)
+ {
+ /* rootParentHandle (4 bytes) */
+ out_uint32_le(self->out_s, window_state->root_parent_handle);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_WND_OFFSET)
+ {
+ /* windowOffsetX (4 bytes) */
+ out_uint32_le(self->out_s, window_state->window_offset_x);
+ /* windowOffsetY (4 bytes) */
+ out_uint32_le(self->out_s, window_state->window_offset_y);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
+ {
+ /* windowClientDeltaX (4 bytes) */
+ out_uint32_le(self->out_s, window_state->window_client_delta_x);
+ /* windowClientDeltaY (4 bytes) */
+ out_uint32_le(self->out_s, window_state->window_client_delta_y);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_WND_SIZE)
+ {
+ /* windowWidth (4 bytes) */
+ out_uint32_le(self->out_s, window_state->window_width);
+ /* windowHeight (4 bytes) */
+ out_uint32_le(self->out_s, window_state->window_height);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_WND_RECTS)
+ {
+ /* numWindowRects (2 bytes) */
+ out_uint16_le(self->out_s, window_state->num_window_rects);
+ for (index = 0; index < window_state->num_window_rects; index++)
+ {
+ out_uint16_le(self->out_s, window_state->window_rects[index].left);
+ out_uint16_le(self->out_s, window_state->window_rects[index].top);
+ out_uint16_le(self->out_s, window_state->window_rects[index].right);
+ out_uint16_le(self->out_s, window_state->window_rects[index].bottom);
+ }
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_VIS_OFFSET)
+ {
+ /* visibleOffsetX (4 bytes) */
+ out_uint32_le(self->out_s, window_state->visible_offset_x);
+ /* visibleOffsetY (4 bytes) */
+ out_uint32_le(self->out_s, window_state->visible_offset_y);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_VISIBILITY)
+ {
+ /* numVisibilityRects (2 bytes) */
+ out_uint16_le(self->out_s, window_state->num_visibility_rects);
+ for (index = 0; index < window_state->num_visibility_rects; index++)
+ {
+ out_uint16_le(self->out_s, window_state->visibility_rects[index].left);
+ out_uint16_le(self->out_s, window_state->visibility_rects[index].top);
+ out_uint16_le(self->out_s, window_state->visibility_rects[index].right);
+ out_uint16_le(self->out_s, window_state->visibility_rects[index].bottom);
+ }
+ }
+
+ return 0;
+}
+
+/*****************************************************************************/
+/* RAIL */
+/* returns error */
+int APP_CC
+xrdp_orders_send_notify_delete(struct xrdp_orders* self, int window_id,
+ int notify_id)
+{
+ int order_size;
+ int order_flags;
+ int field_present_flags;
+
+ order_size = 15;
+ xrdp_orders_check(self, order_size);
+ self->order_count++;
+ order_flags = RDP_ORDER_SECONDARY;
+ order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
+ out_uint8(self->out_s, order_flags);
+ /* orderSize (2 bytes) */
+ out_uint16_le(self->out_s, order_size);
+ /* FieldsPresentFlags (4 bytes) */
+ field_present_flags = WINDOW_ORDER_TYPE_NOTIFY | WINDOW_ORDER_STATE_DELETED;
+ out_uint32_le(self->out_s, field_present_flags);
+ /* windowId (4 bytes) */
+ out_uint32_le(self->out_s, window_id);
+ /* notifyIconId (4 bytes) */
+ out_uint32_le(self->out_s, notify_id);
+ return 0;
+}
+
+/*****************************************************************************/
+/* RAIL */
+/* returns error */
+/* flags can contain WINDOW_ORDER_STATE_NEW */
+int APP_CC
+xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
+ int window_id, int notify_id,
+ struct rail_notify_state_order* notify_state,
+ int flags)
+{
+ int order_size;
+ int order_flags;
+ int field_present_flags;
+ int num_chars;
+ int use_cmap;
+
+ order_size = 15;
+ field_present_flags = flags | WINDOW_ORDER_TYPE_NOTIFY;
+ if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_VERSION)
+ {
+ /* Version (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_TIP)
+ {
+ /* ToolTip (variable) UNICODE_STRING */
+ num_chars = g_mbstowcs(0, notify_state->tool_tip, 0);
+ order_size += 2 * num_chars + 2;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
+ {
+ /* InfoTip (variable) TS_NOTIFY_ICON_INFOTIP */
+ /* UNICODE_STRING */
+ num_chars = g_mbstowcs(0, notify_state->infotip.title, 0);
+ order_size += 2 * num_chars + 2;
+ /* UNICODE_STRING */
+ num_chars = g_mbstowcs(0, notify_state->infotip.text, 0);
+ order_size += 2 * num_chars + 2;
+ /* Timeout (4 bytes) */
+ /* InfoFlags (4 bytes) */
+ order_size += 8;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_STATE)
+ {
+ /* State (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_ICON)
+ {
+ /* Icon (variable) */
+ use_cmap = 0;
+ if ((notify_state->icon_info.bpp == 1) || (notify_state->icon_info.bpp == 2) ||
+ (notify_state->icon_info.bpp == 4))
+ {
+ use_cmap = 1;
+ }
+ order_size += 12 + notify_state->icon_info.mask_bytes +
+ notify_state->icon_info.data_bytes;
+ if (use_cmap)
+ {
+ order_size += notify_state->icon_info.cmap_bytes + 2;
+ }
+ }
+ if (field_present_flags & WINDOW_ORDER_CACHED_ICON)
+ {
+ /* CachedIcon (3 bytes) */
+ order_size += 3;
+ }
+
+ xrdp_orders_check(self, order_size);
+ self->order_count++;
+ order_flags = RDP_ORDER_SECONDARY;
+ order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
+ out_uint8(self->out_s, order_flags);
+ /* orderSize (2 bytes) */
+ out_uint16_le(self->out_s, order_size);
+ /* FieldsPresentFlags (4 bytes) */
+ out_uint32_le(self->out_s, field_present_flags);
+ /* windowId (4 bytes) */
+ out_uint32_le(self->out_s, window_id);
+ /* notifyIconId (4 bytes) */
+ out_uint32_le(self->out_s, notify_id);
+
+ if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_VERSION)
+ {
+ /* Version (4 bytes) */
+ out_uint32_le(self->out_s, notify_state->version);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_TIP)
+ {
+ /* ToolTip (variable) UNICODE_STRING */
+ xrdp_orders_send_as_unicode(self->out_s, notify_state->tool_tip);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
+ {
+ /* InfoTip (variable) TS_NOTIFY_ICON_INFOTIP */
+ out_uint32_le(self->out_s, notify_state->infotip.timeout);
+ out_uint32_le(self->out_s, notify_state->infotip.flags);
+ xrdp_orders_send_as_unicode(self->out_s, notify_state->infotip.text);
+ xrdp_orders_send_as_unicode(self->out_s, notify_state->infotip.title);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_STATE)
+ {
+ /* State (4 bytes) */
+ out_uint32_le(self->out_s, notify_state->state);
+ }
+ if (field_present_flags & WINDOW_ORDER_ICON)
+ {
+ /* Icon (variable) */
+ xrdp_orders_send_ts_icon(self->out_s, notify_state->icon_cache_entry,
+ notify_state->icon_cache_id,
+ &notify_state->icon_info);
+ }
+ if (field_present_flags & WINDOW_ORDER_CACHED_ICON)
+ {
+ /* CacheEntry (2 bytes) */
+ out_uint16_le(self->out_s, notify_state->icon_cache_entry);
+ /* CacheId (1 byte) */
+ out_uint8(self->out_s, notify_state->icon_cache_id);
+ }
+
+ return 0;
+}
+
+/*****************************************************************************/
+/* RAIL */
+/* returns error */
+/* used for both Non-Monitored Desktop and Actively Monitored Desktop */
+int APP_CC
+xrdp_orders_send_monitored_desktop(struct xrdp_orders* self,
+ struct rail_monitored_desktop_order* mdo,
+ int flags)
+{
+ int order_size;
+ int order_flags;
+ int field_present_flags;
+ int index;
+
+ order_size = 7;
+ field_present_flags = flags | WINDOW_ORDER_TYPE_DESKTOP;
+
+ if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND)
+ {
+ /* ActiveWindowId (4 bytes) */
+ order_size += 4;
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
+ {
+ /* NumWindowIds (1 byte) */
+ order_size += 1;
+ /* WindowIds (variable) */
+ order_size += mdo->num_window_ids * 4;
+ }
+
+ xrdp_orders_check(self, order_size);
+ self->order_count++;
+ order_flags = RDP_ORDER_SECONDARY;
+ order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
+ out_uint8(self->out_s, order_flags);
+ /* orderSize (2 bytes) */
+ out_uint16_le(self->out_s, order_size);
+ /* FieldsPresentFlags (4 bytes) */
+ out_uint32_le(self->out_s, field_present_flags);
+
+ if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND)
+ {
+ /* ActiveWindowId (4 bytes) */
+ out_uint32_le(self->out_s, mdo->active_window_id);
+ }
+ if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
+ {
+ /* NumWindowIds (1 byte) */
+ out_uint8(self->out_s, mdo->num_window_ids);
+ /* WindowIds (variable) */
+ for (index = 0; index < mdo->num_window_ids; index++)
+ {
+ out_uint32_le(self->out_s, mdo->window_ids[index]);
+ }
+ }
+
+ return 0;
+}
diff --git a/libxrdp/xrdp_orders_rail.h b/libxrdp/xrdp_orders_rail.h
new file mode 100644
index 00000000..8f5b402f
--- /dev/null
+++ b/libxrdp/xrdp_orders_rail.h
@@ -0,0 +1,50 @@
+/**
+ * xrdp: A Remote Desktop Protocol server.
+ *
+ * Copyright (C) Jay Sorg 2012
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if !defined(_XRDP_ORDERS_RAIL_H)
+#define _XRDP_ORDERS_RAIL_H
+
+int APP_CC
+xrdp_orders_send_window_delete(struct xrdp_orders* self, int window_id);
+int APP_CC
+xrdp_orders_send_window_cached_icon(struct xrdp_orders* self,
+ int window_id, int cache_entry,
+ int cache_id, int flags);
+int APP_CC
+xrdp_orders_send_window_icon(struct xrdp_orders* self,
+ int window_id, int cache_entry, int cache_id,
+ struct rail_icon_info* icon_info,
+ int flags);
+int APP_CC
+xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
+ struct rail_window_state_order* window_state,
+ int flags);
+int APP_CC
+xrdp_orders_send_notify_delete(struct xrdp_orders* self, int window_id,
+ int notify_id);
+int APP_CC
+xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
+ int window_id, int notify_id,
+ struct rail_notify_state_order* notify_state,
+ int flags);
+int APP_CC
+xrdp_orders_send_monitored_desktop(struct xrdp_orders* self,
+ struct rail_monitored_desktop_order* mdo,
+ int flags);
+
+#endif
diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c
index f25ec274..c9f5dedf 100644
--- a/libxrdp/xrdp_rdp.c
+++ b/libxrdp/xrdp_rdp.c
@@ -321,7 +321,7 @@ xrdp_rdp_send_data(struct xrdp_rdp* self, struct stream* s,
if (self->client_info.rdp_compression && self->session->up_and_running)
{
mppc_enc = (struct rdp_mppc_enc*)(self->mppc_enc);
- if (compress_rdp(mppc_enc, s->p + 18, tocomplen))
+ if (compress_rdp(mppc_enc, (tui8*)(s->p + 18), tocomplen))
{
DEBUG(("mppc_encode ok flags 0x%x bytes_in_opb %d historyOffset %d "
"tocomplen %d", mppc_enc->flags, mppc_enc->bytes_in_opb,
@@ -620,6 +620,21 @@ xrdp_rdp_send_demand_active(struct xrdp_rdp* self)
out_uint8(s, 1);
out_uint8s(s, 83);
+ /* Remote Programs Capability Set */
+ caps_count++;
+ out_uint16_le(s, 0x0017); /* CAPSETTYPE_RAIL */
+ out_uint16_le(s, 8);
+ out_uint32_le(s, 3); /* TS_RAIL_LEVEL_SUPPORTED
+ TS_RAIL_LEVEL_DOCKED_LANGBAR_SUPPORTED */
+
+ /* Window List Capability Set */
+ caps_count++;
+ out_uint16_le(s, 0x0018); /* CAPSETTYPE_WINDOW */
+ out_uint16_le(s, 11);
+ out_uint32_le(s, 2); /* TS_WINDOW_LEVEL_SUPPORTED_EX */
+ out_uint8(s, 3); /* NumIconCaches */
+ out_uint16_le(s, 12); /* NumIconCacheEntries */
+
out_uint8s(s, 4); /* pad */
s_mark_end(s);
@@ -826,6 +841,49 @@ xrdp_process_offscreen_bmpcache(struct xrdp_rdp* self, struct stream* s,
}
/*****************************************************************************/
+static int APP_CC
+xrdp_process_capset_rail(struct xrdp_rdp* self, struct stream* s, int len)
+{
+ int i32;
+
+ if (len - 4 < 4)
+ {
+ g_writeln("xrdp_process_capset_rail: bad len");
+ return 1;
+ }
+ in_uint32_le(s, i32);
+ self->client_info.rail_support_level = i32;
+ g_writeln("xrdp_process_capset_rail: rail_support_level %d",
+ self->client_info.rail_support_level);
+ return 0;
+}
+
+/*****************************************************************************/
+static int APP_CC
+xrdp_process_capset_window(struct xrdp_rdp* self, struct stream* s, int len)
+{
+ int i32;
+
+ if (len - 4 < 7)
+ {
+ g_writeln("xrdp_process_capset_window: bad len");
+ return 1;
+ }
+ in_uint32_le(s, i32);
+ self->client_info.wnd_support_level = i32;
+ in_uint8(s, i32);
+ self->client_info.wnd_num_icon_caches = i32;
+ in_uint16_le(s, i32);
+ self->client_info.wnd_num_icon_cache_entries = i32;
+ g_writeln("xrdp_process_capset_window wnd_support_level %d "
+ "wnd_num_icon_caches %d wnd_num_icon_cache_entries %d",
+ self->client_info.wnd_support_level,
+ self->client_info.wnd_num_icon_caches,
+ self->client_info.wnd_num_icon_cache_entries);
+ return 0;
+}
+
+/*****************************************************************************/
int APP_CC
xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s)
{
@@ -915,6 +973,12 @@ xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s)
case 22: /* 22 */
DEBUG(("--22"));
break;
+ case 0x0017: /* 23 CAPSETTYPE_RAIL */
+ xrdp_process_capset_rail(self, s, len);
+ break;
+ case 0x0018: /* 24 CAPSETTYPE_WINDOW */
+ xrdp_process_capset_window(self, s, len);
+ break;
case 26: /* 26 */
DEBUG(("--26"));
break;
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 e9d596cf..41176752 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,26 +521,26 @@ 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);
}
/*****************************************************************************/
static int APP_CC
-get_display_num_from_display(char * display_text)
+get_display_num_from_display(char* display_text)
{
- int index = 0;
- int mode = 0;
- int host_index = 0;
- int disp_index = 0;
- int scre_index = 0;
- char host[256] = "";
- char disp[256] = "";
- char scre[256] = "";
-
- g_memset(host,0,256);
- g_memset(disp,0,256);
- g_memset(scre,0,256);
+ int index;
+ int mode;
+ int host_index;
+ int disp_index;
+ int scre_index;
+ char host[256];
+ char disp[256];
+ char scre[256];
+
+ g_memset(host, 0, 256);
+ g_memset(disp, 0, 256);
+ g_memset(scre, 0, 256);
index = 0;
host_index = 0;
@@ -636,11 +637,35 @@ 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)
+ {
+ switch (error)
+ {
+ case LOG_ERROR_MALLOC:
+ g_writeln("error on malloc. cannot start logging. quitting.");
+ break;
+ case LOG_ERROR_FILE_OPEN:
+ g_writeln("error opening log file [%s]. quitting.",
+ getLogFile(text, 255));
+ break;
+ default:
+ g_writeln("log_start error");
+ break;
+ }
+ g_deinit();
+ 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 +673,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 +690,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 +699,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..a3e83e5f 100644
--- a/sesman/chansrv/clipboard.c
+++ b/sesman/chansrv/clipboard.c
@@ -29,6 +29,8 @@
#include "parse.h"
#include "os_calls.h"
#include "chansrv.h"
+#include "log.h"
+#include "clipboard.h"
static Atom g_clipboard_atom = 0;
static Atom g_clip_property_atom = 0;
@@ -78,7 +80,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 +91,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;
}
@@ -100,10 +102,12 @@ static Time APP_CC
clipboard_get_server_time(void)
{
XEvent xevent;
+ unsigned char no_text[4];
/* append nothing */
+ no_text[0] = 0;
XChangeProperty(g_display, g_wnd, g_get_time_atom, XA_STRING, 8,
- PropModeAppend, "", 0);
+ PropModeAppend, no_text, 0);
/* wait for PropertyNotify */
do
{
@@ -137,7 +141,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 +155,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 +163,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 +173,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 +181,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 +223,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 +242,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;
}
@@ -279,12 +283,11 @@ clipboard_send_data_request(void)
struct stream* s;
int size;
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 +299,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 +322,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 +346,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 +401,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 +415,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;
@@ -491,16 +494,14 @@ static int APP_CC
clipboard_process_format_announce(struct stream* s, int clip_msg_status,
int clip_msg_len)
{
- 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;
@@ -531,16 +532,14 @@ static int APP_CC
clipboard_process_data_response(struct stream* s, int clip_msg_status,
int clip_msg_len)
{
- XEvent xev;
XSelectionRequestEvent* lxev;
twchar* wtext;
twchar wchr;
int len;
int index;
- 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 +590,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 +657,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 +685,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 +811,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 +821,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 +832,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 +849,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 +863,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 +882,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 +894,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 +951,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 +974,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 +1004,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 +1022,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 +1044,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 +1105,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 +1114,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 +1144,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/chansrv/sound.c b/sesman/chansrv/sound.c
index 3d68faff..6a86d97d 100644
--- a/sesman/chansrv/sound.c
+++ b/sesman/chansrv/sound.c
@@ -207,7 +207,6 @@ static int APP_CC
sound_process_training(struct stream* s, int size)
{
int time_diff;
- char buf[256];
print_got_here();
@@ -315,7 +314,6 @@ sound_init(void)
{
char port[256];
int error;
- pthread_t thread;
print_got_here();
LOG(0, ("sound_init:"));
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..e10af26c 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)
@@ -46,18 +46,18 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
if (!skipVchk)
{
- if (0==scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
+ if (0 == scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
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..f93f89ee 100644
--- a/sesman/scp_v1.c
+++ b/sesman/scp_v1.c
@@ -56,9 +56,11 @@ 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");
+ e = scp_v1s_request_password(c, s, "Wrong username and/or password");
switch (e)
{
@@ -83,7 +85,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 +95,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 +109,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,28 +156,28 @@ 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... */
sitem=session_get_bypid(sid);
- if (0==sitem)
+ 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");
+ e = scp_v1s_connection_error(c, "Internal error");
+ log_message(LOG_LEVEL_INFO, "Cannot find session item on the chain");
}
else
{
- display=sitem->display;
+ display = sitem->display;
/*e=scp_v1s_reconnect_session(c, sitem, display);*/
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 +206,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..b882c49d 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)
{
switch (error)
{
case LOG_ERROR_MALLOC:
- g_printf("error on malloc. cannot start logging. quitting.\n");
+ g_writeln("error on malloc. cannot start logging. quitting.");
break;
case LOG_ERROR_FILE_OPEN:
- g_printf("error opening log file [%s]. quitting.\n", g_cfg->log.log_file);
+ g_writeln("error opening log file [%s]. quitting.",
+ getLogFile(text, 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,10 +362,9 @@ main(int argc, char** argv)
if (!daemon)
{
- log_end(&(g_cfg->log));
+ log_end();
}
g_deinit();
return 0;
}
-
diff --git a/sesman/sesman.ini b/sesman/sesman.ini
index 9aa58581..f2a210a4 100644
--- a/sesman/sesman.ini
+++ b/sesman/sesman.ini
@@ -19,9 +19,9 @@ IdleTimeLimit=0
DisconnectedTimeLimit=0
[Logging]
-LogFile=/var/log/xrdp-sesman.log
+LogFile=xrdp-sesman.log
LogLevel=DEBUG
-EnableSyslog=0
+EnableSyslog=1
SyslogLevel=DEBUG
[X11rdp]
diff --git a/sesman/session.c b/sesman/session.c
index 2960a7f7..8acc09c2 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();
@@ -792,7 +828,7 @@ session_get_byuser(char* user, int* cnt, unsigned char flags)
int count;
int index;
- count=0;
+ count = 0;
/*THREAD-FIX require chain lock */
lock_chain_acquire();
@@ -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)
@@ -816,9 +852,9 @@ session_get_byuser(char* user, int* cnt, unsigned char flags)
tmp=tmp->next;
}
- if (count==0)
+ if (count == 0)
{
- (*cnt)=0;
+ (*cnt) = 0;
/*THREAD-FIX release chain lock */
lock_chain_release();
return 0;
@@ -826,9 +862,9 @@ session_get_byuser(char* user, int* cnt, unsigned char flags)
/* malloc() an array of disconnected sessions */
sess=g_malloc(count * sizeof(struct SCP_DISCONNECTED_SESSION),1);
- if (sess==0)
+ if (sess == 0)
{
- (*cnt)=0;
+ (*cnt) = 0;
/*THREAD-FIX release chain lock */
lock_chain_release();
return 0;
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..98a92533 100644
--- a/sesman/thread.c
+++ b/sesman/thread.c
@@ -22,7 +22,7 @@
* @file thread.c
* @brief thread stuff...
* @author Simone Fedele
- *
+ *
*/
#include "sesman.h"
@@ -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;
@@ -100,13 +100,13 @@ thread_session_update_start(void)
int ret;
//starts the session update thread
//that checks for idle time, destroys sessions, ecc...
-
-#warning this thread should always request lock_fork before read or write
+
+#warning this thread should always request lock_fork before read or write
#warning (so we can Fork() In Peace)
ret = pthread_create(&g_thread_updater, NULL, , "");
pthread_detach(g_thread_updater);
- if (ret==0)
+ if (ret == 0)
{
log_message(&(g_cfg->log), LOG_LEVEL_INFO, "session update thread started successfully");
return 0;
@@ -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;
@@ -148,9 +148,9 @@ thread_scp_start(int skt)
//ret = pthread_create(&th, NULL, scp_process_start, (void*) (&g_thread_sck));
pthread_detach(th);
- if (ret == 0)
+ 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,18 +158,17 @@ 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..22f20c23 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))
@@ -142,7 +142,7 @@ int main(int argc, char** argv)
g_tcp_close(sock);
scp_session_destroy(s);
scp_connection_destroy(c);
- log_end(&logging);
+ log_end();
return 0;
}
diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c
index 4382e160..c0784ba3 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();
@@ -206,7 +206,7 @@ menuSelect(tui32 choices)
ret = scanf("%u", &sel);
- while ((ret==0) || (sel > choices))
+ while ((ret == 0) || (sel > choices))
{
g_printf("invalid choice.");
ret = scanf("%u", &sel);
diff --git a/sesman/verify_user.c b/sesman/verify_user.c
index cdc60b47..aaa1515c 100644
--- a/sesman/verify_user.c
+++ b/sesman/verify_user.c
@@ -302,21 +302,21 @@ auth_account_disabled(struct spwd* stp)
{
int today;
- if (0==stp)
+ if (0 == stp)
{
/* if an invalid struct was passed we assume a disabled account */
return 1;
}
- today=g_time1()/SECS_PER_DAY;
+ 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..fd5ba25f 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 \
-connections", 0);
+ 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,12 +874,12 @@ 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 */
@@ -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 */
{
@@ -906,14 +912,25 @@ connections", 0);
{
rfbEncryptBytes(s->data, v->password);
error = lib_send(v, s->data, 16);
+ check_sec_result = 1; // not needed
}
}
+ 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 */
@@ -924,42 +941,58 @@ connections", 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,19 +1144,19 @@ 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/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h
index 5cd84a5d..0da7d967 100644
--- a/xorg/X11R7.6/rdp/rdp.h
+++ b/xorg/X11R7.6/rdp/rdp.h
@@ -128,6 +128,11 @@ struct _rdpScreenInfoRec
/* Window Procedures */
CreateWindowProcPtr CreateWindow;
DestroyWindowProcPtr DestroyWindow;
+ PositionWindowProcPtr PositionWindow;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ WindowExposuresProcPtr WindowExposures;
CreateColormapProcPtr CreateColormap;
DestroyColormapProcPtr DestroyColormap;
@@ -252,6 +257,16 @@ Bool
rdpCreateWindow(WindowPtr pWindow);
Bool
rdpDestroyWindow(WindowPtr pWindow);
+Bool
+rdpPositionWindow(WindowPtr pWindow, int x, int y);
+Bool
+rdpRealizeWindow(WindowPtr pWindow);
+Bool
+rdpUnrealizeWindow(WindowPtr pWindow);
+Bool
+rdpChangeWindowAttributes(WindowPtr pWindow, unsigned long mask);
+void
+rdpWindowExposures(WindowPtr pWindow, RegionPtr pRegion, RegionPtr pBSRegion);
Bool
rdpCreateGC(GCPtr pGC);
diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c
index f35e4de1..7cc7c66a 100644
--- a/xorg/X11R7.6/rdp/rdpdraw.c
+++ b/xorg/X11R7.6/rdp/rdpdraw.c
@@ -452,7 +452,7 @@ rdpCreateWindow(WindowPtr pWindow)
rdpWindowRec* priv;
Bool rv;
- //ErrorF("rdpCreateWindow:\n");
+ ErrorF("rdpCreateWindow:\n");
priv = GETWINPRIV(pWindow);
//ErrorF(" %p status %d\n", priv, priv->status);
pScreen = pWindow->drawable.pScreen;
@@ -470,7 +470,7 @@ rdpDestroyWindow(WindowPtr pWindow)
rdpWindowRec* priv;
Bool rv;
- //ErrorF("rdpDestroyWindow:\n");
+ ErrorF("rdpDestroyWindow:\n");
priv = GETWINPRIV(pWindow);
pScreen = pWindow->drawable.pScreen;
pScreen->DestroyWindow = g_rdpScreen.DestroyWindow;
@@ -481,6 +481,89 @@ rdpDestroyWindow(WindowPtr pWindow)
/******************************************************************************/
Bool
+rdpPositionWindow(WindowPtr pWindow, int x, int y)
+{
+ ScreenPtr pScreen;
+ rdpWindowRec* priv;
+ Bool rv;
+
+ ErrorF("rdpPositionWindow:\n");
+ priv = GETWINPRIV(pWindow);
+ pScreen = pWindow->drawable.pScreen;
+ pScreen->PositionWindow = g_rdpScreen.PositionWindow;
+ rv = pScreen->PositionWindow(pWindow, x, y);
+ pScreen->PositionWindow = rdpPositionWindow;
+ return rv;
+}
+
+/******************************************************************************/
+Bool
+rdpRealizeWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen;
+ rdpWindowRec* priv;
+ Bool rv;
+
+ ErrorF("rdpRealizeWindow:\n");
+ priv = GETWINPRIV(pWindow);
+ pScreen = pWindow->drawable.pScreen;
+ pScreen->RealizeWindow = g_rdpScreen.RealizeWindow;
+ rv = pScreen->RealizeWindow(pWindow);
+ pScreen->RealizeWindow = rdpRealizeWindow;
+ return rv;
+}
+
+/******************************************************************************/
+Bool
+rdpUnrealizeWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen;
+ rdpWindowRec* priv;
+ Bool rv;
+
+ ErrorF("rdpUnrealizeWindow:\n");
+ priv = GETWINPRIV(pWindow);
+ pScreen = pWindow->drawable.pScreen;
+ pScreen->UnrealizeWindow = g_rdpScreen.UnrealizeWindow;
+ rv = pScreen->UnrealizeWindow(pWindow);
+ pScreen->UnrealizeWindow = rdpUnrealizeWindow;
+ return rv;
+}
+
+/******************************************************************************/
+Bool
+rdpChangeWindowAttributes(WindowPtr pWindow, unsigned long mask)
+{
+ ScreenPtr pScreen;
+ rdpWindowRec* priv;
+ Bool rv;
+
+ ErrorF("rdpChangeWindowAttributes:\n");
+ priv = GETWINPRIV(pWindow);
+ pScreen = pWindow->drawable.pScreen;
+ pScreen->ChangeWindowAttributes = g_rdpScreen.ChangeWindowAttributes;
+ rv = pScreen->ChangeWindowAttributes(pWindow, mask);
+ pScreen->ChangeWindowAttributes = rdpChangeWindowAttributes;
+ return rv;
+}
+
+/******************************************************************************/
+void
+rdpWindowExposures(WindowPtr pWindow, RegionPtr pRegion, RegionPtr pBSRegion)
+{
+ ScreenPtr pScreen;
+ rdpWindowRec* priv;
+
+ ErrorF("rdpWindowExposures:\n");
+ priv = GETWINPRIV(pWindow);
+ pScreen = pWindow->drawable.pScreen;
+ pScreen->WindowExposures = g_rdpScreen.WindowExposures;
+ pScreen->WindowExposures(pWindow, pRegion, pBSRegion);
+ pScreen->WindowExposures = rdpWindowExposures;
+}
+
+/******************************************************************************/
+Bool
rdpCreateGC(GCPtr pGC)
{
rdpGCRec* priv;
diff --git a/xorg/X11R7.6/rdp/rdpmain.c b/xorg/X11R7.6/rdp/rdpmain.c
index b8b3840f..c453cb05 100644
--- a/xorg/X11R7.6/rdp/rdpmain.c
+++ b/xorg/X11R7.6/rdp/rdpmain.c
@@ -347,6 +347,11 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char** argv)
/* Window Procedures */
g_rdpScreen.CreateWindow = pScreen->CreateWindow;
g_rdpScreen.DestroyWindow = pScreen->DestroyWindow;
+ g_rdpScreen.ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
+ g_rdpScreen.RealizeWindow = pScreen->RealizeWindow;
+ g_rdpScreen.UnrealizeWindow = pScreen->UnrealizeWindow;
+ g_rdpScreen.PositionWindow = pScreen->PositionWindow;
+ g_rdpScreen.WindowExposures = pScreen->WindowExposures;
g_rdpScreen.CopyWindow = pScreen->CopyWindow;
g_rdpScreen.ClearToBackground = pScreen->ClearToBackground;
@@ -390,6 +395,11 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char** argv)
/* Window Procedures */
pScreen->CreateWindow = rdpCreateWindow;
pScreen->DestroyWindow = rdpDestroyWindow;
+ pScreen->ChangeWindowAttributes = rdpChangeWindowAttributes;
+ pScreen->RealizeWindow = rdpRealizeWindow;
+ pScreen->UnrealizeWindow = rdpUnrealizeWindow;
+ pScreen->PositionWindow = rdpPositionWindow;
+ pScreen->WindowExposures = rdpWindowExposures;
}
pScreen->CopyWindow = rdpCopyWindow;
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 ac2aae45..ec019222 100644
--- a/xrdp/xrdp.c
+++ b/xrdp/xrdp.c
@@ -21,6 +21,7 @@
*/
#include "xrdp.h"
+#include "log.h"
#define THREAD_WAITING 100
@@ -282,6 +283,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;
@@ -325,6 +328,29 @@ 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)
+ {
+ switch (error)
+ {
+ case LOG_ERROR_MALLOC:
+ g_writeln("error on malloc. cannot start logging. quitting.");
+ break;
+ case LOG_ERROR_FILE_OPEN:
+ g_writeln("error opening log file [%s]. quitting.",
+ getLogFile(text, 255));
+ break;
+ default:
+ g_writeln("log_start error");
+ break;
+ }
+ g_deinit();
+ 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..7cab7000 100644
--- a/xrdp/xrdp.ini
+++ b/xrdp/xrdp.ini
@@ -19,6 +19,14 @@ fork=yes
#autorun=xrdp7
#hidelogwindow=yes
+[Logging]
+LogFile=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_listen.c b/xrdp/xrdp_listen.c
index 0270d337..f6dba5c8 100644
--- a/xrdp/xrdp_listen.c
+++ b/xrdp/xrdp_listen.c
@@ -282,7 +282,6 @@ xrdp_listen_main_loop(struct xrdp_listen* self)
tbus robjs[8];
tbus term_obj;
tbus sync_obj;
- tbus sck_obj;
tbus done_obj;
self->status = 1;
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
diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c
index 84a4a851..4060fd86 100644
--- a/xrdp/xrdp_mm.c
+++ b/xrdp/xrdp_mm.c
@@ -703,7 +703,7 @@ xrdp_mm_connect_chansrv(struct xrdp_mm* self, char* ip, char* port)
self->usechansrv = 1;
/* connect channel redir */
- if ((ip == 0) || (strcmp(ip, "127.0.0.1") == 0) || (ip[0] == 0))
+ if ((ip == 0) || (g_strcmp(ip, "127.0.0.1") == 0) || (ip[0] == 0))
{
/* unix socket */
self->chan_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
@@ -755,8 +755,6 @@ xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s)
int ok;
int display;
int rv;
- int uid;
- int gid;
char text[256];
char ip[256];
char port[256];
@@ -778,7 +776,7 @@ xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s)
xrdp_wm_set_login_mode(self->wm, 10);
self->wm->dragging = 0;
/* connect channel redir */
- if ((ip == 0) || (strcmp(ip, "127.0.0.1") == 0) || (ip[0] == 0))
+ if ((ip == 0) || (g_strcmp(ip, "127.0.0.1") == 0) || (ip[0] == 0))
{
g_snprintf(port, 255, "/tmp/.xrdp/xrdp_chansrv_socket_%d", 7200 + display);
}
@@ -1055,7 +1053,7 @@ xrdp_mm_connect(struct xrdp_mm* self)
ip, port);
g_writeln(errstr);
xrdp_wm_log_msg(self->wm, errstr);
- rv = 1 ; /* failure */
+ rv = 1; /* failure */
}
}else{
g_writeln("Failure setting up module");
diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c
index b7caee31..b91be16d 100644
--- a/xrdp/xrdp_painter.c
+++ b/xrdp/xrdp_painter.c
@@ -127,6 +127,7 @@ xrdp_painter_font_needed(struct xrdp_painter* self)
return 0;
}
+#if 0
/*****************************************************************************/
/* returns boolean, true if there is something to draw */
static int APP_CC
@@ -178,6 +179,7 @@ xrdp_painter_clip_adj(struct xrdp_painter* self, int* x, int* y,
*y = *y + dy;
return 1;
}
+#endif
/*****************************************************************************/
int APP_CC
@@ -200,6 +202,7 @@ xrdp_painter_clr_clip(struct xrdp_painter* self)
return 0;
}
+#if 0
/*****************************************************************************/
static int APP_CC
xrdp_painter_rop(int rop, int src, int dst)
@@ -225,6 +228,7 @@ xrdp_painter_rop(int rop, int src, int dst)
}
return dst;
}
+#endif
/*****************************************************************************/
int APP_CC