Merge pull request #390 from proski/june21

Cleanups and C++ compatibility
master
jsorg71 8 years ago committed by GitHub
commit 8353baab3d

@ -19,6 +19,10 @@
#if !defined(ARCH_H) #if !defined(ARCH_H)
#define ARCH_H #define ARCH_H
#if defined(HAVE_CONFIG_H)
#include "config_ac.h"
#endif
/* you can define L_ENDIAN or B_ENDIAN and NEED_ALIGN or NO_NEED_ALIGN /* you can define L_ENDIAN or B_ENDIAN and NEED_ALIGN or NO_NEED_ALIGN
in the makefile to override */ in the makefile to override */
@ -109,7 +113,6 @@ typedef __int64 tbus;
#else #else
typedef long tbus; typedef long tbus;
#endif #endif
typedef tbus thandle;
typedef tbus tintptr; typedef tbus tintptr;
/* wide char, socket */ /* wide char, socket */
#if defined(_WIN32) #if defined(_WIN32)
@ -125,4 +128,22 @@ typedef signed long long tsi64;
#endif #endif
#endif /* DEFINED_Ts */ #endif /* DEFINED_Ts */
/* format string verification */
#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
#define printflike(arg_format, arg_first_check) \
__attribute__((__format__(__printf__, arg_format, arg_first_check)))
#else
#define printflike(arg_format, arg_first_check)
#endif
/* module interface */
#ifdef __cplusplus
extern "C" {
#endif
tintptr mod_init();
int mod_exit(tintptr);
#ifdef __cplusplus
}
#endif
#endif #endif

@ -212,12 +212,6 @@ internal_log_end(struct log_config *l_cfg)
l_cfg->log_file = 0; l_cfg->log_file = 0;
} }
if (0 != l_cfg->program_name)
{
g_free(l_cfg->program_name);
l_cfg->program_name = 0;
}
ret = LOG_STARTUP_OK; ret = LOG_STARTUP_OK;
return ret; return ret;
} }
@ -336,7 +330,7 @@ internal_config_read_logging(int file, struct log_config *lc,
list_clear(param_n); list_clear(param_n);
/* setting defaults */ /* setting defaults */
lc->program_name = g_strdup(applicationName); lc->program_name = applicationName;
lc->log_file = 0; lc->log_file = 0;
lc->fd = 0; lc->fd = 0;
lc->log_level = LOG_LEVEL_DEBUG; lc->log_level = LOG_LEVEL_DEBUG;
@ -401,7 +395,7 @@ enum logReturns DEFAULT_CC
internalInitAndAllocStruct(void) internalInitAndAllocStruct(void)
{ {
enum logReturns ret = LOG_GENERAL_ERROR; enum logReturns ret = LOG_GENERAL_ERROR;
g_staticLogConfig = g_malloc(sizeof(struct log_config), 1); g_staticLogConfig = g_new0(struct log_config, 1);
if (g_staticLogConfig != NULL) if (g_staticLogConfig != NULL)
{ {
@ -455,7 +449,7 @@ log_start_from_param(const struct log_config *iniParams)
g_staticLogConfig->log_level = iniParams->log_level; g_staticLogConfig->log_level = iniParams->log_level;
g_staticLogConfig->log_lock = iniParams->log_lock; g_staticLogConfig->log_lock = iniParams->log_lock;
g_staticLogConfig->log_lock_attr = iniParams->log_lock_attr; g_staticLogConfig->log_lock_attr = iniParams->log_lock_attr;
g_staticLogConfig->program_name = g_strdup(iniParams->program_name); g_staticLogConfig->program_name = iniParams->program_name;
g_staticLogConfig->syslog_level = iniParams->syslog_level; g_staticLogConfig->syslog_level = iniParams->syslog_level;
ret = internal_log_start(g_staticLogConfig); ret = internal_log_start(g_staticLogConfig);

@ -65,12 +65,12 @@ enum logReturns
struct log_config struct log_config
{ {
char *program_name; const char *program_name;
char *log_file; char *log_file;
int fd; int fd;
unsigned int log_level; enum logLevels log_level;
int enable_syslog; int enable_syslog;
unsigned int syslog_level; enum logLevels syslog_level;
pthread_mutex_t log_lock; pthread_mutex_t log_lock;
pthread_mutexattr_t log_lock_attr; pthread_mutexattr_t log_lock_attr;
}; };
@ -171,7 +171,7 @@ log_end(void);
* @return * @return
*/ */
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
log_message(const enum logLevels lvl, const char *msg, ...); log_message(const enum logLevels lvl, const char *msg, ...) printflike(2, 3);
/** /**
* *

@ -402,7 +402,7 @@ g_tcp_set_keepalive(int sck)
/*****************************************************************************/ /*****************************************************************************/
/* returns a newly created socket or -1 on error */ /* returns a newly created socket or -1 on error */
/* in win32 a socket is an unsigned int, in linux, its an int */ /* in win32 a socket is an unsigned int, in linux, it's an int */
int APP_CC int APP_CC
g_tcp_socket(void) g_tcp_socket(void)
{ {
@ -671,7 +671,6 @@ int APP_CC
g_tcp_connect(int sck, const char *address, const char *port) g_tcp_connect(int sck, const char *address, const char *port)
{ {
int res = 0; int res = 0;
char errorMsg[256];
struct addrinfo p; struct addrinfo p;
struct addrinfo *h = (struct addrinfo *)NULL; struct addrinfo *h = (struct addrinfo *)NULL;
struct addrinfo *rp = (struct addrinfo *)NULL; struct addrinfo *rp = (struct addrinfo *)NULL;
@ -699,9 +698,8 @@ g_tcp_connect(int sck, const char *address, const char *port)
} }
if (res != 0) if (res != 0)
{ {
snprintf(errorMsg, 255, "g_tcp_connect: getaddrinfo() failed: %s", log_message(LOG_LEVEL_ERROR, "g_tcp_connect: getaddrinfo() failed: %s",
gai_strerror(res)); gai_strerror(res));
log_message(LOG_LEVEL_ERROR, errorMsg);
} }
if (res > -1) if (res > -1)
{ {
@ -991,7 +989,7 @@ g_tcp_accept(int sck)
{ {
snprintf(ipAddr, 255, "A connection received from: %s port %d", snprintf(ipAddr, 255, "A connection received from: %s port %d",
inet_ntoa(s.sin_addr), ntohs(s.sin_port)); inet_ntoa(s.sin_addr), ntohs(s.sin_port));
log_message(LOG_LEVEL_INFO,ipAddr); log_message(LOG_LEVEL_INFO, "%s", ipAddr);
} }
return ret ; return ret ;
} }
@ -1016,7 +1014,7 @@ g_sck_accept(int sck, char *addr, int addr_bytes, char *port, int port_bytes)
{ {
g_snprintf(ipAddr, 255, "A connection received from: %s port %d", g_snprintf(ipAddr, 255, "A connection received from: %s port %d",
inet_ntoa(s.sin_addr), ntohs(s.sin_port)); inet_ntoa(s.sin_addr), ntohs(s.sin_port));
log_message(LOG_LEVEL_INFO,ipAddr); log_message(LOG_LEVEL_INFO, "%s", ipAddr);
if (s.sin_family == AF_INET) if (s.sin_family == AF_INET)
{ {
g_snprintf(addr, addr_bytes, "%s", inet_ntoa(s.sin_addr)); g_snprintf(addr, addr_bytes, "%s", inet_ntoa(s.sin_addr));
@ -1815,7 +1813,7 @@ g_file_read(int fd, char *ptr, int len)
/*****************************************************************************/ /*****************************************************************************/
/* write to file, returns the number of bytes written or -1 on error */ /* write to file, returns the number of bytes written or -1 on error */
int APP_CC int APP_CC
g_file_write(int fd, char *ptr, int len) g_file_write(int fd, const char *ptr, int len)
{ {
#if defined(_WIN32) #if defined(_WIN32)
@ -1952,7 +1950,7 @@ g_get_current_dir(char *dirname, int maxlen)
/*****************************************************************************/ /*****************************************************************************/
/* returns error, zero on success and -1 on failure */ /* returns error, zero on success and -1 on failure */
int APP_CC int APP_CC
g_set_current_dir(char *dirname) g_set_current_dir(const char *dirname)
{ {
#if defined(_WIN32) #if defined(_WIN32)
@ -2121,7 +2119,7 @@ g_strlen(const char *text)
/*****************************************************************************/ /*****************************************************************************/
/* locates char in text */ /* locates char in text */
char* APP_CC const char *APP_CC
g_strchr(const char* text, int c) g_strchr(const char* text, int c)
{ {
if (text == NULL) if (text == NULL)
@ -2218,7 +2216,7 @@ g_strdup(const char *in)
char *APP_CC char *APP_CC
g_strndup(const char *in, const unsigned int maxlen) g_strndup(const char *in, const unsigned int maxlen)
{ {
int len; unsigned int len;
char *p; char *p;
if (in == 0) if (in == 0)
@ -2400,7 +2398,7 @@ g_htoi(char *str)
int APP_CC int APP_CC
g_pos(const char *str, const char *to_find) g_pos(const char *str, const char *to_find)
{ {
char *pp; const char *pp;
pp = strstr(str, to_find); pp = strstr(str, to_find);
@ -3269,7 +3267,7 @@ g_save_to_bmp(const char* filename, char* data, int stride_bytes,
data -= stride_bytes; data -= stride_bytes;
if ((depth == 24) && (bits_per_pixel == 32)) if ((depth == 24) && (bits_per_pixel == 32))
{ {
line = malloc(file_stride_bytes); line = (char *) malloc(file_stride_bytes);
memset(line, 0, file_stride_bytes); memset(line, 0, file_stride_bytes);
for (index = 0; index < height; index++) for (index = 0; index < height; index++)
{ {

@ -21,14 +21,11 @@
#if !defined(OS_CALLS_H) #if !defined(OS_CALLS_H)
#define OS_CALLS_H #define OS_CALLS_H
#if defined(HAVE_CONFIG_H)
#include "config_ac.h"
#endif
#ifndef NULL #ifndef NULL
#define NULL 0 #define NULL 0
#endif #endif
#include <stdlib.h>
#include "arch.h" #include "arch.h"
#define g_tcp_can_recv g_sck_can_recv #define g_tcp_can_recv g_sck_can_recv
@ -45,13 +42,6 @@
#define g_tcp_select g_sck_select #define g_tcp_select g_sck_select
#define g_close_wait_obj g_delete_wait_obj #define g_close_wait_obj g_delete_wait_obj
#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
#define printflike(arg_format, arg_first_check) \
__attribute__((__format__(__printf__, arg_format, arg_first_check)))
#else
#define printflike(arg_format, arg_first_check)
#endif
int APP_CC g_rm_temp_dir(void); int APP_CC g_rm_temp_dir(void);
int APP_CC g_mk_temp_dir(const char* app_name); int APP_CC g_mk_temp_dir(const char* app_name);
void APP_CC g_init(const char* app_name); void APP_CC g_init(const char* app_name);
@ -115,14 +105,14 @@ int APP_CC g_file_open_ex(const char *file_name, int aread, int awrite,
int acreate, int atrunc); int acreate, int atrunc);
int APP_CC g_file_close(int fd); int APP_CC g_file_close(int fd);
int APP_CC g_file_read(int fd, char* ptr, int len); int APP_CC g_file_read(int fd, char* ptr, int len);
int APP_CC g_file_write(int fd, char* ptr, int len); int APP_CC g_file_write(int fd, const char *ptr, int len);
int APP_CC g_file_seek(int fd, int offset); int APP_CC g_file_seek(int fd, int offset);
int APP_CC g_file_lock(int fd, int start, int len); int APP_CC g_file_lock(int fd, int start, int len);
int APP_CC g_chmod_hex(const char* filename, int flags); int APP_CC g_chmod_hex(const char* filename, int flags);
int APP_CC g_chown(const char* name, int uid, int gid); int APP_CC g_chown(const char* name, int uid, int gid);
int APP_CC g_mkdir(const char* dirname); int APP_CC g_mkdir(const char* dirname);
char* APP_CC g_get_current_dir(char* dirname, int maxlen); char* APP_CC g_get_current_dir(char* dirname, int maxlen);
int APP_CC g_set_current_dir(char* dirname); int APP_CC g_set_current_dir(const char *dirname);
int APP_CC g_file_exist(const char* filename); int APP_CC g_file_exist(const char* filename);
int APP_CC g_directory_exist(const char* dirname); int APP_CC g_directory_exist(const char* dirname);
int APP_CC g_create_dir(const char* dirname); int APP_CC g_create_dir(const char* dirname);
@ -131,7 +121,7 @@ int APP_CC g_remove_dir(const char* dirname);
int APP_CC g_file_delete(const char* filename); int APP_CC g_file_delete(const char* filename);
int APP_CC g_file_get_size(const char* filename); int APP_CC g_file_get_size(const char* filename);
int APP_CC g_strlen(const char* text); int APP_CC g_strlen(const char* text);
char* APP_CC g_strchr(const char* text, int c); const char *APP_CC g_strchr(const char *text, int c);
char* APP_CC g_strcpy(char* dest, const char* src); char* APP_CC g_strcpy(char* dest, const char* src);
char* APP_CC g_strncpy(char* dest, const char* src, int len); char* APP_CC g_strncpy(char* dest, const char* src, int len);
char* APP_CC g_strcat(char* dest, const char* src); char* APP_CC g_strcat(char* dest, const char* src);
@ -194,4 +184,10 @@ int APP_CC g_shmdt(const void *shmaddr);
int APP_CC g_gethostname(char *name, int len); int APP_CC g_gethostname(char *name, int len);
int APP_CC g_mirror_memcpy(void *dst, const void *src, int len); int APP_CC g_mirror_memcpy(void *dst, const void *src, int len);
/* glib-style wrappers */
#define g_new(struct_type, n_structs) \
(struct_type *) malloc(sizeof(struct_type) * (n_structs))
#define g_new0(struct_type, n_structs) \
(struct_type *) calloc((n_structs), sizeof(struct_type))
#endif #endif

@ -111,7 +111,7 @@ ssl_sha1_clear(void *sha1_info)
/*****************************************************************************/ /*****************************************************************************/
void APP_CC void APP_CC
ssl_sha1_transform(void *sha1_info, char *data, int len) ssl_sha1_transform(void *sha1_info, const char *data, int len)
{ {
SHA1_Update((SHA_CTX *)sha1_info, data, len); SHA1_Update((SHA_CTX *)sha1_info, data, len);
} }
@ -187,7 +187,7 @@ ssl_des3_decrypt_info_create(const char *key, const char* ivec)
const tui8 *lkey; const tui8 *lkey;
const tui8 *livec; const tui8 *livec;
des3_ctx = g_malloc(sizeof(EVP_CIPHER_CTX), 1); des3_ctx = g_new0(EVP_CIPHER_CTX, 1);
EVP_CIPHER_CTX_init(des3_ctx); EVP_CIPHER_CTX_init(des3_ctx);
lkey = (const tui8 *) key; lkey = (const tui8 *) key;
livec = (const tui8 *) ivec; livec = (const tui8 *) ivec;
@ -560,7 +560,7 @@ ssl_tls_create(struct trans *trans, const char *key, const char *cert)
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
ssl_tls_print_error(char *func, SSL *connection, int value) ssl_tls_print_error(const char *func, SSL *connection, int value)
{ {
switch (SSL_get_error(connection, value)) switch (SSL_get_error(connection, value))
{ {

@ -41,7 +41,7 @@ ssl_sha1_info_delete(void* sha1_info);
void APP_CC void APP_CC
ssl_sha1_clear(void* sha1_info); ssl_sha1_clear(void* sha1_info);
void APP_CC void APP_CC
ssl_sha1_transform(void* sha1_info, char* data, int len); ssl_sha1_transform(void* sha1_info, const char *data, int len);
void APP_CC void APP_CC
ssl_sha1_complete(void* sha1_info, char* data); ssl_sha1_complete(void* sha1_info, char* data);
void* APP_CC void* APP_CC
@ -84,8 +84,8 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
/* ssl_tls */ /* ssl_tls */
struct ssl_tls struct ssl_tls
{ {
void *ssl; /* SSL * */ struct ssl_st *ssl; /* SSL * */
void *ctx; /* SSL_CTX * */ struct ssl_ctx_st *ctx; /* SSL_CTX * */
char *cert; char *cert;
char *key; char *key;
struct trans *trans; struct trans *trans;

@ -28,7 +28,7 @@
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
trans_tls_recv(struct trans *self, void *ptr, int len) trans_tls_recv(struct trans *self, char *ptr, int len)
{ {
if (self->tls == NULL) if (self->tls == NULL)
{ {
@ -39,7 +39,7 @@ trans_tls_recv(struct trans *self, void *ptr, int len)
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
trans_tls_send(struct trans *self, const void *data, int len) trans_tls_send(struct trans *self, const char *data, int len)
{ {
if (self->tls == NULL) if (self->tls == NULL)
{ {
@ -61,14 +61,14 @@ trans_tls_can_recv(struct trans *self, int sck, int millis)
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
trans_tcp_recv(struct trans *self, void *ptr, int len) trans_tcp_recv(struct trans *self, char *ptr, int len)
{ {
return g_tcp_recv(self->sck, ptr, len, 0); return g_tcp_recv(self->sck, ptr, len, 0);
} }
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
trans_tcp_send(struct trans *self, const void *data, int len) trans_tcp_send(struct trans *self, const char *data, int len)
{ {
return g_tcp_send(self->sck, data, len, 0); return g_tcp_send(self->sck, data, len, 0);
} }

@ -41,8 +41,8 @@ typedef int (DEFAULT_CC *ttrans_data_in)(struct trans* self);
typedef int (DEFAULT_CC *ttrans_conn_in)(struct trans* self, typedef int (DEFAULT_CC *ttrans_conn_in)(struct trans* self,
struct trans* new_self); struct trans* new_self);
typedef int (DEFAULT_CC *tis_term)(void); typedef int (DEFAULT_CC *tis_term)(void);
typedef int (APP_CC *trans_recv_proc) (struct trans *self, void *ptr, int len); typedef int (APP_CC *trans_recv_proc) (struct trans *self, char *ptr, int len);
typedef int (APP_CC *trans_send_proc) (struct trans *self, const void *data, int len); typedef int (APP_CC *trans_send_proc) (struct trans *self, const char *data, int len);
typedef int (APP_CC *trans_can_recv_proc) (struct trans *self, int sck, int millis); typedef int (APP_CC *trans_can_recv_proc) (struct trans *self, int sck, int millis);
/* optional source info */ /* optional source info */

@ -14,6 +14,7 @@ PKG_PROG_PKG_CONFIG
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AX_CFLAGS_WARN_ALL AX_CFLAGS_WARN_ALL
AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
AX_GCC_FUNC_ATTRIBUTE([format]) AX_GCC_FUNC_ATTRIBUTE([format])
case $host_os in case $host_os in

@ -1,206 +1,225 @@
.\" .\"
.TH "sesman.ini" "5" "0.1.0" "xrdp team" "" .TH "sesman.ini" "5" "0.1.0" "xrdp team" ""
.SH "NAME" .SH "NAME"
\fBsesman.ini\fR \- Configuration file for \fBsesman\fR(8) \fBsesman.ini\fR \- Configuration file for \fBxrdp-sesman\fR(8)
.SH "DESCRIPTION" .SH "DESCRIPTION"
This is the man page for \fBsesman.ini\fR, \fBsesman\fR(8) configuration file. \fBsesman.ini\fR consists of several sections. Each section starts with
It is composed by a number of sections, each one composed by a section name, enclosed by square brackets, folowed by a list of \fI<parameter>\fR=\fI<value>\fR lines. the section name in square brackets, followed by a list of
\fIparameter\fR=\fIvalue\fR lines. Following sections are recognized:
\fBsesman.ini\fR supports the following sections: .TP
\fB[Globals]\fR
Global configuration
.TP .TP
\fB[Globals]\fR \- sesman global configuration section, \fB[Logging]\fR
Logging subsystem
.TP .TP
\fB[Logging]\fR \- logging subsystem parameters \fB[Sessions]\fR
Session management
.TP .TP
\fB[Security]\fR \- Access control parameters \fB[Security]\fR
Access control
.TP .TP
\fB[Sessions]\fR \- Session management parameters \fB[X11rdp]\fR, \fB[Xvnc]\fR, \fB[Xorg]\fR
X11 server settings for supported servers
.LP .TP
All options and values (except for file names and paths) are case insensitive, and are described in detail below. \fB[Chansrv]\fR
Settings for xrdp-chansrv(8)
.LP .TP
For any of the following parameter, if it's specified more than one time the last entry encountered will be used. \fB[SessionVariables]\fR
Environment variables for the session
\fBNOTE\fR: if any of these options is specified outside its section, it will be \fIignored\fR. .LP
All parameters and values (except for file names and paths) are case
insensitive, and are described in detail below. If any parameter is
specified more than once, the last entry will be used. Options specified
outside their proper section will be \fIignored\fR.
.SH "GLOBALS" .SH "GLOBALS"
The options to be specified in the \fB[globals]\fR section are the following: Following parameters can be used in the \fB[Globals]\fR section.
.TP .TP
\fBListenAddress\fR=\fIip address\fR \fBListenAddress\fR=\fIip address\fR
Specifies sesman listening address. Default is 0.0.0.0 (all interfaces) xrdp-sesman listening address. Default is 0.0.0.0 (all interfaces).
.TP .TP
\fBListenPort\fR=\fIport number\fR \fBListenPort\fR=\fIport number\fR
Specifies sesman listening port. Default is 3350 xrdp-sesman listening port. Default is 3350.
.TP .TP
\fBEnableUserWindowManager\fR=\fI[0|1]\fR \fBEnableUserWindowManager\fR=\fI[0|1]\fR
If set to \fB1\fR, \fBtrue\fR or \fByes\fR this option enables user specific window manager, that is, anyone can define it's own script executed by sesman when starting a new session, specified by \fBUserWindowManager\fR If set to \fB1\fR, \fBtrue\fR or \fByes\fR, this option enables user
specific startup script. That is, xrdp-sesman will execute the script
specified by \fBUserWindowManager\fR if it exists.
.TP .TP
\fBUserWindowManager\fR=\fIstartwm.sh\fR \fBUserWindowManager\fR=\fIfilename\fR
This option specifies the script run by sesman when starting a session and per\-user window manager is enabled. Name of the startup script relative to the user's home directory. If
.br present and enabled by \fBEnableUserWindowManager\fR, that script is
The path is relative to user's HOME directory executed instead of \fBDefaultWindowManager\fR.
.TP .TP
\fBDefaultWindowManager\fR=\fI${SESMAN_BIN_DIR}/startwm.sh\fR \fBDefaultWindowManager\fR=\fIfilename\fR
This contains full path to the default window manager startup script used by sesman to start a session Full path to the default startup script used by xrdp-sesman to start a
session if the user script is disabled or missing.
.SH "LOGGING" .SH "LOGGING"
The following parameters can be used in the \fB[logging]\fR section: Following parameters can be used in the \fB[Logging]\fR section.
.TP .TP
\fBLogFile\fR=\fI${SESMAN_LOG_DIR}/sesman.log\fR \fBLogFile\fR=\fIfilename\fR
This options contains the path to logfile. It can be either absolute or relative, and the default is \fI${SESMAN_LOG_DIR}/sesman.log\fR Log file path. It can be either absolute or relative. The default is
\fI./sesman.log\fR
.TP .TP
\fBLogLevel\fR=\fIlevel\fR \fBLogLevel\fR=\fIlevel\fR
This option can have one of the following values: This option can have one of the following values:
\fBCORE\fR or \fB0\fR \- Log only core messages. these messages are _always_ logged, regardless the logging level selected. \fBCORE\fR or \fB0\fR \- Log only core messages. Those messages are
logged \fIregardless\fR of the selected logging level.
\fBERROR\fR or \fB1\fR \- Log only error messages \fBERROR\fR or \fB1\fR \- Log only error messages.
\fBWARNING\fR, \fBWARN\fR or \fB2\fR \- Logs warnings and error messages \fBWARNING\fR, \fBWARN\fR or \fB2\fR \- Logs warnings and error messages.
\fBINFO\fR or \fB3\fR \- Logs errors, warnings and informational messages \fBINFO\fR or \fB3\fR \- Log errors, warnings and informational messages.
\fBDEBUG\fR or \fB4\fR \- Log everything. If \fBsesman\fR is compiled in debug mode, this options will output many more low\-level message, useful for developers \fBDEBUG\fR or \fB4\fR \- Log everything. If xrdp-sesman is compiled in
debug mode, this options will output many more low\-level messages.
.TP .TP
\fBEnableSyslog\fR=\fI[0|1]\fR \fBEnableSyslog\fR=\fI[0|1]\fR
If set to \fB1\fR, \fBtrue\fR or \fByes\fR this option enables logging to syslog. Otherwise syslog is disabled. If set to \fB1\fR, \fBtrue\fR or \fByes\fR, this option enables logging to
syslog.
.TP .TP
\fBSyslogLevel\fR=\fIlevel\fR \fBSyslogLevel\fR=\fIlevel\fR
This option sets the logging level for syslog. It can have the same values of \fBLogLevel\fR. If \fBSyslogLevel\fR is greater than \fBLogLevel\fR, its value is lowered to that of \fBLogLevel\fR. Logging level for syslog. It can have the same values as \fBLogLevel\fR.
If \fBSyslogLevel\fR and \fBLogLevel\fR differ, the least verbose setting
takes effect for syslog.
.SH "SESSIONS" .SH "SESSIONS"
The following parameters can be used in the \fB[Sessions]\fR section: Following parameters can be used in the \fB[Sessions]\fR section.
.TP .TP
\fBX11DisplayOffset\fR=\fI<number>\fR \fBX11DisplayOffset\fR=\fInumber\fR
Specifies the first X display number available for \fBsesman\fP(8). This prevents sesman from interfering with real X11 servers. The default is 10. The first X display number available for xrdp-sesman. This prevents
xrdp-sesman from interfering with real X11 servers. The default is 10.
.TP .TP
\fBMaxSessions\fR=\fI<number>\fR \fBMaxSessions\fR=\fInumber\fR
Sets the maximum number of simultaneous session on terminal server. Sets the maximum number of simultaneous sessions. If not set or set to
.br \fI0\fR, unlimited session are allowed.
If unset or set to \fI0\fR, unlimited session are allowed.
.TP .TP
\fBKillDisconnected\fR=\fI[0|1]\fR \fBKillDisconnected\fR=\fI[0|1]\fR
If set to \fB1\fR, \fBtrue\fR or \fByes\fR, every session will be killed within 60 seconds when the user disconnects. If set to \fB1\fR, \fBtrue\fR or \fByes\fR, every session will be killed
.br within 60 seconds after the user disconnects.
.TP .TP
\fBIdleTimeLimit\fR=\fI<number>\fR \fBIdleTimeLimit\fR=\fInumber\fR
Sets the the time limit before an idle session is disconnected. \fI\This option is currently ignored!\fR Time limit before an idle
.br session is disconnected. If set to \fI0\fR, automatic disconnection is
If set to \fI0\fR, automatic disconnection is disabled. disabled.
.br
\fI\-this option is currently ignored!\-\fR .TP
\fBDisconnectedTimeLimit\fR=\fInumber\fR
.TP Sets the time limit (in seconds) before a disconnected session is killed.
\fBDisconnectedTimeLimit\fR=\fI<number>\fR
Sets the time(in seconds) limit before a disconnected session is killed.
.br
If set to \fI0\fR, automatic killing is disabled. If set to \fI0\fR, automatic killing is disabled.
.br
.TP .TP
\fBPolicy\fR=\fI[Default|UBD|UBI|UBC|UBDI|UBDC]\fR \fBPolicy\fR=\fI[Default|UBD|UBI|UBC|UBDI|UBDC]\fR
Session allocation policy. By Default, a new session is created Session allocation policy. By default, a new session is created
for the combination <User,BitPerPixel> when using Xrdp, and for the combination <User,BitPerPixel> when using Xrdp, and
for the combination <User,BitPerPixel,DisplaySize> when using Xvnc. for the combination <User,BitPerPixel,DisplaySize> when using Xvnc.
This behaviour can be changed by setting session policy to: This behavior can be changed by setting session policy to:
.br .br
.br .br
\fBUBD\fR - session per <User,BitPerPixel,DisplaySize> \fBUBD\fR - session per <User,BitPerPixel,DisplaySize>
.br .br
\fBUBI\fR - session per <User,BitPerPixel,IPAddr> \fBUBI\fR - session per <User,BitPerPixel,IPAddr>
.br .br
\fBUBC\fR - session per <User,BitPerPixel,Connection> \fBUBC\fR - session per <User,BitPerPixel,Connection>
.br .br
\fBUBDI\fR - session per <User,BitPerPixel,DisplaySize,IPAddr> \fBUBDI\fR - session per <User,BitPerPixel,DisplaySize,IPAddr>
.br .br
\fBUBDC\fR - session per <User,BitPerPixel,DisplaySize,Connection> \fBUBDC\fR - session per <User,BitPerPixel,DisplaySize,Connection>
.br .br
.br .br
Note that the criteria <User,BitPerPixel> can not be turned off Note that the \fBUser\fR and \fBBitPerPixel\fR criteria cannot be turned
and <DisplaySize> will always be checkt when for Xvnc connections. off. For Xvnc connections, \fBDisplaySize\fR is always enabled as well.
.br .br
.SH "SECURITY" .SH "SECURITY"
The following parameters can be used in the \fB[Sessions]\fR section: Following parameters can be used in the \fB[Security]\fR section.
.TP .TP
\fBAllowRootLogin\fR=\fI[0|1]\fR \fBAllowRootLogin\fR=\fI[0|1]\fR
If set to \fB1\fR, \fBtrue\fR or \fByes\fR enables root login on the terminal server If set to \fB1\fR, \fBtrue\fR or \fByes\fR, enables root login on the
terminal server.
.TP
\fBMaxLoginRetry\fR=\fI[0|1]\fR .TP
The number of login attempts that are allowed on terminal server. If set to \fI0\fR, unlimited attempts are allowed. The default value for this field is \fI3\fR. \fBMaxLoginRetry\fR=\fInumber\fR
The number of login attempts that are allowed on terminal server. If set
.TP to \fI0\fR, unlimited attempts are allowed. The default value for this
\fBTerminalServerUsers\fR=\fItsusers\fR field is \fI3\fR.
Only the users belonging to the group \fItsusers\fR are allowed to login on terminal server.
.br .TP
If unset or set to an invalid or non\-existent group, login for all users is enabled. \fBTerminalServerUsers\fR=\fIgroup\fR
Only the users belonging to the specified group are allowed to login on
.TP terminal server. If unset or set to an invalid or non\-existent group,
\fBTerminalServerAdmins\fR=\fItsadmins\fR login for all users is enabled.
Sets the group which a user shall belong to have session management rights.
.br .TP
\fI\-this option is currently ignored!\-\fR \fBTerminalServerAdmins\fR=\fIgroup\fR
\fIThis option is currently ignored!\fR Only members of this group can
.SH "EXAMPLES" have session management rights.
This is an example \fBsesman.ini\fR:
.TP
.nf \fBAlwaysGroupCheck\fR=\fI[0|1]\fR
[Globals] If set to \fB1\fR, \fBtrue\fR or \fByes\fR, require group membership even
ListenAddress=127.0.0.1 if the group specified in \fBTerminalServerUsers\fR doesn't exist.
ListenPort=3350
EnableUserWindowManager=1 .SH "X11 SERVER"
UserWindowManager=startwm.sh Following parameters can be used in the \fB[X11rdp]\fR, \fB[Xvnc]\fR and
DefaultWindowManager=startwm.sh \fB[Xorg]\fR sections.
[Logging] .TP
LogFile=/usr/local/xrdp/sesman.log \fBparam0\fR=\fIfilename\fR
LogLevel=DEBUG Path to the X11 server executable
EnableSyslog=0
SyslogLevel=DEBUG .TP
\fBparam\fR\fIN\fR=\fIstring\fR
[Sessions] Nth command line argument
MaxSessions=10
KillDisconnected=0 .SH "CHANSRV"
IdleTimeLimit=0 Following parameters can be used in the \fB[Chansrv]\fR section.
DisconnectedTimeLimit=0
.TP
[Security] \fBFuseMountName\fR=\fIstring\fR
AllowRootLogin=1 Directory for drive redirection, relative to the user home directory.
MaxLoginRetry=3 Created if it doesn't exist. Defaults to \fIxrdp_client\fR
TerminalServerUsers=tsusers
TerminalServerAdmins=tsadmins .SH "SESSIONS VARIABLES"
.fi All entries it the \fB[SessionVariables]\fR section are set as
environment variables in the user's session.
.SH "FILES" .SH "FILES"
${SESMAN_CFG_DIR}/sesman.ini /etc/xrdp/sesman.ini
.SH "SEE ALSO" .SH "SEE ALSO"
.BR sesman (8), .BR xrdp-sesman (8),
.BR sesrun (8), .BR xrdp-sesrun (8),
.BR xrdp (8), .BR xrdp (8),
.BR xrdp.ini (5) .BR xrdp.ini (5)
for more info on \fBxrdp\fR see http://xrdp.sf.net For more info on \fBxrdp\fR see http://xrdp.sf.net

@ -7,7 +7,7 @@ xrdp\-dis \- xrdp disconnect utility
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\fBxrdp\-dix\fP is run with no parameters to disconnect your xrdp session. \fBxrdp\-dis\fP is run with no parameters to disconnect your xrdp session.
.SH ENVIRONMENT .SH ENVIRONMENT
.TP .TP

@ -158,13 +158,13 @@ This option sets the logging level for syslog. It can have the same values of \f
.SH "CHANNELS" .SH "CHANNELS"
The Remote Desktop Protocol supports several channels, which are used to transfer additional data like sound, clipboard data and others. The Remote Desktop Protocol supports several channels, which are used to transfer additional data like sound, clipboard data and others.
Channel names not listed here will be blocked by \fBxrdp\fP. Channel names not listed here will be blocked by \fBxrdp\fP.
Not all channels are supported in all cases, so setting a value to \fItrue\fP is a pre-requisite, but does not force it's use. Not all channels are supported in all cases, so setting a value to \fItrue\fP is a prerequisite, but does not force its use.
.br .br
Channels can also be enabled or disabled on a per connection basis by prefixing each setting with \fBchannel.\fP in the channel section. Channels can also be enabled or disabled on a per connection basis by prefixing each setting with \fBchannel.\fP in the channel section.
.TP .TP
\fBrdpdr\fP=\fI[0|1]\fP \fBrdpdr\fP=\fI[0|1]\fP
If set to \fB1\fR, \fBtrue\fR or \fByes\fR using the RDP channel for device re-direction is allowed. If set to \fB1\fR, \fBtrue\fR or \fByes\fR using the RDP channel for device redirection is allowed.
.TP .TP
\fBrdpsnd\fP=\fI[0|1]\fP \fBrdpsnd\fP=\fI[0|1]\fP
@ -176,7 +176,7 @@ If set to \fB1\fR, \fBtrue\fR or \fByes\fR using the RDP channel to initiate add
.TP .TP
\fBcliprdr\fP=\fI[0|1]\fP \fBcliprdr\fP=\fI[0|1]\fP
If set to \fB1\fR, \fBtrue\fR or \fByes\fR using the RDP channel for clipboard re-direction is allowed. If set to \fB1\fR, \fBtrue\fR or \fByes\fR using the RDP channel for clipboard redirection is allowed.
.TP .TP
\fBrail\fP=\fI[0|1]\fP \fBrail\fP=\fI[0|1]\fP

@ -2,17 +2,17 @@ General FAQ
Q. What is RDP? Q. What is RDP?
A. RDP stands for Remote Desktop Protocol. Its the protocol used by Windows A. RDP stands for Remote Desktop Protocol. It's the protocol used by Windows
terminal servers to talk to the terminal server clients. terminal servers to talk to the terminal server clients.
Q. What is xrdp? Q. What is xrdp?
A. xrdp, usually spell lower case, is as open source implementation of the RDP A. xrdp, usually spelled in lower case, is as open source implementation of the
protocol. RDP protocol.
Q. I can't get it to compile in Ubuntu. What can I do? Q. I can't get xrdp to compile in Ubuntu. What can I do?
A. See faq-compile.txt. A. See faq-compile.txt.

@ -48,7 +48,10 @@ int main(int argc, char **argv)
char text[256]; char text[256];
char *displayname = NULL; char *displayname = NULL;
char *outfname; char *outfname;
char *sections[8] = {"noshift", "shift", "altgr", "shiftaltgr", "capslock", "capslockaltgr", "shiftcapslock", "shiftcapslockaltgr"}; const char *sections[8] = {
"noshift", "shift", "altgr", "shiftaltgr",
"capslock", "capslockaltgr", "shiftcapslock", "shiftcapslockaltgr"
};
int states[8] = {0, 1, 0x80, 0x81, 2, 0x82, 3, 0x83}; int states[8] = {0, 1, 0x80, 0x81, 2, 0x82, 3, 0x83};
int i; int i;
int idx; int idx;

@ -282,7 +282,7 @@ sign_key(char *e_data, int e_len, char *n_data, int n_len,
/*****************************************************************************/ /*****************************************************************************/
static int APP_CC static int APP_CC
write_out_line(int fd, char *name, char *data, int len) write_out_line(int fd, const char *name, char *data, int len)
{ {
int max; int max;
int error; int error;

@ -485,12 +485,12 @@ libxrdp_send_bitmap(struct xrdp_session *session, int width, int height,
if (j > 32768) if (j > 32768)
{ {
g_writeln("error, decompressed size too big, its %d", j); g_writeln("error, decompressed size too big: %d bytes", j);
} }
if (bufsize > 8192) if (bufsize > 8192)
{ {
g_writeln("error, compressed size too big, its %d", bufsize); g_writeln("error, compressed size too big: %d bytes", bufsize);
} }
s->p = s->end; s->p = s->end;
@ -504,7 +504,7 @@ libxrdp_send_bitmap(struct xrdp_session *session, int width, int height,
if (total_bufsize > 8192) if (total_bufsize > 8192)
{ {
g_writeln("error, total compressed size too big, its %d", g_writeln("error, total compressed size too big: %d bytes",
total_bufsize); total_bufsize);
} }
} }
@ -1077,7 +1077,7 @@ libxrdp_query_channel(struct xrdp_session *session, int index,
/* returns a zero based index of the channel, -1 if error or it doesn't /* returns a zero based index of the channel, -1 if error or it doesn't
exist */ exist */
int EXPORT_CC int EXPORT_CC
libxrdp_get_channel_id(struct xrdp_session *session, char *name) libxrdp_get_channel_id(struct xrdp_session *session, const char *name)
{ {
int index = 0; int index = 0;
int count = 0; int count = 0;

@ -189,7 +189,7 @@ int DEFAULT_CC
libxrdp_query_channel(struct xrdp_session *session, int index, libxrdp_query_channel(struct xrdp_session *session, int index,
char *channel_name, int *channel_flags); char *channel_name, int *channel_flags);
int DEFAULT_CC int DEFAULT_CC
libxrdp_get_channel_id(struct xrdp_session *session, char *name); libxrdp_get_channel_id(struct xrdp_session *session, const char *name);
int DEFAULT_CC int DEFAULT_CC
libxrdp_send_to_channel(struct xrdp_session *session, int channel_id, libxrdp_send_to_channel(struct xrdp_session *session, int channel_id,
char *data, int data_len, char *data, int data_len,

@ -1023,7 +1023,7 @@ xrdp_mcs_send(struct xrdp_mcs *self, struct stream *s, int chan)
if (len > 8192 * 2) if (len > 8192 * 2)
{ {
g_writeln("error in xrdp_mcs_send, size too big, its %d", len); g_writeln("error in xrdp_mcs_send, size too big: %d bytes", len);
} }
//if (len > max_len) //if (len > max_len)

@ -236,7 +236,7 @@ xrdp_orders_check(struct xrdp_orders *self, int max_size)
size = (int)(self->out_s->p - self->order_count_ptr); size = (int)(self->out_s->p - self->order_count_ptr);
if (size < 0) if (size < 0)
{ {
g_writeln("error in xrdp_orders_check, size too small, its %d", size); g_writeln("error in xrdp_orders_check, size too small: %d bytes", size);
return 1; return 1;
} }
if (size > max_packet_size) if (size > max_packet_size)
@ -244,7 +244,7 @@ xrdp_orders_check(struct xrdp_orders *self, int max_size)
/* this suggests someone calls this function without passing the /* this suggests someone calls this function without passing the
correct max_size so we end up putting more into the buffer correct max_size so we end up putting more into the buffer
than we indicate we can */ than we indicate we can */
g_writeln("error in xrdp_orders_check, size too big, its %d", size); g_writeln("error in xrdp_orders_check, size too big: %d bytes", size);
/* We where getting called with size already greater than /* We where getting called with size already greater than
max_packet_size max_packet_size
Which I suspect was because the sending of text did not include Which I suspect was because the sending of text did not include
@ -507,7 +507,7 @@ xrdp_orders_rect(struct xrdp_orders *self, int x, int y, int cx, int cy,
if (rect != 0) if (rect != 0)
{ {
/* if clip is present, still check if its needed */ /* if clip is present, still check if it's needed */
if (x < rect->left || y < rect->top || if (x < rect->left || y < rect->top ||
x + cx > rect->right || y + cy > rect->bottom) x + cx > rect->right || y + cy > rect->bottom)
{ {
@ -678,7 +678,7 @@ xrdp_orders_screen_blt(struct xrdp_orders *self, int x, int y,
if (rect != 0) if (rect != 0)
{ {
/* if clip is present, still check if its needed */ /* if clip is present, still check if it's needed */
if (x < rect->left || y < rect->top || if (x < rect->left || y < rect->top ||
x + cx > rect->right || y + cy > rect->bottom) x + cx > rect->right || y + cy > rect->bottom)
{ {
@ -870,7 +870,7 @@ xrdp_orders_pat_blt(struct xrdp_orders *self, int x, int y,
if (rect != 0) if (rect != 0)
{ {
/* if clip is present, still check if its needed */ /* if clip is present, still check if it's needed */
if (x < rect->left || y < rect->top || if (x < rect->left || y < rect->top ||
x + cx > rect->right || y + cy > rect->bottom) x + cx > rect->right || y + cy > rect->bottom)
{ {
@ -1087,7 +1087,7 @@ xrdp_orders_dest_blt(struct xrdp_orders *self, int x, int y,
if (rect != 0) if (rect != 0)
{ {
/* if clip is present, still check if its needed */ /* if clip is present, still check if it's needed */
if (x < rect->left || y < rect->top || if (x < rect->left || y < rect->top ||
x + cx > rect->right || y + cy > rect->bottom) x + cx > rect->right || y + cy > rect->bottom)
{ {
@ -1258,7 +1258,7 @@ xrdp_orders_line(struct xrdp_orders *self, int mix_mode,
if (rect != 0) if (rect != 0)
{ {
/* if clip is present, still check if its needed */ /* if clip is present, still check if it's needed */
if (MIN(endx, startx) < rect->left || if (MIN(endx, startx) < rect->left ||
MIN(endy, starty) < rect->top || MIN(endy, starty) < rect->top ||
MAX(endx, startx) >= rect->right || MAX(endx, startx) >= rect->right ||
@ -1460,7 +1460,7 @@ xrdp_orders_mem_blt(struct xrdp_orders *self, int cache_id,
if (rect != 0) if (rect != 0)
{ {
/* if clip is present, still check if its needed */ /* if clip is present, still check if it's needed */
if (x < rect->left || y < rect->top || if (x < rect->left || y < rect->top ||
x + cx > rect->right || y + cy > rect->bottom) x + cx > rect->right || y + cy > rect->bottom)
{ {
@ -1667,7 +1667,7 @@ xrdp_orders_composite_blt(struct xrdp_orders* self, int srcidx, int srcformat,
self->orders_state.last_order = RDP_ORDER_COMPOSITE; self->orders_state.last_order = RDP_ORDER_COMPOSITE;
if (rect != 0) if (rect != 0)
{ {
/* if clip is present, still check if its needed */ /* if clip is present, still check if it's needed */
if (dstx < rect->left || dsty < rect->top || if (dstx < rect->left || dsty < rect->top ||
dstx + width > rect->right || dsty + height > rect->bottom) dstx + width > rect->right || dsty + height > rect->bottom)
{ {
@ -1999,7 +1999,7 @@ xrdp_orders_text(struct xrdp_orders *self,
if (rect != 0) if (rect != 0)
{ {
/* if clip is present, still check if its needed */ /* if clip is present, still check if it's needed */
if ((box_right - box_left > 1 && if ((box_right - box_left > 1 &&
(box_left < rect->left || (box_left < rect->left ||
box_top < rect->top || box_top < rect->top ||

@ -2101,7 +2101,7 @@ xrdp_sec_in_mcs_data(struct xrdp_sec *self)
client_info = &(self->rdp_layer->client_info); client_info = &(self->rdp_layer->client_info);
s = &(self->client_mcs_data); s = &(self->client_mcs_data);
/* get hostname, its unicode */ /* get hostname, it's unicode */
s->p = s->data; s->p = s->data;
if (!s_check_rem(s, 47)) if (!s_check_rem(s, 47))
{ {

@ -0,0 +1,67 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# For every FLAG1, FLAG2 it is checked whether the compiler works with the
# flag. If it does, the flag is added FLAGS-VARIABLE
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. During the check the flag is always added to the
# current language's flags.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: This macro depends on the AX_APPEND_FLAG and
# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
# AX_APPEND_LINK_FLAGS.
#
# LICENSE
#
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 5
AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
done
])dnl AX_APPEND_COMPILE_FLAGS

@ -0,0 +1,74 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 4
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS

@ -75,13 +75,13 @@ lib_mod_end(struct mod *mod)
/******************************************************************************/ /******************************************************************************/
/* return error */ /* return error */
int DEFAULT_CC int DEFAULT_CC
lib_mod_set_param(struct mod *mod, char *name, char *value) lib_mod_set_param(struct mod *mod, const char *name, char *value)
{ {
return 0; return 0;
} }
/******************************************************************************/ /******************************************************************************/
struct mod *EXPORT_CC tintptr EXPORT_CC
mod_init(void) mod_init(void)
{ {
struct mod *mod; struct mod *mod;
@ -89,20 +89,22 @@ mod_init(void)
mod = (struct mod *)g_malloc(sizeof(struct mod), 1); mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
mod->size = sizeof(struct mod); mod->size = sizeof(struct mod);
mod->version = CURRENT_MOD_VER; mod->version = CURRENT_MOD_VER;
mod->handle = (long)mod; mod->handle = (tintptr) mod;
mod->mod_connect = lib_mod_connect; mod->mod_connect = lib_mod_connect;
mod->mod_start = lib_mod_start; mod->mod_start = lib_mod_start;
mod->mod_event = lib_mod_event; mod->mod_event = lib_mod_event;
mod->mod_signal = lib_mod_signal; mod->mod_signal = lib_mod_signal;
mod->mod_end = lib_mod_end; mod->mod_end = lib_mod_end;
mod->mod_set_param = lib_mod_set_param; mod->mod_set_param = lib_mod_set_param;
return mod; return (tintptr) mod;
} }
/******************************************************************************/ /******************************************************************************/
int EXPORT_CC int EXPORT_CC
mod_exit(struct mod *mod) mod_exit(tintptr handle)
{ {
struct mod *mod = (struct mod *) handle;
if (mod == 0) if (mod == 0)
{ {
return 0; return 0;

@ -37,7 +37,7 @@ struct mod
long param3, long param4); long param3, long param4);
int (*mod_signal)(struct mod* v); int (*mod_signal)(struct mod* v);
int (*mod_end)(struct mod* v); int (*mod_end)(struct mod* v);
int (*mod_set_param)(struct mod* v, char* name, char* value); int (*mod_set_param)(struct mod* v, const char *name, char* value);
int (*mod_session_change)(struct mod* v, int, int); int (*mod_session_change)(struct mod* v, int, int);
int (*mod_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount, int (*mod_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount,
tbus* write_objs, int* wcount, int* timeout); tbus* write_objs, int* wcount, int* timeout);
@ -80,7 +80,7 @@ struct mod
int (*server_query_channel)(struct mod* v, int index, int (*server_query_channel)(struct mod* v, int index,
char* channel_name, char* channel_name,
int* channel_flags); int* channel_flags);
int (*server_get_channel_id)(struct mod* v, char* name); int (*server_get_channel_id)(struct mod* v, const char *name);
int (*server_send_to_channel)(struct mod* v, int channel_id, int (*server_send_to_channel)(struct mod* v, int channel_id,
char* data, int data_len, char* data, int data_len,
int total_data_len, int flags); int total_data_len, int flags);

@ -22,7 +22,6 @@
#include "xrdp_rail.h" #include "xrdp_rail.h"
#include "log.h" #include "log.h"
#include <freerdp/settings.h> #include <freerdp/settings.h>
#include <X11/Xlib.h>
#ifdef XRDP_DEBUG #ifdef XRDP_DEBUG
#define LOG_LEVEL 99 #define LOG_LEVEL 99
@ -230,7 +229,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2,
break; break;
case 17: /* Synchronize */ case 17: /* Synchronize */
LLOGLN(11, ("Synchronized event handled : %d", param1)); LLOGLN(11, ("Synchronized event handled : %ld", param1));
/* In some situations the Synchronize event come to early. /* In some situations the Synchronize event come to early.
Therefore we store this information and use it when we Therefore we store this information and use it when we
receive the first keyboard event receive the first keyboard event
@ -246,7 +245,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2,
break; break;
case 100: /* mouse move */ case 100: /* mouse move */
LLOGLN(12, ("mouse move %d %d", param1, param2)); LLOGLN(12, ("mouse move %ld %ld", param1, param2));
x = param1; x = param1;
y = param2; y = param2;
flags = PTR_FLAGS_MOVE; flags = PTR_FLAGS_MOVE;
@ -254,7 +253,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2,
break; break;
case 101: /* left button up */ case 101: /* left button up */
LLOGLN(12, ("left button up %d %d", param1, param2)); LLOGLN(12, ("left button up %ld %ld", param1, param2));
x = param1; x = param1;
y = param2; y = param2;
flags = PTR_FLAGS_BUTTON1; flags = PTR_FLAGS_BUTTON1;
@ -262,7 +261,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2,
break; break;
case 102: /* left button down */ case 102: /* left button down */
LLOGLN(12, ("left button down %d %d", param1, param2)); LLOGLN(12, ("left button down %ld %ld", param1, param2));
x = param1; x = param1;
y = param2; y = param2;
flags = PTR_FLAGS_BUTTON1 | PTR_FLAGS_DOWN; flags = PTR_FLAGS_BUTTON1 | PTR_FLAGS_DOWN;
@ -270,7 +269,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2,
break; break;
case 103: /* right button up */ case 103: /* right button up */
LLOGLN(12, ("right button up %d %d", param1, param2)); LLOGLN(12, ("right button up %ld %ld", param1, param2));
x = param1; x = param1;
y = param2; y = param2;
flags = PTR_FLAGS_BUTTON2; flags = PTR_FLAGS_BUTTON2;
@ -278,7 +277,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2,
break; break;
case 104: /* right button down */ case 104: /* right button down */
LLOGLN(12, ("right button down %d %d", param1, param2)); LLOGLN(12, ("right button down %ld %ld", param1, param2));
x = param1; x = param1;
y = param2; y = param2;
flags = PTR_FLAGS_BUTTON2 | PTR_FLAGS_DOWN; flags = PTR_FLAGS_BUTTON2 | PTR_FLAGS_DOWN;
@ -286,7 +285,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2,
break; break;
case 105: /* middle button up */ case 105: /* middle button up */
LLOGLN(12, ("middle button up %d %d", param1, param2)); LLOGLN(12, ("middle button up %ld %ld", param1, param2));
x = param1; x = param1;
y = param2; y = param2;
flags = PTR_FLAGS_BUTTON3; flags = PTR_FLAGS_BUTTON3;
@ -294,7 +293,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2,
break; break;
case 106: /* middle button down */ case 106: /* middle button down */
LLOGLN(12, ("middle button down %d %d", param1, param2)); LLOGLN(12, ("middle button down %ld %ld", param1, param2));
x = param1; x = param1;
y = param2; y = param2;
flags = PTR_FLAGS_BUTTON3 | PTR_FLAGS_DOWN; flags = PTR_FLAGS_BUTTON3 | PTR_FLAGS_DOWN;
@ -428,7 +427,7 @@ lxrdp_end(struct mod *mod)
/******************************************************************************/ /******************************************************************************/
/* return error */ /* return error */
static int DEFAULT_CC static int DEFAULT_CC
lxrdp_set_param(struct mod *mod, char *name, char *value) lxrdp_set_param(struct mod *mod, const char *name, char *value)
{ {
rdpSettings *settings; rdpSettings *settings;
@ -1368,7 +1367,9 @@ lfreerdp_polygon_sc(rdpContext *context, POLYGON_SC_ORDER *polygon_sc)
{ {
struct mod *mod; struct mod *mod;
int i, npoints; int i, npoints;
XPoint points[4]; struct {
short x, y;
} points[4];
int fgcolor; int fgcolor;
int server_bpp, client_bpp; int server_bpp, client_bpp;
@ -1954,7 +1955,7 @@ lfreerdp_verify_certificate(freerdp *instance, char *subject, char *issuer,
} }
/******************************************************************************/ /******************************************************************************/
struct mod *EXPORT_CC tintptr EXPORT_CC
mod_init(void) mod_init(void)
{ {
struct mod *mod; struct mod *mod;
@ -1967,7 +1968,7 @@ mod_init(void)
mod->vmaj, mod->vmin, mod->vrev)); mod->vmaj, mod->vmin, mod->vrev));
mod->size = sizeof(struct mod); mod->size = sizeof(struct mod);
mod->version = CURRENT_MOD_VER; mod->version = CURRENT_MOD_VER;
mod->handle = (tbus)mod; mod->handle = (tintptr) mod;
mod->mod_connect = lxrdp_connect; mod->mod_connect = lxrdp_connect;
mod->mod_start = lxrdp_start; mod->mod_start = lxrdp_start;
mod->mod_event = lxrdp_event; mod->mod_event = lxrdp_event;
@ -1994,13 +1995,15 @@ mod_init(void)
lcon->modi = mod; lcon->modi = mod;
LLOGLN(10, ("mod_init: mod %p", mod)); LLOGLN(10, ("mod_init: mod %p", mod));
return mod; return (tintptr) mod;
} }
/******************************************************************************/ /******************************************************************************/
int EXPORT_CC int EXPORT_CC
mod_exit(struct mod *mod) mod_exit(tintptr handle)
{ {
struct mod *mod = (struct mod *) handle;
LLOGLN(0, ("mod_exit:")); LLOGLN(0, ("mod_exit:"));
if (mod == 0) if (mod == 0)

@ -71,7 +71,7 @@ struct mod
long param3, long param4); long param3, long param4);
int (*mod_signal)(struct mod *v); int (*mod_signal)(struct mod *v);
int (*mod_end)(struct mod *v); int (*mod_end)(struct mod *v);
int (*mod_set_param)(struct mod *v, char *name, char *value); int (*mod_set_param)(struct mod *v, const char *name, char *value);
int (*mod_session_change)(struct mod *v, int, int); int (*mod_session_change)(struct mod *v, int, int);
int (*mod_get_wait_objs)(struct mod *v, tbus *read_objs, int *rcount, int (*mod_get_wait_objs)(struct mod *v, tbus *read_objs, int *rcount,
tbus *write_objs, int *wcount, int *timeout); tbus *write_objs, int *wcount, int *timeout);
@ -114,7 +114,7 @@ struct mod
int (*server_query_channel)(struct mod *v, int index, int (*server_query_channel)(struct mod *v, int index,
char *channel_name, char *channel_name,
int *channel_flags); int *channel_flags);
int (*server_get_channel_id)(struct mod *v, char *name); int (*server_get_channel_id)(struct mod *v, const char *name);
int (*server_send_to_channel)(struct mod *v, int channel_id, int (*server_send_to_channel)(struct mod *v, int channel_id,
char *data, int data_len, char *data, int data_len,
int total_data_len, int flags); int total_data_len, int flags);

@ -1,7 +1,8 @@
This is an attempt to explain my odd programming standard used for this project. This is an attempt to explain my odd programming standard used for this project.
Not to defend any of these but its my default standard and make it easy Not to defend any of these but it's my default standard and it makes it easy
for me to read. for me to read code.
Some files break these rules, they will be updated eventually. Some files break these rules, they will be updated eventually.
try to make any file compile with c++ compilers try to make any file compile with c++ compilers
@ -30,7 +31,7 @@ don't use tabs, use spaces
no line should exceed 80 chars no line should exceed 80 chars
always use {} in if and while, even if its only one line always use {} in if and while, even if it's only one line
while (p != 0) while (p != 0)
{ {
p = p->next; p = p->next;

@ -242,7 +242,7 @@ lib_mod_end(struct mod *mod)
/******************************************************************************/ /******************************************************************************/
/* return error */ /* return error */
int DEFAULT_CC int DEFAULT_CC
lib_mod_set_param(struct mod *mod, char *name, char *value) lib_mod_set_param(struct mod *mod, const char *name, char *value)
{ {
if (g_strncasecmp(name, "ip", 255) == 0) if (g_strncasecmp(name, "ip", 255) == 0)
{ {
@ -318,7 +318,7 @@ lib_mod_check_wait_objs(struct mod *mod)
} }
/******************************************************************************/ /******************************************************************************/
struct mod *EXPORT_CC tintptr EXPORT_CC
mod_init(void) mod_init(void)
{ {
struct mod *mod; struct mod *mod;
@ -327,7 +327,7 @@ mod_init(void)
mod = (struct mod *)g_malloc(sizeof(struct mod), 1); mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
mod->size = sizeof(struct mod); mod->size = sizeof(struct mod);
mod->version = CURRENT_MOD_VER; mod->version = CURRENT_MOD_VER;
mod->handle = (long)mod; mod->handle = (tintptr) mod;
mod->mod_connect = lib_mod_connect; mod->mod_connect = lib_mod_connect;
mod->mod_start = lib_mod_start; mod->mod_start = lib_mod_start;
mod->mod_event = lib_mod_event; mod->mod_event = lib_mod_event;
@ -338,13 +338,15 @@ mod_init(void)
mod->mod_check_wait_objs = lib_mod_check_wait_objs; mod->mod_check_wait_objs = lib_mod_check_wait_objs;
mod->rdp_layer = rdp_rdp_create(mod); mod->rdp_layer = rdp_rdp_create(mod);
DEBUG(("out mod_init")); DEBUG(("out mod_init"));
return mod; return (tintptr) mod;
} }
/******************************************************************************/ /******************************************************************************/
int EXPORT_CC int EXPORT_CC
mod_exit(struct mod *mod) mod_exit(tintptr handle)
{ {
struct mod *mod = (struct mod *) handle;
DEBUG(("in mod_exit")); DEBUG(("in mod_exit"));
g_free(mod); g_free(mod);
DEBUG(("out mod_exit")); DEBUG(("out mod_exit"));

@ -262,7 +262,7 @@ struct mod
long param3, long param4); long param3, long param4);
int (*mod_signal)(struct mod* v); int (*mod_signal)(struct mod* v);
int (*mod_end)(struct mod* v); int (*mod_end)(struct mod* v);
int (*mod_set_param)(struct mod* v, char* name, char* value); int (*mod_set_param)(struct mod* v, const char *name, char* value);
int (*mod_session_change)(struct mod* v, int, int); int (*mod_session_change)(struct mod* v, int, int);
int (*mod_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount, int (*mod_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount,
tbus* write_objs, int* wcount, int* timeout); tbus* write_objs, int* wcount, int* timeout);
@ -305,7 +305,7 @@ struct mod
int (*server_query_channel)(struct mod* v, int index, int (*server_query_channel)(struct mod* v, int index,
char* channel_name, char* channel_name,
int* channel_flags); int* channel_flags);
int (*server_get_channel_id)(struct mod* v, char* name); int (*server_get_channel_id)(struct mod* v, const char *name);
int (*server_send_to_channel)(struct mod* v, int channel_id, int (*server_send_to_channel)(struct mod* v, int channel_id,
char* data, int data_len, char* data, int data_len,
int total_data_len, int flags); int total_data_len, int flags);

@ -312,7 +312,7 @@ rdp_rdp_out_colcache_caps(struct rdp_rdp *self, struct stream *s)
return 0; return 0;
} }
static char caps_0x0d[] = static const unsigned char caps_0x0d[] =
{ {
0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -327,11 +327,11 @@ static char caps_0x0d[] =
0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00
}; };
static char caps_0x0c[] = { 0x01, 0x00, 0x00, 0x00 }; static const unsigned char caps_0x0c[] = { 0x01, 0x00, 0x00, 0x00 };
static char caps_0x0e[] = { 0x01, 0x00, 0x00, 0x00 }; static const unsigned char caps_0x0e[] = { 0x01, 0x00, 0x00, 0x00 };
static char caps_0x10[] = static const unsigned char caps_0x10[] =
{ {
0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00,
0xFE, 0x00, 0x08, 0x00, 0xFE, 0x00, 0x08, 0x00, 0xFE, 0x00, 0x08, 0x00, 0xFE, 0x00, 0x08, 0x00,
@ -345,7 +345,7 @@ static char caps_0x10[] =
/* Output unknown capability sets */ /* Output unknown capability sets */
static int APP_CC static int APP_CC
rdp_rdp_out_unknown_caps(struct rdp_rdp *self, struct stream *s, int id, rdp_rdp_out_unknown_caps(struct rdp_rdp *self, struct stream *s, int id,
int length, char *caps) int length, const unsigned char *caps)
{ {
out_uint16_le(s, id); out_uint16_le(s, id);
out_uint16_le(s, length); out_uint16_le(s, length);
@ -415,9 +415,9 @@ rdp_rdp_send_confirm_active(struct rdp_rdp *self, struct stream *s)
static int APP_CC static int APP_CC
rdp_rdp_process_color_pointer_pdu(struct rdp_rdp *self, struct stream *s) rdp_rdp_process_color_pointer_pdu(struct rdp_rdp *self, struct stream *s)
{ {
int cache_idx; unsigned int cache_idx;
int dlen; unsigned int dlen;
int mlen; unsigned int mlen;
struct rdp_cursor *cursor; struct rdp_cursor *cursor;
in_uint16_le(s, cache_idx); in_uint16_le(s, cache_idx);

@ -55,7 +55,7 @@ static tbus g_thread_done_event = 0;
static int g_use_unix_socket = 0; static int g_use_unix_socket = 0;
static char g_xrdpapi_magic[12] = static const unsigned char g_xrdpapi_magic[12] =
{ 0x78, 0x32, 0x10, 0x67, 0x00, 0x92, 0x30, 0x56, 0xff, 0xd8, 0xa9, 0x1f }; { 0x78, 0x32, 0x10, 0x67, 0x00, 0x92, 0x30, 0x56, 0xff, 0xd8, 0xa9, 0x1f };
int g_display_num = 0; int g_display_num = 0;
@ -97,7 +97,7 @@ add_timeout(int msoffset, void (*callback)(void *data), void *data)
LOG(10, ("add_timeout:")); LOG(10, ("add_timeout:"));
now = g_time3(); now = g_time3();
tobj = g_malloc(sizeof(struct timeout_obj), 1); tobj = g_new0(struct timeout_obj, 1);
tobj->mstime = now + msoffset; tobj->mstime = now + msoffset;
tobj->callback = callback; tobj->callback = callback;
tobj->data = data; tobj->data = data;
@ -734,8 +734,7 @@ process_message(void)
rv = process_message_channel_data_response(s); rv = process_message_channel_data_response(s);
break; break;
default: default:
LOGM((LOG_LEVEL_ERROR, "process_message: error in process_message ", LOGM((LOG_LEVEL_ERROR, "process_message: unknown msg %d", id));
"unknown msg %d", id));
break; break;
} }
@ -1402,8 +1401,8 @@ get_log_path()
} }
/*****************************************************************************/ /*****************************************************************************/
static unsigned int APP_CC static enum logLevels APP_CC
get_log_level(const char* level_str, unsigned int default_level) get_log_level(const char* level_str, enum logLevels default_level)
{ {
static const char* levels[] = { static const char* levels[] = {
"LOG_LEVEL_ALWAYS", "LOG_LEVEL_ALWAYS",
@ -1422,7 +1421,7 @@ get_log_level(const char* level_str, unsigned int default_level)
{ {
if (g_strcasecmp(levels[i], level_str) == 0) if (g_strcasecmp(levels[i], level_str) == 0)
{ {
return i; return (enum logLevels) i;
} }
} }
return default_level; return default_level;
@ -1467,7 +1466,7 @@ main(int argc, char **argv)
char log_file[256]; char log_file[256];
enum logReturns error; enum logReturns error;
struct log_config logconfig; struct log_config logconfig;
unsigned int log_level; enum logLevels log_level;
g_init("xrdp-chansrv"); /* os_calls */ g_init("xrdp-chansrv"); /* os_calls */
@ -1499,7 +1498,7 @@ main(int argc, char **argv)
logconfig.fd = -1; logconfig.fd = -1;
logconfig.log_level = log_level; logconfig.log_level = log_level;
logconfig.enable_syslog = 0; logconfig.enable_syslog = 0;
logconfig.syslog_level = 0; logconfig.syslog_level = LOG_LEVEL_ALWAYS;
error = log_start_from_param(&logconfig); error = log_start_from_param(&logconfig);
if (error != LOG_STARTUP_OK) if (error != LOG_STARTUP_OK)
@ -1629,7 +1628,8 @@ struct_from_dvc_chan_id(tui32 dvc_chan_id)
for (i = 0; i < MAX_DVC_CHANNELS; i++) for (i = 0; i < MAX_DVC_CHANNELS; i++)
{ {
if (g_dvc_channels[i]->dvc_chan_id == dvc_chan_id) if (g_dvc_channels[i]->dvc_chan_id >= 0 &&
(tui32) g_dvc_channels[i]->dvc_chan_id == dvc_chan_id)
{ {
return g_dvc_channels[i]; return g_dvc_channels[i];
} }
@ -1645,7 +1645,8 @@ remove_struct_with_chan_id(tui32 dvc_chan_id)
for (i = 0; i < MAX_DVC_CHANNELS; i++) for (i = 0; i < MAX_DVC_CHANNELS; i++)
{ {
if (g_dvc_channels[i]->dvc_chan_id == dvc_chan_id) if (g_dvc_channels[i]->dvc_chan_id >= 0 &&
(tui32) g_dvc_channels[i]->dvc_chan_id == dvc_chan_id)
{ {
g_dvc_channels[i] = NULL; g_dvc_channels[i] = NULL;
return 0; return 0;

@ -295,7 +295,7 @@ int devredir_file_read(void *fusep, tui32 device_id, tui32 FileId,
tui32 Length, tui64 Offset); tui32 Length, tui64 Offset);
int dev_redir_file_write(void *fusep, tui32 device_id, tui32 FileId, int dev_redir_file_write(void *fusep, tui32 device_id, tui32 FileId,
const char *buf, tui32 Length, tui64 Offset); const char *buf, int Length, tui64 Offset);
int devredir_file_close(void *fusep, tui32 device_id, tui32 FileId); int devredir_file_close(void *fusep, tui32 device_id, tui32 FileId);

@ -582,7 +582,7 @@ clipboard_send_format_ack(void)
/*****************************************************************************/ /*****************************************************************************/
/* returns number of bytes written */ /* returns number of bytes written */
int APP_CC int APP_CC
clipboard_out_unicode(struct stream *s, char *text, int num_chars) clipboard_out_unicode(struct stream *s, const char *text, int num_chars)
{ {
int index; int index;
int lnum_chars; int lnum_chars;
@ -1920,7 +1920,8 @@ clipboard_event_selection_notify(XEvent *xevent)
for (index = 0; index < n_items; index++) for (index = 0; index < n_items; index++)
{ {
atom = atoms[index]; atom = atoms[index];
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: %d %s %d", LOGM((LOG_LEVEL_DEBUG,
"clipboard_event_selection_notify: 0x%lx %s 0x%lx",
atom, get_atom_text(atom), XA_STRING)); atom, get_atom_text(atom), XA_STRING));
log_debug("clipboard_event_selection_notify: 0x%lx %s", log_debug("clipboard_event_selection_notify: 0x%lx %s",
atom, get_atom_text(atom)); atom, get_atom_text(atom));

@ -127,7 +127,8 @@ struct clip_file_desc /* CLIPRDR_FILEDESCRIPTOR */
char cFileName[256]; char cFileName[256];
}; };
int APP_CC clipboard_out_unicode(struct stream *s, char *text, int num_chars); int APP_CC clipboard_out_unicode(struct stream *s, const char *text,
int num_chars);
int APP_CC clipboard_in_unicode(struct stream *s, char *text, int *num_chars); int APP_CC clipboard_in_unicode(struct stream *s, char *text, int *num_chars);
#endif #endif

@ -636,7 +636,7 @@ void dev_redir_proc_client_core_cap_resp(struct stream *s)
void devredir_proc_client_devlist_announce_req(struct stream *s) void devredir_proc_client_devlist_announce_req(struct stream *s)
{ {
int i; unsigned int i;
int j; int j;
tui32 device_count; tui32 device_count;
tui32 device_type; tui32 device_type;
@ -899,7 +899,7 @@ dev_redir_proc_query_dir_response(IRP *irp,
tui32 status; tui32 status;
char filename[256]; char filename[256];
int i = 0; unsigned int i = 0;
xstream_rd_u32_le(s_in, Length); xstream_rd_u32_le(s_in, Length);
@ -962,7 +962,8 @@ dev_redir_proc_query_dir_response(IRP *irp,
//log_debug("FileNameLength: %d", FileNameLength); //log_debug("FileNameLength: %d", FileNameLength);
log_debug("FileName: %s", filename); log_debug("FileName: %s", filename);
if ((xinode = calloc(1, sizeof(struct xrdp_inode))) == NULL) xinode = g_new0(struct xrdp_inode, 1);
if (xinode == NULL)
{ {
log_error("system out of memory"); log_error("system out of memory");
fuse_data = devredir_fuse_data_peek(irp); fuse_data = devredir_fuse_data_peek(irp);
@ -1255,7 +1256,7 @@ devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
int APP_CC int APP_CC
dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId, dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
const char *buf, tui32 Length, tui64 Offset) const char *buf, int Length, tui64 Offset)
{ {
struct stream *s; struct stream *s;
IRP *irp; IRP *irp;
@ -1320,7 +1321,7 @@ dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
* @return FUSE_DATA on success, or NULL on failure * @return FUSE_DATA on success, or NULL on failure
*****************************************************************************/ *****************************************************************************/
void * APP_CC FUSE_DATA *APP_CC
devredir_fuse_data_peek(IRP *irp) devredir_fuse_data_peek(IRP *irp)
{ {
log_debug("returning %p", irp->fd_head); log_debug("returning %p", irp->fd_head);
@ -1333,7 +1334,7 @@ devredir_fuse_data_peek(IRP *irp)
* @return FUSE_DATA on success, NULL on failure * @return FUSE_DATA on success, NULL on failure
*****************************************************************************/ *****************************************************************************/
void * APP_CC FUSE_DATA *APP_CC
devredir_fuse_data_dequeue(IRP *irp) devredir_fuse_data_dequeue(IRP *irp)
{ {
FUSE_DATA *head; FUSE_DATA *head;
@ -1378,7 +1379,8 @@ devredir_fuse_data_enqueue(IRP *irp, void *vp)
if (irp == NULL) if (irp == NULL)
return -1; return -1;
if ((fd = calloc(1, sizeof(FUSE_DATA))) == NULL) fd = g_new0(FUSE_DATA, 1);
if (fd == NULL)
return -1; return -1;
fd->data_ptr = vp; fd->data_ptr = vp;
@ -1481,7 +1483,7 @@ devredir_cvt_from_unicode_len(char *path, char *unicode, int len)
bytes_to_alloc = (((len / 2) * sizeof(twchar)) + sizeof(twchar)); bytes_to_alloc = (((len / 2) * sizeof(twchar)) + sizeof(twchar));
src = unicode; src = unicode;
dest = g_malloc(bytes_to_alloc, 1); dest = g_new0(char, bytes_to_alloc);
dest_saved = dest; dest_saved = dest;
for (i = 0; i < len; i += 2) for (i = 0; i < len; i += 2)

@ -27,8 +27,8 @@
#define USE_SHORT_NAMES_IN_DIR_LISTING #define USE_SHORT_NAMES_IN_DIR_LISTING
void *devredir_fuse_data_peek(IRP *irp); FUSE_DATA *devredir_fuse_data_peek(IRP *irp);
void *devredir_fuse_data_dequeue(IRP *irp); FUSE_DATA *devredir_fuse_data_dequeue(IRP *irp);
int devredir_fuse_data_enqueue(IRP *irp, void *vp); int devredir_fuse_data_enqueue(IRP *irp, void *vp);
int APP_CC dev_redir_init(void); int APP_CC dev_redir_init(void);

@ -18,7 +18,7 @@
#include "drdynvc.h" #include "drdynvc.h"
int g_drdynvc_chan_id; extern int g_drdynvc_chan_id; /* in chansrv.c */
int g_drdynvc_inited = 0; int g_drdynvc_inited = 0;
static int APP_CC drdynvc_send_capability_request(uint16_t version); static int APP_CC drdynvc_send_capability_request(uint16_t version);

@ -77,7 +77,8 @@ IRP * devredir_irp_new()
log_debug("entered"); log_debug("entered");
/* create new IRP */ /* create new IRP */
if ((irp = g_malloc(sizeof(IRP), 1)) == NULL) irp = g_new0(IRP, 1);
if (irp == NULL)
{ {
log_error("system out of memory!"); log_error("system out of memory!");
return NULL; return NULL;

@ -184,7 +184,7 @@ rail_send_key_esc(int window_id)
static struct rail_window_data* APP_CC static struct rail_window_data* APP_CC
rail_get_window_data(Window window) rail_get_window_data(Window window)
{ {
int bytes; unsigned int bytes;
Atom actual_type_return; Atom actual_type_return;
int actual_format_return; int actual_format_return;
unsigned long nitems_return; unsigned long nitems_return;
@ -238,7 +238,7 @@ rail_get_window_data_safe(Window window)
{ {
return rv; return rv;
} }
rv = g_malloc(sizeof(struct rail_window_data), 1); rv = g_new0(struct rail_window_data, 1);
rail_set_window_data(window, rv); rail_set_window_data(window, rv);
g_free(rv); g_free(rv);
return rail_get_window_data(window); return rail_get_window_data(window);
@ -557,7 +557,7 @@ my_timeout(void* data)
static int APP_CC static int APP_CC
rail_process_activate(struct stream *s, int size) rail_process_activate(struct stream *s, int size)
{ {
int window_id; unsigned int window_id;
int enabled; int enabled;
int index; int index;
XWindowAttributes window_attributes; XWindowAttributes window_attributes;
@ -1148,8 +1148,8 @@ rail_data_in(struct stream *s, int chan_id, int chan_flags, int length,
return 0; return 0;
} }
static int g_crc_seed = 0xffffffff; static const unsigned int g_crc_seed = 0xffffffff;
static int g_crc_table[256] = static const unsigned int g_crc_table[256] =
{ {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,

@ -900,7 +900,8 @@ scard_add_new_device(tui32 device_id)
return -1; return -1;
} }
if ((sc = g_malloc(sizeof(SMARTCARD), 1)) == NULL) sc = g_new0(SMARTCARD, 1);
if (sc == NULL)
{ {
log_error("system out of memory"); log_error("system out of memory");
return -1; return -1;
@ -1255,7 +1256,7 @@ scard_send_GetStatusChange(IRP* irp, char *context, int context_bytes,
struct stream *s; struct stream *s;
tui32 ioctl; tui32 ioctl;
int bytes; int bytes;
int i; unsigned int i;
int num_chars; int num_chars;
int index; int index;
twchar w_reader_name[100]; twchar w_reader_name[100];

@ -97,7 +97,7 @@ create_uds_client(struct trans *con)
{ {
return 0; return 0;
} }
uds_client = g_malloc(sizeof(struct pcsc_uds_client), 1); uds_client = g_new0(struct pcsc_uds_client, 1);
if (uds_client == 0) if (uds_client == 0)
{ {
return 0; return 0;
@ -145,7 +145,7 @@ get_uds_client_by_id(int uds_client_id)
/*****************************************************************************/ /*****************************************************************************/
struct pcsc_context * struct pcsc_context *
get_pcsc_context_by_app_context(struct pcsc_uds_client *uds_client, get_pcsc_context_by_app_context(struct pcsc_uds_client *uds_client,
int app_context) tui32 app_context)
{ {
struct pcsc_context *rv; struct pcsc_context *rv;
int index; int index;
@ -173,7 +173,7 @@ get_pcsc_context_by_app_context(struct pcsc_uds_client *uds_client,
/*****************************************************************************/ /*****************************************************************************/
struct pcsc_card * struct pcsc_card *
get_pcsc_card_by_app_card(struct pcsc_uds_client *uds_client, get_pcsc_card_by_app_card(struct pcsc_uds_client *uds_client,
int app_card, struct pcsc_context **acontext) tui32 app_card, struct pcsc_context **acontext)
{ {
struct pcsc_card *lcard; struct pcsc_card *lcard;
struct pcsc_context *lcontext; struct pcsc_context *lcontext;
@ -606,7 +606,7 @@ scard_process_list_readers(struct trans *con, struct stream *in_s)
g_free(groups); g_free(groups);
return 1; return 1;
} }
pcscListReaders = g_malloc(sizeof(struct pcsc_list_readers), 1); pcscListReaders = g_new0(struct pcsc_list_readers, 1);
pcscListReaders->uds_client_id = uds_client->uds_client_id; pcscListReaders->uds_client_id = uds_client->uds_client_id;
pcscListReaders->cchReaders = cchReaders; pcscListReaders->cchReaders = cchReaders;
scard_send_list_readers(pcscListReaders, lcontext->context, scard_send_list_readers(pcscListReaders, lcontext->context,

@ -182,61 +182,6 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n,
return 0; return 0;
} }
/******************************************************************************
int DEFAULT_CC
config_read_logging(int file, struct log_config* lc, struct list* param_n,
struct list* param_v)
{
int i;
char* buf;
list_clear(param_v);
list_clear(param_n);
// setting defaults
lc->program_name = g_strdup("sesman");
lc->log_file = 0;
lc->fd = 0;
lc->log_level = LOG_LEVEL_DEBUG;
lc->enable_syslog = 0;
lc->syslog_level = LOG_LEVEL_DEBUG;
file_read_section(file, SESMAN_CFG_LOGGING, param_n, param_v);
for (i = 0; i < param_n->count; i++)
{
buf = (char*)list_get_item(param_n, i);
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_FILE))
{
lc->log_file = g_strdup((char*)list_get_item(param_v, i));
}
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_LEVEL))
{
lc->log_level = log_text2level((char*)list_get_item(param_v, i));
}
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_ENABLE_SYSLOG))
{
lc->enable_syslog = g_text2bool((char*)list_get_item(param_v, i));
}
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_SYSLOG_LEVEL))
{
lc->syslog_level = log_text2level((char*)list_get_item(param_v, i));
}
}
if (0 == lc->log_file)
{
lc->log_file=g_strdup("./sesman.log");
}
g_printf("logging configuration:\r\n");
g_printf("\tLogFile: %s\r\n",lc->log_file);
g_printf("\tLogLevel: %i\r\n", lc->log_level);
g_printf("\tEnableSyslog: %i\r\n", lc->enable_syslog);
g_printf("\tSyslogLevel: %i\r\n", lc->syslog_level);
return 0;
}
*/
/******************************************************************************/ /******************************************************************************/
int DEFAULT_CC int DEFAULT_CC
config_read_security(int file, struct config_security *sc, config_read_security(int file, struct config_security *sc,
@ -347,7 +292,7 @@ config_read_sessions(int file, struct config_sessions *se, struct list *param_n,
{ {
buf = (char *)list_get_item(param_n, i); buf = (char *)list_get_item(param_n, i);
if (0 == g_strcasecmp(buf, SESMAN_CFG_X11DISPLAYOFFSET)) if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_X11DISPLAYOFFSET))
{ {
se->x11_display_offset = g_atoi((char *)list_get_item(param_v, i)); se->x11_display_offset = g_atoi((char *)list_get_item(param_v, i));
} }

@ -37,7 +37,6 @@
#define SESMAN_CFG_PORT "ListenPort" #define SESMAN_CFG_PORT "ListenPort"
#define SESMAN_CFG_ENABLE_USERWM "EnableUserWindowManager" #define SESMAN_CFG_ENABLE_USERWM "EnableUserWindowManager"
#define SESMAN_CFG_USERWM "UserWindowManager" #define SESMAN_CFG_USERWM "UserWindowManager"
#define SESMAN_CFG_X11DISPLAYOFFSET "X11DisplayOffset"
#define SESMAN_CFG_MAX_SESSION "MaxSessions" #define SESMAN_CFG_MAX_SESSION "MaxSessions"
#define SESMAN_CFG_AUTH_FILE_PATH "AuthFilePath" #define SESMAN_CFG_AUTH_FILE_PATH "AuthFilePath"
@ -66,6 +65,7 @@
#define SESMAN_CFG_SESS_KILL_DISC "KillDisconnected" #define SESMAN_CFG_SESS_KILL_DISC "KillDisconnected"
#define SESMAN_CFG_SESS_IDLE_LIMIT "IdleTimeLimit" #define SESMAN_CFG_SESS_IDLE_LIMIT "IdleTimeLimit"
#define SESMAN_CFG_SESS_DISC_LIMIT "DisconnectedTimeLimit" #define SESMAN_CFG_SESS_DISC_LIMIT "DisconnectedTimeLimit"
#define SESMAN_CFG_SESS_X11DISPLAYOFFSET "X11DisplayOffset"
#define SESMAN_CFG_SESS_POLICY_S "Policy" #define SESMAN_CFG_SESS_POLICY_S "Policy"
#define SESMAN_CFG_SESS_POLICY_DFLT_S "Default" #define SESMAN_CFG_SESS_POLICY_DFLT_S "Default"

@ -33,7 +33,7 @@ scp_connection_create(int sck)
{ {
struct SCP_CONNECTION *conn; struct SCP_CONNECTION *conn;
conn = g_malloc(sizeof(struct SCP_CONNECTION), 0); conn = g_new(struct SCP_CONNECTION, 1);
if (0 == conn) if (0 == conn)
{ {

@ -43,7 +43,7 @@ scp_init()
scp_lock_init(); scp_lock_init();
log_message(LOG_LEVEL_WARNING, "[init:%d] libscp initialized", __LINE__); log_message(LOG_LEVEL_DEBUG, "libscp initialized");
return 0; return 0;
} }

@ -164,7 +164,7 @@ scp_session_set_rsr(struct SCP_SESSION *s, tui8 rsr)
/*******************************************************************/ /*******************************************************************/
int int
scp_session_set_locale(struct SCP_SESSION *s, char *str) scp_session_set_locale(struct SCP_SESSION *s, const char *str)
{ {
if (0 == str) if (0 == str)
{ {
@ -180,7 +180,7 @@ scp_session_set_locale(struct SCP_SESSION *s, char *str)
/*******************************************************************/ /*******************************************************************/
int int
scp_session_set_username(struct SCP_SESSION *s, char *str) scp_session_set_username(struct SCP_SESSION *s, const char *str)
{ {
if (0 == str) if (0 == str)
{ {
@ -206,7 +206,7 @@ scp_session_set_username(struct SCP_SESSION *s, char *str)
/*******************************************************************/ /*******************************************************************/
int int
scp_session_set_password(struct SCP_SESSION *s, char *str) scp_session_set_password(struct SCP_SESSION *s, const char *str)
{ {
if (0 == str) if (0 == str)
{ {
@ -232,7 +232,7 @@ scp_session_set_password(struct SCP_SESSION *s, char *str)
/*******************************************************************/ /*******************************************************************/
int int
scp_session_set_domain(struct SCP_SESSION *s, char *str) scp_session_set_domain(struct SCP_SESSION *s, const char *str)
{ {
if (0 == str) if (0 == str)
{ {
@ -258,7 +258,7 @@ scp_session_set_domain(struct SCP_SESSION *s, char *str)
/*******************************************************************/ /*******************************************************************/
int int
scp_session_set_program(struct SCP_SESSION *s, char *str) scp_session_set_program(struct SCP_SESSION *s, const char *str)
{ {
if (0 == str) if (0 == str)
{ {
@ -284,7 +284,7 @@ scp_session_set_program(struct SCP_SESSION *s, char *str)
/*******************************************************************/ /*******************************************************************/
int int
scp_session_set_directory(struct SCP_SESSION *s, char *str) scp_session_set_directory(struct SCP_SESSION *s, const char *str)
{ {
if (0 == str) if (0 == str)
{ {
@ -310,7 +310,7 @@ scp_session_set_directory(struct SCP_SESSION *s, char *str)
/*******************************************************************/ /*******************************************************************/
int int
scp_session_set_client_ip(struct SCP_SESSION *s, char *str) scp_session_set_client_ip(struct SCP_SESSION *s, const char *str)
{ {
if (0 == str) if (0 == str)
{ {
@ -336,7 +336,7 @@ scp_session_set_client_ip(struct SCP_SESSION *s, char *str)
/*******************************************************************/ /*******************************************************************/
int int
scp_session_set_hostname(struct SCP_SESSION *s, char *str) scp_session_set_hostname(struct SCP_SESSION *s, const char *str)
{ {
if (0 == str) if (0 == str)
{ {
@ -362,7 +362,7 @@ scp_session_set_hostname(struct SCP_SESSION *s, char *str)
/*******************************************************************/ /*******************************************************************/
int int
scp_session_set_errstr(struct SCP_SESSION *s, char *str) scp_session_set_errstr(struct SCP_SESSION *s, const char *str)
{ {
if (0 == str) if (0 == str)
{ {
@ -396,49 +396,15 @@ scp_session_set_display(struct SCP_SESSION *s, SCP_DISPLAY display)
/*******************************************************************/ /*******************************************************************/
int int
scp_session_set_addr(struct SCP_SESSION *s, int type, void *addr) scp_session_set_addr(struct SCP_SESSION *s, int type, const void *addr)
{ {
struct in_addr ip4;
#ifdef IN6ADDR_ANY_INIT
struct in6_addr ip6;
#endif
int ret;
switch (type) switch (type)
{ {
case SCP_ADDRESS_TYPE_IPV4: case SCP_ADDRESS_TYPE_IPV4:
/* convert from char to 32bit*/
ret = inet_pton(AF_INET, addr, &ip4);
if (ret == 0)
{
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;
}
g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4);
break;
case SCP_ADDRESS_TYPE_IPV4_BIN:
g_memcpy(&(s->ipv4addr), addr, 4); g_memcpy(&(s->ipv4addr), addr, 4);
break; break;
#ifdef IN6ADDR_ANY_INIT #ifdef IN6ADDR_ANY_INIT
case SCP_ADDRESS_TYPE_IPV6: case SCP_ADDRESS_TYPE_IPV6:
/* convert from char to 128bit*/
ret = inet_pton(AF_INET6, addr, &ip6);
if (ret == 0)
{
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;
}
g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16);
break;
case SCP_ADDRESS_TYPE_IPV6_BIN:
g_memcpy(s->ipv6addr, addr, 16); g_memcpy(s->ipv6addr, addr, 16);
break; break;
#endif #endif

@ -59,37 +59,37 @@ int
scp_session_set_rsr(struct SCP_SESSION* s, tui8 rsr); scp_session_set_rsr(struct SCP_SESSION* s, tui8 rsr);
int int
scp_session_set_locale(struct SCP_SESSION* s, char* str); scp_session_set_locale(struct SCP_SESSION* s, const char *str);
int int
scp_session_set_username(struct SCP_SESSION* s, char* str); scp_session_set_username(struct SCP_SESSION* s, const char *str);
int int
scp_session_set_password(struct SCP_SESSION* s, char* str); scp_session_set_password(struct SCP_SESSION* s, const char *str);
int int
scp_session_set_domain(struct SCP_SESSION* s, char* str); scp_session_set_domain(struct SCP_SESSION* s, const char *str);
int int
scp_session_set_program(struct SCP_SESSION* s, char* str); scp_session_set_program(struct SCP_SESSION* s, const char *str);
int int
scp_session_set_directory(struct SCP_SESSION* s, char* str); scp_session_set_directory(struct SCP_SESSION* s, const char *str);
int int
scp_session_set_client_ip(struct SCP_SESSION* s, char* str); scp_session_set_client_ip(struct SCP_SESSION* s, const char *str);
int int
scp_session_set_hostname(struct SCP_SESSION* s, char* str); scp_session_set_hostname(struct SCP_SESSION* s, const char *str);
int int
scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr); scp_session_set_addr(struct SCP_SESSION* s, int type, const void* addr);
int int
scp_session_set_display(struct SCP_SESSION* s, SCP_DISPLAY display); scp_session_set_display(struct SCP_SESSION* s, SCP_DISPLAY display);
int int
scp_session_set_errstr(struct SCP_SESSION* s, char* str); scp_session_set_errstr(struct SCP_SESSION* s, const char *str);
/** /**
* *

@ -51,10 +51,6 @@
#define SCP_ADDRESS_TYPE_IPV4 0x00 #define SCP_ADDRESS_TYPE_IPV4 0x00
#define SCP_ADDRESS_TYPE_IPV6 0x01 #define SCP_ADDRESS_TYPE_IPV6 0x01
/* used in scp_session_set_addr() */
#define SCP_ADDRESS_TYPE_IPV4_BIN 0x80
#define SCP_ADDRESS_TYPE_IPV6_BIN 0x81
#define SCP_COMMAND_SET_DEFAULT 0x0000 #define SCP_COMMAND_SET_DEFAULT 0x0000
#define SCP_COMMAND_SET_MANAGE 0x0001 #define SCP_COMMAND_SET_MANAGE 0x0001
#define SCP_COMMAND_SET_RSR 0x0002 #define SCP_COMMAND_SET_RSR 0x0002

@ -224,7 +224,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION *c, int *scount,
in_uint32_be(c->in_s, sescnt); in_uint32_be(c->in_s, sescnt);
sestmp = sescnt; sestmp = sescnt;
ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0); ds = g_new(struct SCP_DISCONNECTED_SESSION, sescnt);
if (ds == 0) if (ds == 0)
{ {
@ -429,7 +429,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
g_free(s->errstr); g_free(s->errstr);
} }
s->errstr = g_malloc(dim + 1, 0); s->errstr = g_new(char, dim + 1);
if (s->errstr == 0) if (s->errstr == 0)
{ {
@ -450,7 +450,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
g_free(s->errstr); g_free(s->errstr);
} }
s->errstr = g_malloc(dim + 1, 0); s->errstr = g_new(char, dim + 1);
if (s->errstr == 0) if (s->errstr == 0)
{ {
@ -471,7 +471,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
g_free(s->errstr); g_free(s->errstr);
} }
s->errstr = g_malloc(dim + 1, 0); s->errstr = g_new(char, dim + 1);
if (s->errstr == 0) if (s->errstr == 0)
{ {

@ -199,7 +199,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION *c, int *scount,
return SCP_CLIENT_STATE_LIST_OK; return SCP_CLIENT_STATE_LIST_OK;
} }
ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0); ds = g_new(struct SCP_DISCONNECTED_SESSION, sescnt);
if (ds == 0) if (ds == 0)
{ {

@ -150,12 +150,12 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION *c, struct SCP_SES
if (sz == SCP_ADDRESS_TYPE_IPV4) if (sz == SCP_ADDRESS_TYPE_IPV4)
{ {
in_uint32_be(c->in_s, size); in_uint32_be(c->in_s, size);
scp_session_set_addr(session, SCP_ADDRESS_TYPE_IPV4_BIN, &size); scp_session_set_addr(session, sz, &size);
} }
else if (sz == SCP_ADDRESS_TYPE_IPV6) else if (sz == SCP_ADDRESS_TYPE_IPV6)
{ {
in_uint8a(c->in_s, buf, 16); in_uint8a(c->in_s, buf, 16);
scp_session_set_addr(session, SCP_ADDRESS_TYPE_IPV6_BIN, buf); scp_session_set_addr(session, sz, buf);
} }
buf[256] = '\0'; buf[256] = '\0';
@ -202,7 +202,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION *c, struct SCP_SES
} }
enum SCP_SERVER_STATES_E enum SCP_SERVER_STATES_E
scp_v1s_deny_connection(struct SCP_CONNECTION *c, char *reason) scp_v1s_deny_connection(struct SCP_CONNECTION *c, const char *reason)
{ {
int rlen; int rlen;
@ -235,7 +235,8 @@ scp_v1s_deny_connection(struct SCP_CONNECTION *c, char *reason)
} }
enum SCP_SERVER_STATES_E enum SCP_SERVER_STATES_E
scp_v1s_request_password(struct SCP_CONNECTION *c, struct SCP_SESSION *s, char *reason) scp_v1s_request_password(struct SCP_CONNECTION *c, struct SCP_SESSION *s,
const char *reason)
{ {
tui8 sz; tui8 sz;
tui32 version; tui32 version;
@ -392,7 +393,7 @@ scp_v1s_connect_new_session(struct SCP_CONNECTION *c, SCP_DISPLAY d)
/* 032 */ /* 032 */
enum SCP_SERVER_STATES_E enum SCP_SERVER_STATES_E
scp_v1s_connection_error(struct SCP_CONNECTION *c, char *error) scp_v1s_connection_error(struct SCP_CONNECTION *c, const char *error)
{ {
tui16 len; tui16 len;

@ -53,10 +53,11 @@ scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk);
*/ */
/* 002 */ /* 002 */
enum SCP_SERVER_STATES_E enum SCP_SERVER_STATES_E
scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason); scp_v1s_deny_connection(struct SCP_CONNECTION* c, const char *reason);
enum SCP_SERVER_STATES_E enum SCP_SERVER_STATES_E
scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char* reason); scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
const char *reason);
/* 020 */ /* 020 */
enum SCP_SERVER_STATES_E enum SCP_SERVER_STATES_E
@ -72,7 +73,7 @@ scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d);
/* 032 */ /* 032 */
enum SCP_SERVER_STATES_E enum SCP_SERVER_STATES_E
scp_v1s_connection_error(struct SCP_CONNECTION* c, char* error); scp_v1s_connection_error(struct SCP_CONNECTION* c, const char *error);
/* 040 */ /* 040 */
enum SCP_SERVER_STATES_E enum SCP_SERVER_STATES_E

@ -90,12 +90,12 @@ scp_v1s_mng_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s)
if (sz == SCP_ADDRESS_TYPE_IPV4) if (sz == SCP_ADDRESS_TYPE_IPV4)
{ {
in_uint32_be(c->in_s, ipaddr); in_uint32_be(c->in_s, ipaddr);
scp_session_set_addr(session, SCP_ADDRESS_TYPE_IPV4_BIN, &ipaddr); scp_session_set_addr(session, sz, &ipaddr);
} }
else if (sz == SCP_ADDRESS_TYPE_IPV6) else if (sz == SCP_ADDRESS_TYPE_IPV6)
{ {
in_uint8a(c->in_s, buf, 16); in_uint8a(c->in_s, buf, 16);
scp_session_set_addr(session, SCP_ADDRESS_TYPE_IPV6_BIN, buf); scp_session_set_addr(session, sz, buf);
} }
/* reading hostname */ /* reading hostname */
@ -138,7 +138,7 @@ scp_v1s_mng_allow_connection(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
/* 003 */ /* 003 */
enum SCP_SERVER_STATES_E enum SCP_SERVER_STATES_E
scp_v1s_mng_deny_connection(struct SCP_CONNECTION *c, char *reason) scp_v1s_mng_deny_connection(struct SCP_CONNECTION *c, const char *reason)
{ {
int rlen; int rlen;

@ -61,7 +61,7 @@ scp_v1s_mng_allow_connection(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
*/ */
/* 003 */ /* 003 */
enum SCP_SERVER_STATES_E enum SCP_SERVER_STATES_E
scp_v1s_mng_deny_connection(struct SCP_CONNECTION* c, char* reason); scp_v1s_mng_deny_connection(struct SCP_CONNECTION* c, const char *reason);
/** /**
* *

@ -31,7 +31,7 @@
extern struct config_sesman *g_cfg; /* in sesman.c */ extern struct config_sesman *g_cfg; /* in sesman.c */
static void parseCommonStates(enum SCP_SERVER_STATES_E e, char *f); static void parseCommonStates(enum SCP_SERVER_STATES_E e, const char *f);
/******************************************************************************/ /******************************************************************************/
void DEFAULT_CC void DEFAULT_CC
@ -209,7 +209,7 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
g_free(slist); g_free(slist);
} }
static void parseCommonStates(enum SCP_SERVER_STATES_E e, char *f) static void parseCommonStates(enum SCP_SERVER_STATES_E e, const char *f)
{ {
switch (e) switch (e)
{ {

@ -30,7 +30,7 @@
extern struct config_sesman *g_cfg; /* in sesman.c */ extern struct config_sesman *g_cfg; /* in sesman.c */
static void parseCommonStates(enum SCP_SERVER_STATES_E e, char *f); static void parseCommonStates(enum SCP_SERVER_STATES_E e, const char *f);
/******************************************************************************/ /******************************************************************************/
void DEFAULT_CC void DEFAULT_CC
@ -109,7 +109,7 @@ scp_v1_mng_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
auth_end(data); auth_end(data);
} }
static void parseCommonStates(enum SCP_SERVER_STATES_E e, char *f) static void parseCommonStates(enum SCP_SERVER_STATES_E e, const char *f)
{ {
switch (e) switch (e)
{ {

@ -49,9 +49,6 @@ sesman_main_loop(void)
tbus sck_obj; tbus sck_obj;
tbus robjs[8]; tbus robjs[8];
/*main program loop*/
log_message(LOG_LEVEL_INFO, "listening...");
g_sck = g_tcp_socket(); g_sck = g_tcp_socket();
if (g_sck < 0) if (g_sck < 0)
{ {
@ -68,6 +65,8 @@ sesman_main_loop(void)
if (error == 0) if (error == 0)
{ {
log_message(LOG_LEVEL_INFO, "listening to port %s on %s",
g_cfg->listen_port, g_cfg->listen_address);
sck_obj = g_create_wait_obj_from_socket(g_sck, 0); sck_obj = g_create_wait_obj_from_socket(g_sck, 0);
cont = 1; cont = 1;
@ -248,7 +247,7 @@ main(int argc, char **argv)
} }
/* reading config */ /* reading config */
g_cfg = g_malloc(sizeof(struct config_sesman), 1); g_cfg = g_new0(struct config_sesman, 1);
if (0 == g_cfg) if (0 == g_cfg)
{ {
@ -359,8 +358,8 @@ main(int argc, char **argv)
} }
/* start program main loop */ /* start program main loop */
log_message(LOG_LEVEL_ALWAYS, log_message(LOG_LEVEL_INFO,
"starting sesman with pid %d", g_pid); "starting xrdp-sesman with pid %d", g_pid);
/* make sure the /tmp/.X11-unix directory exist */ /* make sure the /tmp/.X11-unix directory exist */
if (!g_directory_exist("/tmp/.X11-unix")) if (!g_directory_exist("/tmp/.X11-unix"))

@ -89,7 +89,9 @@ session_get_bydata(char *name, int width, int height, int bpp, int type, char *c
{ {
case SCP_SESSION_TYPE_XVNC: /* 0 */ case SCP_SESSION_TYPE_XVNC: /* 0 */
type = SESMAN_SESSION_TYPE_XVNC; /* 2 */ type = SESMAN_SESSION_TYPE_XVNC; /* 2 */
policy |= SESMAN_CFG_SESS_POLICY_D; /* Xvnc cannot resize */ /* Xvnc cannot resize */
policy = (enum SESMAN_CFG_SESS_POLICY)
(policy | SESMAN_CFG_SESS_POLICY_D);
break; break;
case SCP_SESSION_TYPE_XRDP: /* 1 */ case SCP_SESSION_TYPE_XRDP: /* 1 */
type = SESMAN_SESSION_TYPE_XRDP; /* 1 */ type = SESMAN_SESSION_TYPE_XRDP; /* 1 */
@ -978,11 +980,11 @@ session_get_bypid(int pid)
struct session_chain *tmp; struct session_chain *tmp;
struct session_item *dummy; struct session_item *dummy;
dummy = g_malloc(sizeof(struct session_item), 1); dummy = g_new0(struct session_item, 1);
if (0 == dummy) if (0 == dummy)
{ {
log_message(LOG_LEVEL_ERROR, "internal error", pid); log_message(LOG_LEVEL_ERROR, "session_get_bypid: out of memory");
return 0; return 0;
} }
@ -1052,7 +1054,7 @@ session_get_byuser(char *user, int *cnt, unsigned char flags)
} }
/* malloc() an array of disconnected sessions */ /* malloc() an array of disconnected sessions */
sess = g_malloc(count *sizeof(struct SCP_DISCONNECTED_SESSION), 1); sess = g_new0(struct SCP_DISCONNECTED_SESSION, count);
if (sess == 0) if (sess == 0)
{ {

@ -49,7 +49,7 @@ nil_signal_handler(int sig)
} }
/******************************************************************************/ /******************************************************************************/
/* chansrv can exit at any time without cleaning up, its an xlib app */ /* chansrv can exit at any time without cleaning up, it's an xlib app */
int APP_CC int APP_CC
chansrv_cleanup(int pid) chansrv_cleanup(int pid)
{ {

@ -75,7 +75,7 @@ sig_sesman_reload_cfg(int sig)
return; return;
} }
cfg = g_malloc(sizeof(struct config_sesman), 1); cfg = g_new0(struct config_sesman, 1);
if (0 == cfg) if (0 == cfg)
{ {

@ -59,7 +59,7 @@ int main(int argc, char **argv)
serv[0] = '\0'; serv[0] = '\0';
port[0] = '\0'; port[0] = '\0';
logging.program_name = g_strdup("sesadmin"); logging.program_name = "sesadmin";
logging.log_file = g_strdup("xrdp-sesadmin.log"); logging.log_file = g_strdup("xrdp-sesadmin.log");
logging.log_level = LOG_LEVEL_DEBUG; logging.log_level = LOG_LEVEL_DEBUG;
logging.enable_syslog = 0; logging.enable_syslog = 0;
@ -124,7 +124,7 @@ int main(int argc, char **argv)
} }
} }
scp_init(&logging); scp_init();
sock = g_tcp_socket(); sock = g_tcp_socket();
if (sock < 0) if (sock < 0)

@ -44,11 +44,11 @@ int main(int argc, char **argv)
int sock; int sock;
log.enable_syslog = 0; log.enable_syslog = 0;
log.log_level = 99; log.log_level = LOG_LEVEL_DEBUG;
log.program_name = g_strdup("sestest"); log.program_name = "sestest";
log.log_file = g_strdup("sestest.log"); log.log_file = g_strdup("sestest.log");
log_start_from_param(&log); log_start_from_param(&log);
scp_init(&log); scp_init();
sock = g_tcp_socket(); sock = g_tcp_socket();
if (sock < 0) if (sock < 0)

@ -54,19 +54,19 @@ verify_pam_conv(int num_msg, const struct pam_message **msg,
struct pam_response *reply; struct pam_response *reply;
struct t_user_pass *user_pass; struct t_user_pass *user_pass;
reply = g_malloc(sizeof(struct pam_response) * num_msg, 1); reply = g_new0(struct pam_response, num_msg);
for (i = 0; i < num_msg; i++) for (i = 0; i < num_msg; i++)
{ {
switch (msg[i]->msg_style) switch (msg[i]->msg_style)
{ {
case PAM_PROMPT_ECHO_ON: /* username */ case PAM_PROMPT_ECHO_ON: /* username */
user_pass = appdata_ptr; user_pass = (struct t_user_pass *) appdata_ptr;
reply[i].resp = g_strdup(user_pass->user); reply[i].resp = g_strdup(user_pass->user);
reply[i].resp_retcode = PAM_SUCCESS; reply[i].resp_retcode = PAM_SUCCESS;
break; break;
case PAM_PROMPT_ECHO_OFF: /* password */ case PAM_PROMPT_ECHO_OFF: /* password */
user_pass = appdata_ptr; user_pass = (struct t_user_pass *) appdata_ptr;
reply[i].resp = g_strdup(user_pass->pass); reply[i].resp = g_strdup(user_pass->pass);
reply[i].resp_retcode = PAM_SUCCESS; reply[i].resp_retcode = PAM_SUCCESS;
break; break;
@ -109,7 +109,7 @@ auth_userpass(char *user, char *pass, int *errorcode)
char service_name[256]; char service_name[256];
get_service_name(service_name); get_service_name(service_name);
auth_info = g_malloc(sizeof(struct t_auth_info), 1); auth_info = g_new0(struct t_auth_info, 1);
g_strncpy(auth_info->user_pass.user, user, 255); g_strncpy(auth_info->user_pass.user, user, 255);
g_strncpy(auth_info->user_pass.pass, pass, 255); g_strncpy(auth_info->user_pass.pass, pass, 255);
auth_info->pamc.conv = &verify_pam_conv; auth_info->pamc.conv = &verify_pam_conv;

@ -33,7 +33,7 @@ int tcp_socket_create(void)
unsigned int option_len; unsigned int option_len;
#endif #endif
/* in win32 a socket is an unsigned int, in linux, its an int */ /* in win32 a socket is an unsigned int, in linux, it's an int */
if ((rv = (int) socket(PF_INET, SOCK_STREAM, 0)) < 0) if ((rv = (int) socket(PF_INET, SOCK_STREAM, 0)) < 0)
return -1; return -1;
@ -193,7 +193,7 @@ int tcp_socket(void)
unsigned int option_len; unsigned int option_len;
#endif #endif
/* in win32 a socket is an unsigned int, in linux, its an int */ /* in win32 a socket is an unsigned int, in linux, it's an int */
if ((rv = (int) socket(PF_INET, SOCK_STREAM, 0)) < 0) if ((rv = (int) socket(PF_INET, SOCK_STREAM, 0)) < 0)
return -1; return -1;

@ -233,7 +233,7 @@ lib_process_channel_data(struct vnc *v, int chanid, int flags, int size,
} }
else else
{ {
log_message(LOG_LEVEL_DEBUG, "lib_process_channel_data: unknown chanid:", log_message(LOG_LEVEL_DEBUG, "lib_process_channel_data: unknown chanid: "
"%d :(v->clip_chanid) %d", chanid, v->clip_chanid); "%d :(v->clip_chanid) %d", chanid, v->clip_chanid);
} }
@ -587,7 +587,7 @@ lib_framebuffer_update(struct vnc *v)
int cy; int cy;
int srcx; int srcx;
int srcy; int srcy;
int encoding; unsigned int encoding;
int Bpp; int Bpp;
int pixel; int pixel;
int r; int r;
@ -1396,7 +1396,7 @@ lib_mod_end(struct vnc *v)
/******************************************************************************/ /******************************************************************************/
int DEFAULT_CC int DEFAULT_CC
lib_mod_set_param(struct vnc *v, char *name, char *value) lib_mod_set_param(struct vnc *v, const char *name, char *value)
{ {
if (g_strcasecmp(name, "username") == 0) if (g_strcasecmp(name, "username") == 0)
{ {
@ -1465,7 +1465,7 @@ lib_mod_check_wait_objs(struct vnc *v)
} }
/******************************************************************************/ /******************************************************************************/
struct vnc *EXPORT_CC tintptr EXPORT_CC
mod_init(void) mod_init(void)
{ {
struct vnc *v; struct vnc *v;
@ -1474,7 +1474,7 @@ mod_init(void)
/* set client functions */ /* set client functions */
v->size = sizeof(struct vnc); v->size = sizeof(struct vnc);
v->version = CURRENT_MOD_VER; v->version = CURRENT_MOD_VER;
v->handle = (long)v; v->handle = (tintptr) v;
v->mod_connect = lib_mod_connect; v->mod_connect = lib_mod_connect;
v->mod_start = lib_mod_start; v->mod_start = lib_mod_start;
v->mod_event = lib_mod_event; v->mod_event = lib_mod_event;
@ -1483,13 +1483,14 @@ mod_init(void)
v->mod_set_param = lib_mod_set_param; v->mod_set_param = lib_mod_set_param;
v->mod_get_wait_objs = lib_mod_get_wait_objs; v->mod_get_wait_objs = lib_mod_get_wait_objs;
v->mod_check_wait_objs = lib_mod_check_wait_objs; v->mod_check_wait_objs = lib_mod_check_wait_objs;
return v; return (tintptr) v;
} }
/******************************************************************************/ /******************************************************************************/
int EXPORT_CC int EXPORT_CC
mod_exit(struct vnc *v) mod_exit(tintptr handle)
{ {
struct vnc *v = (struct vnc *) handle;
log_message(LOG_LEVEL_DEBUG, "VNC mod_exit"); log_message(LOG_LEVEL_DEBUG, "VNC mod_exit");
if (v == 0) if (v == 0)

@ -37,7 +37,7 @@ struct vnc
long param3, long param4); long param3, long param4);
int (*mod_signal)(struct vnc* v); int (*mod_signal)(struct vnc* v);
int (*mod_end)(struct vnc* v); int (*mod_end)(struct vnc* v);
int (*mod_set_param)(struct vnc* v, char* name, char* value); int (*mod_set_param)(struct vnc* v, const char *name, char* value);
int (*mod_session_change)(struct vnc* v, int, int); int (*mod_session_change)(struct vnc* v, int, int);
int (*mod_get_wait_objs)(struct vnc* v, tbus* read_objs, int* rcount, int (*mod_get_wait_objs)(struct vnc* v, tbus* read_objs, int* rcount,
tbus* write_objs, int* wcount, int* timeout); tbus* write_objs, int* wcount, int* timeout);
@ -54,7 +54,7 @@ struct vnc
char* data, int width, int height, int srcx, int srcy); char* data, int width, int height, int srcx, int srcy);
int (*server_set_cursor)(struct vnc* v, int x, int y, char* data, char* mask); int (*server_set_cursor)(struct vnc* v, int x, int y, char* data, char* mask);
int (*server_palette)(struct vnc* v, int* palette); int (*server_palette)(struct vnc* v, int* palette);
int (*server_msg)(struct vnc* v, char* msg, int code); int (*server_msg)(struct vnc* v, const char *msg, int code);
int (*server_is_term)(struct vnc* v); int (*server_is_term)(struct vnc* v);
int (*server_set_clip)(struct vnc* v, int x, int y, int cx, int cy); int (*server_set_clip)(struct vnc* v, int x, int y, int cx, int cy);
int (*server_reset_clip)(struct vnc* v); int (*server_reset_clip)(struct vnc* v);
@ -80,7 +80,7 @@ struct vnc
int (*server_query_channel)(struct vnc* v, int index, int (*server_query_channel)(struct vnc* v, int index,
char* channel_name, char* channel_name,
int* channel_flags); int* channel_flags);
int (*server_get_channel_id)(struct vnc* v, char* name); int (*server_get_channel_id)(struct vnc* v, const char *name);
int (*server_send_to_channel)(struct vnc* v, int channel_id, int (*server_send_to_channel)(struct vnc* v, int channel_id,
char* data, int data_len, char* data, int data_len,
int total_data_len, int flags); int total_data_len, int flags);

@ -27,7 +27,7 @@ keyboard and mouse stuff
num lock */ num lock */
/* this should be fixed in rdesktop */ /* this should be fixed in rdesktop */
/* g_pause_spe flag for special control sent by ms client before scan code /* g_pause_spe flag for special control sent by ms client before scan code
69 is sent to tell that its pause, not num lock. both pause and num 69 is sent to tell that it's pause, not num lock. both pause and num
lock use scan code 69 */ lock use scan code 69 */
/* tab notes */ /* tab notes */

@ -443,8 +443,7 @@ main(int argc, char **argv)
if (fd == -1) if (fd == -1)
{ {
g_writeln("problem opening to xrdp.pid [%s]", pid_file); g_writeln("cannot open %s, maybe xrdp is not running", pid_file);
g_writeln("maybe its not running");
} }
else else
{ {
@ -598,6 +597,7 @@ main(int argc, char **argv)
g_sync_mutex = tc_mutex_create(); g_sync_mutex = tc_mutex_create();
g_sync1_mutex = tc_mutex_create(); g_sync1_mutex = tc_mutex_create();
pid = g_getpid(); pid = g_getpid();
log_message(LOG_LEVEL_INFO, "starting xrdp with pid %d", pid);
g_snprintf(text, 255, "xrdp_%8.8x_main_term", pid); g_snprintf(text, 255, "xrdp_%8.8x_main_term", pid);
g_term_event = g_create_wait_obj(text); g_term_event = g_create_wait_obj(text);

@ -37,6 +37,7 @@
#include "file.h" #include "file.h"
#include "file_loc.h" #include "file_loc.h"
#include "xrdp_client_info.h" #include "xrdp_client_info.h"
#include "log.h"
/* xrdp.c */ /* xrdp.c */
long APP_CC long APP_CC
@ -140,7 +141,8 @@ xrdp_wm_delete_all_children(struct xrdp_wm* self);
int APP_CC int APP_CC
xrdp_wm_show_log(struct xrdp_wm *self); xrdp_wm_show_log(struct xrdp_wm *self);
int APP_CC int APP_CC
xrdp_wm_log_msg(struct xrdp_wm* self, char* msg); xrdp_wm_log_msg(struct xrdp_wm *self, enum logLevels loglevel,
const char *fmt, ...) printflike(3, 4);
int APP_CC int APP_CC
xrdp_wm_get_wait_objs(struct xrdp_wm* self, tbus* robjs, int* rc, xrdp_wm_get_wait_objs(struct xrdp_wm* self, tbus* robjs, int* rc,
tbus* wobjs, int* wc, int* timeout); tbus* wobjs, int* wc, int* timeout);
@ -264,9 +266,9 @@ xrdp_painter_draw_bitmap(struct xrdp_painter* self,
struct xrdp_bitmap* to_draw, struct xrdp_bitmap* to_draw,
int x, int y, int cx, int cy); int x, int y, int cx, int cy);
int APP_CC int APP_CC
xrdp_painter_text_width(struct xrdp_painter* self, char* text); xrdp_painter_text_width(struct xrdp_painter* self, const char *text);
int APP_CC int APP_CC
xrdp_painter_text_height(struct xrdp_painter* self, char* text); xrdp_painter_text_height(struct xrdp_painter* self, const char *text);
int APP_CC int APP_CC
xrdp_painter_draw_text(struct xrdp_painter* self, xrdp_painter_draw_text(struct xrdp_painter* self,
struct xrdp_bitmap* bitmap, struct xrdp_bitmap* bitmap,
@ -464,7 +466,7 @@ int DEFAULT_CC
server_query_channel(struct xrdp_mod* mod, int index, char* channel_name, server_query_channel(struct xrdp_mod* mod, int index, char* channel_name,
int* channel_flags); int* channel_flags);
int DEFAULT_CC int DEFAULT_CC
server_get_channel_id(struct xrdp_mod* mod, char* name); server_get_channel_id(struct xrdp_mod* mod, const char *name);
int DEFAULT_CC int DEFAULT_CC
server_send_to_channel(struct xrdp_mod* mod, int channel_id, server_send_to_channel(struct xrdp_mod* mod, int channel_id,
char* data, int data_len, char* data, int data_len,

@ -38,7 +38,7 @@
while (0) while (0)
static const int g_crc_table[256] = static const unsigned int g_crc_table[256] =
{ {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,

@ -167,7 +167,7 @@ xrdp_encoder_delete(struct xrdp_encoder *self)
{ {
while (!fifo_is_empty(fifo)) while (!fifo_is_empty(fifo))
{ {
enc = fifo_remove_item(fifo); enc = (XRDP_ENC_DATA *) fifo_remove_item(fifo);
if (enc == 0) if (enc == 0)
{ {
continue; continue;
@ -185,7 +185,7 @@ xrdp_encoder_delete(struct xrdp_encoder *self)
{ {
while (!fifo_is_empty(fifo)) while (!fifo_is_empty(fifo))
{ {
enc_done = fifo_remove_item(fifo); enc_done = (XRDP_ENC_DATA_DONE *) fifo_remove_item(fifo);
if (enc_done == 0) if (enc_done == 0)
{ {
continue; continue;

@ -370,6 +370,8 @@ xrdp_listen_main_loop(struct xrdp_listen *self)
if (error == 0) if (error == 0)
{ {
log_message(LOG_LEVEL_INFO, "listening to port %s on %s",
port, address);
if (tcp_nodelay) if (tcp_nodelay)
{ {
if (g_tcp_set_no_delay(self->listen_trans->sck)) if (g_tcp_set_no_delay(self->listen_trans->sck))

@ -273,7 +273,6 @@ xrdp_wm_parse_domain_information(char *originalDomainInfo, int comboMax,
int pos; int pos;
int comboxindex; int comboxindex;
char index[2]; char index[2];
char debugstr[256];
/* If the first char in the domain name is '_' we use the domain /* If the first char in the domain name is '_' we use the domain
name as IP*/ name as IP*/
@ -300,11 +299,9 @@ xrdp_wm_parse_domain_information(char *originalDomainInfo, int comboMax,
/* we just accept values 0-9 (one figure) */ /* we just accept values 0-9 (one figure) */
g_strncpy(index, &originalDomainInfo[pos + 3], 1); g_strncpy(index, &originalDomainInfo[pos + 3], 1);
comboxindex = g_htoi(index); comboxindex = g_htoi(index);
g_snprintf(debugstr, 255, "Value of index (as char): %s " log_message(LOG_LEVEL_DEBUG,
"(converted) : %d (max) : %d", index, comboxindex, "index value as string: %s, as int: %d, max: %d",
comboMax - 1); index, comboxindex, comboMax - 1);
debugstr[255] = 0;
log_message(LOG_LEVEL_DEBUG, debugstr);
/* limit to max number of items in combo box */ /* limit to max number of items in combo box */
if ((comboxindex > 0) && (comboxindex < comboMax)) if ((comboxindex > 0) && (comboxindex < comboMax))
{ {

@ -176,8 +176,8 @@ xrdp_mm_send_login(struct xrdp_mm *self)
char *name; char *name;
char *value; char *value;
xrdp_wm_log_msg(self->wm, "sending login info to session manager, " xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
"please wait..."); "sending login info to session manager, please wait...");
username = 0; username = 0;
password = 0; password = 0;
self->code = 0; self->code = 0;
@ -210,7 +210,8 @@ xrdp_mm_send_login(struct xrdp_mm *self)
if ((username == 0) || (password == 0)) if ((username == 0) || (password == 0))
{ {
xrdp_wm_log_msg(self->wm, "Error finding username and password"); xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
"Error finding username and password");
return 1; return 1;
} }
@ -277,7 +278,8 @@ xrdp_mm_send_login(struct xrdp_mm *self)
if (rv != 0) if (rv != 0)
{ {
xrdp_wm_log_msg(self->wm, "xrdp_mm_send_login: xrdp_mm_send_login failed"); xrdp_wm_log_msg(self->wm, LOG_LEVEL_WARNING,
"xrdp_mm_send_login: xrdp_mm_send_login failed");
} }
return rv; return rv;
@ -289,7 +291,8 @@ xrdp_mm_send_login(struct xrdp_mm *self)
then it copies the corresponding login_values item into 'dest' then it copies the corresponding login_values item into 'dest'
'dest' must be at least 'dest_len' + 1 bytes in size */ 'dest' must be at least 'dest_len' + 1 bytes in size */
static int APP_CC static int APP_CC
xrdp_mm_get_value(struct xrdp_mm *self, char *aname, char *dest, int dest_len) xrdp_mm_get_value(struct xrdp_mm *self, const char *aname, char *dest,
int dest_len)
{ {
char *name; char *name;
char *value; char *value;
@ -339,18 +342,18 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self)
if (xrdp_mm_get_value(self, "lib", lib, 255) != 0) if (xrdp_mm_get_value(self, "lib", lib, 255) != 0)
{ {
g_snprintf(text, 255, "no library name specified in xrdp.ini, please add " xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
"lib=libxrdp-vnc.so or similar"); "no library name specified in xrdp.ini, please add "
xrdp_wm_log_msg(self->wm, text); "lib=libxrdp-vnc.so or similar");
return 1; return 1;
} }
if (lib[0] == 0) if (lib[0] == 0)
{ {
g_snprintf(text, 255, "empty library name specified in xrdp.ini, please " xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
"add lib=libxrdp-vnc.so or similar"); "empty library name specified in xrdp.ini, please "
xrdp_wm_log_msg(self->wm, text); "add lib=libxrdp-vnc.so or similar");
return 1; return 1;
} }
@ -372,10 +375,9 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self)
if (func == 0) if (func == 0)
{ {
g_snprintf(text, 255, "error finding proc mod_init in %s, not a valid " xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
"xrdp backend", lib); "error finding proc mod_init in %s, "
xrdp_wm_log_msg(self->wm, text); "not a valid xrdp backend", lib);
log_message(LOG_LEVEL_ERROR,text);
} }
self->mod_init = (struct xrdp_mod * ( *)(void))func; self->mod_init = (struct xrdp_mod * ( *)(void))func;
@ -388,10 +390,9 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self)
if (func == 0) if (func == 0)
{ {
g_snprintf(text, 255, "error finding proc mod_exit in %s, not a valid " xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
"xrdp backend", lib); "error finding proc mod_exit in %s, "
xrdp_wm_log_msg(self->wm, text); "not a valid xrdp backend", lib);
log_message(LOG_LEVEL_ERROR,text);
} }
self->mod_exit = (int ( *)(struct xrdp_mod *))func; self->mod_exit = (int ( *)(struct xrdp_mod *))func;
@ -413,10 +414,10 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self)
} }
else else
{ {
g_snprintf(text, 255, "error loading %s specified in xrdp.ini, please " xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
"add a valid entry like lib=libxrdp-vnc.so or similar", lib); "error loading %s specified in xrdp.ini, please "
xrdp_wm_log_msg(self->wm, text); "add a valid entry like lib=libxrdp-vnc.so or "
log_message(LOG_LEVEL_ERROR,text); "similar", lib);
return 1; return 1;
} }
@ -763,7 +764,7 @@ xrdp_mm_process_rail_create_window(struct xrdp_mm* self, struct stream* s)
in_uint16_le(s, title_bytes); in_uint16_le(s, title_bytes);
if (title_bytes > 0) if (title_bytes > 0)
{ {
rwso.title_info = g_malloc(title_bytes + 1, 0); rwso.title_info = g_new(char, title_bytes + 1);
in_uint8a(s, rwso.title_info, title_bytes); in_uint8a(s, rwso.title_info, title_bytes);
rwso.title_info[title_bytes] = 0; rwso.title_info[title_bytes] = 0;
} }
@ -946,7 +947,7 @@ xrdp_mm_process_rail_update_window_text(struct xrdp_mm* self, struct stream* s)
g_memset(&rwso, 0, sizeof(rwso)); g_memset(&rwso, 0, sizeof(rwso));
in_uint32_le(s, size); /* title size */ in_uint32_le(s, size); /* title size */
rwso.title_info = g_malloc(size + 1, 0); rwso.title_info = g_new(char, size + 1);
in_uint8a(s, rwso.title_info, size); in_uint8a(s, rwso.title_info, size);
rwso.title_info[size] = 0; rwso.title_info[size] = 0;
g_writeln(" set window title %s size %d 0x%8.8x", rwso.title_info, size, flags); g_writeln(" set window title %s size %d 0x%8.8x", rwso.title_info, size, flags);
@ -1111,7 +1112,7 @@ xrdp_mm_chan_send_init(struct xrdp_mm *self)
/*****************************************************************************/ /*****************************************************************************/
/* connect to chansrv */ /* connect to chansrv */
static int APP_CC static int APP_CC
xrdp_mm_connect_chansrv(struct xrdp_mm *self, char *ip, char *port) xrdp_mm_connect_chansrv(struct xrdp_mm *self, const char *ip, const char *port)
{ {
int index; int index;
@ -1192,7 +1193,6 @@ xrdp_mm_process_login_response(struct xrdp_mm *self, struct stream *s)
int ok; int ok;
int display; int display;
int rv; int rv;
char text[256];
char ip[256]; char ip[256];
char port[256]; char port[256];
@ -1203,9 +1203,8 @@ xrdp_mm_process_login_response(struct xrdp_mm *self, struct stream *s)
if (ok) if (ok)
{ {
self->display = display; self->display = display;
g_snprintf(text, 255, "xrdp_mm_process_login_response: login successful " xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
"for display %d", display); "login successful for display %d", display);
xrdp_wm_log_msg(self->wm, text);
if (xrdp_mm_setup_mod1(self) == 0) if (xrdp_mm_setup_mod1(self) == 0)
{ {
@ -1231,10 +1230,8 @@ xrdp_mm_process_login_response(struct xrdp_mm *self, struct stream *s)
} }
else else
{ {
xrdp_wm_log_msg(self->wm, "xrdp_mm_process_login_response: " xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
"login failed"); "login failed for display %d", display);
log_message(LOG_LEVEL_INFO,"xrdp_mm_process_login_response: "
"login failed");
xrdp_wm_show_log(self->wm); xrdp_wm_show_log(self->wm);
if (self->wm->hide_log_window) if (self->wm->hide_log_window)
{ {
@ -1398,8 +1395,9 @@ xrdp_mm_sesman_data_in(struct trans *trans)
error = xrdp_mm_process_login_response(self, s); error = xrdp_mm_process_login_response(self, s);
break; break;
default: default:
xrdp_wm_log_msg(self->wm, "An undefined reply code was received from sesman"); xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
log_message(LOG_LEVEL_ERROR,"Fatal xrdp_mm_sesman_data_in: unknown cmd code %d", code); "Undefined reply code %d received from sesman",
code);
cleanup_sesman_connection(self); cleanup_sesman_connection(self);
break; break;
} }
@ -1489,7 +1487,7 @@ access_control(char *username, char *password, char *srv)
else else
{ {
log_message(LOG_LEVEL_ERROR, "Corrupt reply size or " log_message(LOG_LEVEL_ERROR, "Corrupt reply size or "
"version from sesman: %d", size); "version from sesman: %ld", size);
} }
} }
else else
@ -1801,8 +1799,6 @@ xrdp_mm_connect(struct xrdp_mm *self)
char *name; char *name;
char *value; char *value;
char ip[256]; char ip[256];
char errstr[256];
char text[256];
char port[8]; char port[8];
char chansrvport[256]; char chansrvport[256];
#ifdef ACCESS #ifdef ACCESS
@ -1820,8 +1816,6 @@ xrdp_mm_connect(struct xrdp_mm *self)
/* make sure we start in correct state */ /* make sure we start in correct state */
cleanup_states(self); cleanup_states(self);
g_memset(ip, 0, sizeof(ip)); g_memset(ip, 0, sizeof(ip));
g_memset(errstr, 0, sizeof(errstr));
g_memset(text, 0, sizeof(text));
g_memset(port, 0, sizeof(port)); g_memset(port, 0, sizeof(port));
g_memset(chansrvport, 0, sizeof(chansrvport)); g_memset(chansrvport, 0, sizeof(chansrvport));
rv = 0; /* success */ rv = 0; /* success */
@ -1884,10 +1878,10 @@ xrdp_mm_connect(struct xrdp_mm *self)
if (use_pam_auth) if (use_pam_auth)
{ {
int reply; int reply;
char replytxt[128];
char pam_error[128]; char pam_error[128];
const char *additionalError; const char *additionalError;
xrdp_wm_log_msg(self->wm, "Please wait, we now perform access control..."); xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
"Please wait, we now perform access control...");
/* g_writeln("we use pam modules to check if we can approve this user"); */ /* g_writeln("we use pam modules to check if we can approve this user"); */
if (!g_strncmp(pam_auth_username, "same", 255)) if (!g_strncmp(pam_auth_username, "same", 255))
@ -1905,19 +1899,14 @@ xrdp_mm_connect(struct xrdp_mm *self)
/* access_control return 0 on success */ /* access_control return 0 on success */
reply = access_control(pam_auth_username, pam_auth_password, pam_auth_sessionIP); reply = access_control(pam_auth_username, pam_auth_password, pam_auth_sessionIP);
g_sprintf(replytxt, "Reply from access control: %s", xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
getPAMError(reply, pam_error, 127)); "Reply from access control: %s",
getPAMError(reply, pam_error, 127));
xrdp_wm_log_msg(self->wm, replytxt);
log_message(LOG_LEVEL_INFO, replytxt);
additionalError = getPAMAdditionalErrorInfo(reply, self); additionalError = getPAMAdditionalErrorInfo(reply, self);
if (additionalError) if (additionalError && additionalError[0])
{ {
g_snprintf(replytxt, 127, "%s", additionalError); xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "%s", additionalError);
if (replytxt[0])
{
xrdp_wm_log_msg(self->wm, replytxt);
}
} }
if (reply != 0) if (reply != 0)
@ -1936,8 +1925,8 @@ xrdp_mm_connect(struct xrdp_mm *self)
self->sesman_trans = trans_create(TRANS_MODE_TCP, 8192, 8192); self->sesman_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
self->sesman_trans->is_term = g_is_term; self->sesman_trans->is_term = g_is_term;
xrdp_mm_get_sesman_port(port, sizeof(port)); xrdp_mm_get_sesman_port(port, sizeof(port));
g_snprintf(text, 255, "connecting to sesman ip %s port %s", ip, port); xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
xrdp_wm_log_msg(self->wm, text); "connecting to sesman ip %s port %s", ip, port);
/* xrdp_mm_sesman_data_in is the callback that is called when data arrives */ /* xrdp_mm_sesman_data_in is the callback that is called when data arrives */
self->sesman_trans->trans_data_in = xrdp_mm_sesman_data_in; self->sesman_trans->trans_data_in = xrdp_mm_sesman_data_in;
self->sesman_trans->header_size = 8; self->sesman_trans->header_size = 8;
@ -1961,16 +1950,15 @@ xrdp_mm_connect(struct xrdp_mm *self)
if (ok) if (ok)
{ {
/* fully connect */ /* fully connect */
xrdp_wm_log_msg(self->wm, "sesman connect ok"); xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "sesman connect ok");
self->connected_state = 1; self->connected_state = 1;
rv = xrdp_mm_send_login(self); rv = xrdp_mm_send_login(self);
} }
else else
{ {
g_snprintf(errstr, 255, "Failure to connect to sesman: %s port: %s", xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
ip, port); "Error connecting to sesman: %s port: %s",
xrdp_wm_log_msg(self->wm, errstr); ip, port);
log_message(LOG_LEVEL_ERROR,errstr);
trans_delete(self->sesman_trans); trans_delete(self->sesman_trans);
self->sesman_trans = 0; self->sesman_trans = 0;
self->sesman_trans_up = 0; self->sesman_trans_up = 0;
@ -1989,9 +1977,8 @@ xrdp_mm_connect(struct xrdp_mm *self)
else else
{ {
/* connect error */ /* connect error */
g_snprintf(errstr, 255, "Failure to connect to: %s", ip); xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
log_message(LOG_LEVEL_ERROR,errstr); "Error connecting to: %s", ip);
xrdp_wm_log_msg(self->wm, errstr);
rv = 1; /* failure */ rv = 1; /* failure */
} }
} }
@ -2664,7 +2651,7 @@ server_msg(struct xrdp_mod *mod, char *msg, int code)
} }
wm = (struct xrdp_wm *)(mod->wm); wm = (struct xrdp_wm *)(mod->wm);
return xrdp_wm_log_msg(wm, msg); return xrdp_wm_log_msg(wm, LOG_LEVEL_DEBUG, "%s", msg);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -3159,7 +3146,7 @@ server_query_channel(struct xrdp_mod *mod, int index, char *channel_name,
/*****************************************************************************/ /*****************************************************************************/
/* returns -1 on error */ /* returns -1 on error */
int DEFAULT_CC int DEFAULT_CC
server_get_channel_id(struct xrdp_mod *mod, char *name) server_get_channel_id(struct xrdp_mod *mod, const char *name)
{ {
struct xrdp_wm *wm; struct xrdp_wm *wm;

@ -262,7 +262,7 @@ xrdp_painter_rop(int rop, int src, int dst)
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
xrdp_painter_text_width(struct xrdp_painter *self, char *text) xrdp_painter_text_width(struct xrdp_painter *self, const char *text)
{ {
int index; int index;
int rv; int rv;
@ -299,7 +299,7 @@ xrdp_painter_text_width(struct xrdp_painter *self, char *text)
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
xrdp_painter_text_height(struct xrdp_painter *self, char *text) xrdp_painter_text_height(struct xrdp_painter *self, const char *text)
{ {
int index; int index;
int rv; int rv;

@ -42,7 +42,7 @@ struct xrdp_mod
long param3, long param4); long param3, long param4);
int (*mod_signal)(struct xrdp_mod* v); int (*mod_signal)(struct xrdp_mod* v);
int (*mod_end)(struct xrdp_mod* v); int (*mod_end)(struct xrdp_mod* v);
int (*mod_set_param)(struct xrdp_mod* v, char* name, char* value); int (*mod_set_param)(struct xrdp_mod* v, const char *name, char* value);
int (*mod_session_change)(struct xrdp_mod* v, int, int); int (*mod_session_change)(struct xrdp_mod* v, int, int);
int (*mod_get_wait_objs)(struct xrdp_mod* v, tbus* read_objs, int* rcount, int (*mod_get_wait_objs)(struct xrdp_mod* v, tbus* read_objs, int* rcount,
tbus* write_objs, int* wcount, int* timeout); tbus* write_objs, int* wcount, int* timeout);
@ -88,7 +88,7 @@ struct xrdp_mod
int (*server_query_channel)(struct xrdp_mod* v, int index, int (*server_query_channel)(struct xrdp_mod* v, int index,
char* channel_name, char* channel_name,
int* channel_flags); int* channel_flags);
int (*server_get_channel_id)(struct xrdp_mod* v, char* name); int (*server_get_channel_id)(struct xrdp_mod* v, const char *name);
int (*server_send_to_channel)(struct xrdp_mod* v, int channel_id, int (*server_send_to_channel)(struct xrdp_mod* v, int channel_id,
char* data, int data_len, char* data, int data_len,
int total_data_len, int flags); int total_data_len, int flags);
@ -216,7 +216,7 @@ struct xrdp_brush_item
{ {
int stamp; int stamp;
/* expand this to a structure to handle more complicated brushes /* expand this to a structure to handle more complicated brushes
for now its 8x8 1bpp brushes only */ for now it's 8x8 1bpp brushes only */
char pattern[8]; char pattern[8];
}; };

@ -18,6 +18,8 @@
* simple window manager * simple window manager
*/ */
#include <stdarg.h>
#include <stdio.h>
#include "xrdp.h" #include "xrdp.h"
#include "log.h" #include "log.h"
@ -45,7 +47,7 @@ xrdp_wm_create(struct xrdp_process *owner,
pid = g_getpid(); pid = g_getpid();
g_snprintf(event_name, 255, "xrdp_%8.8x_wm_login_mode_event_%8.8x", g_snprintf(event_name, 255, "xrdp_%8.8x_wm_login_mode_event_%8.8x",
pid, owner->session_id); pid, owner->session_id);
log_message(LOG_LEVEL_DEBUG,event_name); log_message(LOG_LEVEL_DEBUG, "%s", event_name);
self->login_mode_event = g_create_wait_obj(event_name); self->login_mode_event = g_create_wait_obj(event_name);
self->painter = xrdp_painter_create(self, self->session); self->painter = xrdp_painter_create(self, self->session);
self->cache = xrdp_cache_create(self, self->session, self->client_info); self->cache = xrdp_cache_create(self, self->session, self->client_info);
@ -60,7 +62,7 @@ xrdp_wm_create(struct xrdp_process *owner,
self->current_surface_index = 0xffff; /* screen */ self->current_surface_index = 0xffff; /* screen */
/* to store configuration from xrdp.ini */ /* to store configuration from xrdp.ini */
self->xrdp_config = g_malloc(sizeof(struct xrdp_config), 1); self->xrdp_config = g_new0(struct xrdp_config, 1);
return self; return self;
} }
@ -546,7 +548,7 @@ xrdp_wm_init(struct xrdp_wm *self)
struct list *names; struct list *names;
struct list *values; struct list *values;
char *q; char *q;
char *r; const char *r;
char param[256]; char param[256];
char section_name[256]; char section_name[256];
char cfg_file[256]; char cfg_file[256];
@ -677,9 +679,9 @@ xrdp_wm_init(struct xrdp_wm *self)
else else
{ {
/* requested module name not found in xrdp.ini */ /* requested module name not found in xrdp.ini */
g_writeln(" xrdp_wm_init: file_read_section returned non-zero, requested section not found in xrdp.ini"); xrdp_wm_log_msg(self, LOG_LEVEL_ERROR,
xrdp_wm_log_msg(self, "ERROR: The requested xrdp module not found in xrdp.ini," "Section \"%s\" not configured in xrdp.ini",
" falling back to login window"); section_name);
} }
list_delete(names); list_delete(names);
@ -1725,8 +1727,8 @@ callback(long id, int msg, long param1, long param2, long param3, long param4)
rv = xrdp_wm_process_input_mousex(wm, param3, param1, param2); rv = xrdp_wm_process_input_mousex(wm, param3, param1, param2);
break; break;
case 0x4444: /* invalidate, this is not from RDP_DATA_PDU_INPUT */ case 0x4444: /* invalidate, this is not from RDP_DATA_PDU_INPUT */
/* like the rest, its from RDP_PDU_DATA with code 33 */ /* like the rest, it's from RDP_PDU_DATA with code 33 */
/* its the rdp client asking for a screen update */ /* it's the rdp client asking for a screen update */
MAKERECT(rect, param1, param2, param3, param4); MAKERECT(rect, param1, param2, param3, param4);
rv = xrdp_bitmap_invalidate(wm->screen, &rect); rv = xrdp_bitmap_invalidate(wm->screen, &rect);
break; break;
@ -1857,22 +1859,21 @@ xrdp_wm_log_wnd_notify(struct xrdp_bitmap *wnd,
return 0; return 0;
} }
void add_string_to_logwindow(char *msg, struct list *log) static void
add_string_to_logwindow(const char *msg, struct list *log)
{ {
const char *new_part_message;
char *new_part_message; const char *current_pointer = msg;
char *current_pointer = msg ; int len_done = 0;
int processedlen = 0;
do do
{ {
new_part_message = g_strndup(current_pointer, LOG_WINDOW_CHAR_PER_LINE) ; new_part_message = g_strndup(current_pointer, LOG_WINDOW_CHAR_PER_LINE);
g_writeln("%s",new_part_message); g_writeln("%s", new_part_message);
list_add_item(log, (long)new_part_message); list_add_item(log, (tintptr) new_part_message);
processedlen = processedlen + g_strlen(new_part_message); len_done += g_strlen(new_part_message);
current_pointer = current_pointer + g_strlen(new_part_message) ; current_pointer += g_strlen(new_part_message);
} } while ((len_done < g_strlen(msg)) && (len_done < DEFAULT_STRING_LEN));
while ((processedlen < g_strlen(msg)) && (processedlen < DEFAULT_STRING_LEN));
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1966,8 +1967,17 @@ xrdp_wm_show_log(struct xrdp_wm *self)
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
xrdp_wm_log_msg(struct xrdp_wm *self, char *msg) xrdp_wm_log_msg(struct xrdp_wm *self, enum logLevels loglevel,
const char *fmt, ...)
{ {
va_list ap;
char msg[256];
va_start(ap, fmt);
vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
log_message(loglevel, "xrdp_wm_log_msg: %s", msg);
add_string_to_logwindow(msg, self->log); add_string_to_logwindow(msg, self->log);
return 0; return 0;
} }

@ -466,8 +466,8 @@ main(int argc, char **argv)
if (fd == -1) if (fd == -1)
{ {
g_writeln("problem opening to xrdp.pid"); g_writeln("cannot open %s, maybe xrdp is not running",
g_writeln("maybe its not running"); pid_file);
} }
else else
{ {

@ -53,8 +53,10 @@ static int send_init(struct wts_obj *wts);
static int can_send(int sck, int millis); static int can_send(int sck, int millis);
static int can_recv(int sck, int millis); static int can_recv(int sck, int millis);
static char g_xrdpapi_magic[12] = static const unsigned char g_xrdpapi_magic[12] =
{ 0x78, 0x32, 0x10, 0x67, 0x00, 0x92, 0x30, 0x56, 0xff, 0xd8, 0xa9, 0x1f }; {
0x78, 0x32, 0x10, 0x67, 0x00, 0x92, 0x30, 0x56, 0xff, 0xd8, 0xa9, 0x1f
};
/* /*
* Opens a handle to the server end of a specified virtual channel - this * Opens a handle to the server end of a specified virtual channel - this

@ -697,7 +697,7 @@ process_server_window_new_update(struct mod *mod, struct stream *s)
if (title_bytes > 0) if (title_bytes > 0)
{ {
rwso.title_info = g_malloc(title_bytes + 1, 0); rwso.title_info = g_new(char, title_bytes + 1);
in_uint8a(s, rwso.title_info, title_bytes); in_uint8a(s, rwso.title_info, title_bytes);
rwso.title_info[title_bytes] = 0; rwso.title_info[title_bytes] = 0;
} }
@ -1088,7 +1088,7 @@ process_server_paint_rect_shmem(struct mod *amod, struct stream *s)
if (amod->screen_shmem_id_mapped == 0) if (amod->screen_shmem_id_mapped == 0)
{ {
amod->screen_shmem_id = shmem_id; amod->screen_shmem_id = shmem_id;
amod->screen_shmem_pixels = g_shmat(amod->screen_shmem_id); amod->screen_shmem_pixels = (char *) g_shmat(amod->screen_shmem_id);
if (amod->screen_shmem_pixels == (void*)-1) if (amod->screen_shmem_pixels == (void*)-1)
{ {
/* failed */ /* failed */
@ -1199,7 +1199,7 @@ process_server_paint_rect_shmem_ex(struct mod *amod, struct stream *s)
if (amod->screen_shmem_id_mapped == 0) if (amod->screen_shmem_id_mapped == 0)
{ {
amod->screen_shmem_id = shmem_id; amod->screen_shmem_id = shmem_id;
amod->screen_shmem_pixels = g_shmat(amod->screen_shmem_id); amod->screen_shmem_pixels = (char *) g_shmat(amod->screen_shmem_id);
if (amod->screen_shmem_pixels == (void*)-1) if (amod->screen_shmem_pixels == (void*)-1)
{ {
/* failed */ /* failed */
@ -1479,7 +1479,7 @@ lib_mod_end(struct mod *mod)
/******************************************************************************/ /******************************************************************************/
/* return error */ /* return error */
int DEFAULT_CC int DEFAULT_CC
lib_mod_set_param(struct mod *mod, char *name, char *value) lib_mod_set_param(struct mod *mod, const char *name, char *value)
{ {
if (g_strcasecmp(name, "username") == 0) if (g_strcasecmp(name, "username") == 0)
{ {
@ -1552,7 +1552,7 @@ lib_mod_frame_ack(struct mod *amod, int flags, int frame_id)
} }
/******************************************************************************/ /******************************************************************************/
struct mod *EXPORT_CC tintptr EXPORT_CC
mod_init(void) mod_init(void)
{ {
struct mod *mod; struct mod *mod;
@ -1560,7 +1560,7 @@ mod_init(void)
mod = (struct mod *)g_malloc(sizeof(struct mod), 1); mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
mod->size = sizeof(struct mod); mod->size = sizeof(struct mod);
mod->version = CURRENT_MOD_VER; mod->version = CURRENT_MOD_VER;
mod->handle = (tbus)mod; mod->handle = (tintptr) mod;
mod->mod_connect = lib_mod_connect; mod->mod_connect = lib_mod_connect;
mod->mod_start = lib_mod_start; mod->mod_start = lib_mod_start;
mod->mod_event = lib_mod_event; mod->mod_event = lib_mod_event;
@ -1570,13 +1570,15 @@ mod_init(void)
mod->mod_get_wait_objs = lib_mod_get_wait_objs; mod->mod_get_wait_objs = lib_mod_get_wait_objs;
mod->mod_check_wait_objs = lib_mod_check_wait_objs; mod->mod_check_wait_objs = lib_mod_check_wait_objs;
mod->mod_frame_ack = lib_mod_frame_ack; mod->mod_frame_ack = lib_mod_frame_ack;
return mod; return (tintptr) mod;
} }
/******************************************************************************/ /******************************************************************************/
int EXPORT_CC int EXPORT_CC
mod_exit(struct mod *mod) mod_exit(tintptr handle)
{ {
struct mod *mod = (struct mod *) handle;
if (mod == 0) if (mod == 0)
{ {
return 0; return 0;

@ -39,7 +39,7 @@ struct mod
tbus param3, tbus param4); tbus param3, tbus param4);
int (*mod_signal)(struct mod* v); int (*mod_signal)(struct mod* v);
int (*mod_end)(struct mod* v); int (*mod_end)(struct mod* v);
int (*mod_set_param)(struct mod* v, char* name, char* value); int (*mod_set_param)(struct mod* v, const char *name, char* value);
int (*mod_session_change)(struct mod* v, int, int); int (*mod_session_change)(struct mod* v, int, int);
int (*mod_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount, int (*mod_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount,
tbus* write_objs, int* wcount, int* timeout); tbus* write_objs, int* wcount, int* timeout);
@ -58,7 +58,7 @@ struct mod
int srcx, int srcy); int srcx, int srcy);
int (*server_set_cursor)(struct mod* v, int x, int y, char* data, char* mask); int (*server_set_cursor)(struct mod* v, int x, int y, char* data, char* mask);
int (*server_palette)(struct mod* v, int* palette); int (*server_palette)(struct mod* v, int* palette);
int (*server_msg)(struct mod* v, char* msg, int code); int (*server_msg)(struct mod* v, const char *msg, int code);
int (*server_is_term)(struct mod* v); int (*server_is_term)(struct mod* v);
int (*server_set_clip)(struct mod* v, int x, int y, int cx, int cy); int (*server_set_clip)(struct mod* v, int x, int y, int cx, int cy);
int (*server_reset_clip)(struct mod* v); int (*server_reset_clip)(struct mod* v);
@ -84,7 +84,7 @@ struct mod
int (*server_query_channel)(struct mod* v, int index, int (*server_query_channel)(struct mod* v, int index,
char* channel_name, char* channel_name,
int* channel_flags); int* channel_flags);
int (*server_get_channel_id)(struct mod* v, char* name); int (*server_get_channel_id)(struct mod* v, const char *name);
int (*server_send_to_channel)(struct mod* v, int channel_id, int (*server_send_to_channel)(struct mod* v, int channel_id,
char* data, int data_len, char* data, int data_len,
int total_data_len, int flags); int total_data_len, int flags);

Loading…
Cancel
Save