From ae5bb5bf9c26b850bb80725e4748a08b55815002 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:15 -0700 Subject: [PATCH 01/32] Fix incorrect use of "it's" and "its", adjust wording --- common/os_calls.c | 2 +- docs/man/xrdp.ini.5 | 2 +- faq-general.txt | 8 ++++---- libxrdp/libxrdp.c | 6 +++--- libxrdp/xrdp_mcs.c | 2 +- libxrdp/xrdp_orders.c | 20 ++++++++++---------- libxrdp/xrdp_sec.c | 2 +- prog_std.txt | 7 ++++--- sesman/sessvc/sessvc.c | 2 +- tests/gtcp_proxy/gtcp.c | 4 ++-- xorg/X11R7.6/rdp/rdpinput.c | 2 +- xrdp/xrdp.c | 3 +-- xrdp/xrdp_types.h | 2 +- xrdp/xrdp_wm.c | 4 ++-- xrdp/xrdpwin.c | 4 ++-- 15 files changed, 35 insertions(+), 35 deletions(-) diff --git a/common/os_calls.c b/common/os_calls.c index dbef8da6..8ce5c25a 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -399,7 +399,7 @@ g_tcp_set_keepalive(int sck) /*****************************************************************************/ /* 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 g_tcp_socket(void) { diff --git a/docs/man/xrdp.ini.5 b/docs/man/xrdp.ini.5 index 8e6969cd..6f727971 100644 --- a/docs/man/xrdp.ini.5 +++ b/docs/man/xrdp.ini.5 @@ -158,7 +158,7 @@ This option sets the logging level for syslog. It can have the same values of \f .SH "CHANNELS" 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. -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 pre-requisite, but does not force its use. .br Channels can also be enabled or disabled on a per connection basis by prefixing each setting with \fBchannel.\fP in the channel section. diff --git a/faq-general.txt b/faq-general.txt index e63804cb..53dab380 100644 --- a/faq-general.txt +++ b/faq-general.txt @@ -2,17 +2,17 @@ General FAQ 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. Q. What is xrdp? -A. xrdp, usually spell lower case, is as open source implementation of the RDP - protocol. +A. xrdp, usually spelled in lower case, is as open source implementation of the + 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. diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c index 0b92668a..daa7ca75 100644 --- a/libxrdp/libxrdp.c +++ b/libxrdp/libxrdp.c @@ -485,12 +485,12 @@ libxrdp_send_bitmap(struct xrdp_session *session, int width, int height, 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) { - g_writeln("error, compressed size too big, its %d", bufsize); + g_writeln("error, compressed size too big: %d bytes", bufsize); } s->p = s->end; @@ -504,7 +504,7 @@ libxrdp_send_bitmap(struct xrdp_session *session, int width, int height, 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); } } diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c index 6f04e719..8ed821e9 100644 --- a/libxrdp/xrdp_mcs.c +++ b/libxrdp/xrdp_mcs.c @@ -1023,7 +1023,7 @@ xrdp_mcs_send(struct xrdp_mcs *self, struct stream *s, int chan) 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) diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index 697d2a5a..18a5ad38 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -236,7 +236,7 @@ xrdp_orders_check(struct xrdp_orders *self, int max_size) size = (int)(self->out_s->p - self->order_count_ptr); 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; } 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 correct max_size so we end up putting more into the buffer 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 max_packet_size 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 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 || 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 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 || 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 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 || 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 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 || 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 clip is present, still check if its needed */ + /* if clip is present, still check if it's needed */ if (MIN(endx, startx) < rect->left || MIN(endy, starty) < rect->top || MAX(endx, startx) >= rect->right || @@ -1460,7 +1460,7 @@ xrdp_orders_mem_blt(struct xrdp_orders *self, int cache_id, 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 || 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; 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 || dstx + width > rect->right || dsty + height > rect->bottom) { @@ -1999,7 +1999,7 @@ xrdp_orders_text(struct xrdp_orders *self, 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 && (box_left < rect->left || box_top < rect->top || diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c index af0cedf2..a31190ca 100644 --- a/libxrdp/xrdp_sec.c +++ b/libxrdp/xrdp_sec.c @@ -2101,7 +2101,7 @@ xrdp_sec_in_mcs_data(struct xrdp_sec *self) client_info = &(self->rdp_layer->client_info); s = &(self->client_mcs_data); - /* get hostname, its unicode */ + /* get hostname, it's unicode */ s->p = s->data; if (!s_check_rem(s, 47)) { diff --git a/prog_std.txt b/prog_std.txt index 671172f2..761006a5 100644 --- a/prog_std.txt +++ b/prog_std.txt @@ -1,7 +1,8 @@ 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 -for me to read. +Not to defend any of these but it's my default standard and it makes it easy +for me to read code. + Some files break these rules, they will be updated eventually. 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 -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) { p = p->next; diff --git a/sesman/sessvc/sessvc.c b/sesman/sessvc/sessvc.c index dce88d17..3fb80a60 100644 --- a/sesman/sessvc/sessvc.c +++ b/sesman/sessvc/sessvc.c @@ -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 chansrv_cleanup(int pid) { diff --git a/tests/gtcp_proxy/gtcp.c b/tests/gtcp_proxy/gtcp.c index 4b218a3c..504138bf 100644 --- a/tests/gtcp_proxy/gtcp.c +++ b/tests/gtcp_proxy/gtcp.c @@ -33,7 +33,7 @@ int tcp_socket_create(void) unsigned int option_len; #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) return -1; @@ -193,7 +193,7 @@ int tcp_socket(void) unsigned int option_len; #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) return -1; diff --git a/xorg/X11R7.6/rdp/rdpinput.c b/xorg/X11R7.6/rdp/rdpinput.c index f221ae34..4c976417 100644 --- a/xorg/X11R7.6/rdp/rdpinput.c +++ b/xorg/X11R7.6/rdp/rdpinput.c @@ -27,7 +27,7 @@ keyboard and mouse stuff num lock */ /* this should be fixed in rdesktop */ /* 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 */ /* tab notes */ diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index 88743cc6..740b0e1c 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -443,8 +443,7 @@ main(int argc, char **argv) if (fd == -1) { - g_writeln("problem opening to xrdp.pid [%s]", pid_file); - g_writeln("maybe its not running"); + g_writeln("cannot open %s, maybe xrdp is not running", pid_file); } else { diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index 4590d7a8..d6c7ccb1 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -216,7 +216,7 @@ struct xrdp_brush_item { int stamp; /* 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]; }; diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 3b223902..ca466197 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -1725,8 +1725,8 @@ callback(long id, int msg, long param1, long param2, long param3, long param4) rv = xrdp_wm_process_input_mousex(wm, param3, param1, param2); break; case 0x4444: /* invalidate, this is not from RDP_DATA_PDU_INPUT */ - /* like the rest, its from RDP_PDU_DATA with code 33 */ - /* its the rdp client asking for a screen update */ + /* like the rest, it's from RDP_PDU_DATA with code 33 */ + /* it's the rdp client asking for a screen update */ MAKERECT(rect, param1, param2, param3, param4); rv = xrdp_bitmap_invalidate(wm->screen, &rect); break; diff --git a/xrdp/xrdpwin.c b/xrdp/xrdpwin.c index 224efc0c..25ca6048 100644 --- a/xrdp/xrdpwin.c +++ b/xrdp/xrdpwin.c @@ -466,8 +466,8 @@ main(int argc, char **argv) if (fd == -1) { - g_writeln("problem opening to xrdp.pid"); - g_writeln("maybe its not running"); + g_writeln("cannot open %s, maybe xrdp is not running", + pid_file); } else { From 0d7f2d2802c5a8ac1a7062979c35b08703c9912a Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:15 -0700 Subject: [PATCH 02/32] Improve manual page for sesman Add new sections and parameters, improve wording, wrap lines. --- docs/man/sesman.ini.5 | 285 ++++++++++++++++++++++-------------------- 1 file changed, 152 insertions(+), 133 deletions(-) diff --git a/docs/man/sesman.ini.5 b/docs/man/sesman.ini.5 index a1ba3a50..0ae48caf 100644 --- a/docs/man/sesman.ini.5 +++ b/docs/man/sesman.ini.5 @@ -1,206 +1,225 @@ -.\" +.\" .TH "sesman.ini" "5" "0.1.0" "xrdp team" "" .SH "NAME" -\fBsesman.ini\fR \- Configuration file for \fBsesman\fR(8) +\fBsesman.ini\fR \- Configuration file for \fBxrdp-sesman\fR(8) .SH "DESCRIPTION" -This is the man page for \fBsesman.ini\fR, \fBsesman\fR(8) configuration file. -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\fR=\fI\fR lines. +\fBsesman.ini\fR consists of several sections. Each section starts with +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 -\fB[Globals]\fR \- sesman global configuration section, +.TP +\fB[Logging]\fR +Logging subsystem -.TP -\fB[Logging]\fR \- logging subsystem parameters +.TP +\fB[Sessions]\fR +Session management -.TP -\fB[Security]\fR \- Access control parameters +.TP +\fB[Security]\fR +Access control -.TP -\fB[Sessions]\fR \- Session management parameters +.TP +\fB[X11rdp]\fR, \fB[Xvnc]\fR, \fB[Xorg]\fR +X11 server settings for supported servers -.LP -All options and values (except for file names and paths) are case insensitive, and are described in detail below. +.TP +\fB[Chansrv]\fR +Settings for xrdp-chansrv(8) -.LP -For any of the following parameter, if it's specified more than one time the last entry encountered will be used. +.TP +\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" -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 -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 -Specifies sesman listening port. Default is 3350 +xrdp-sesman listening port. Default is 3350. -.TP +.TP \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 -\fBUserWindowManager\fR=\fIstartwm.sh\fR -This option specifies the script run by sesman when starting a session and per\-user window manager is enabled. -.br -The path is relative to user's HOME directory +.TP +\fBUserWindowManager\fR=\fIfilename\fR +Name of the startup script relative to the user's home directory. If +present and enabled by \fBEnableUserWindowManager\fR, that script is +executed instead of \fBDefaultWindowManager\fR. -.TP -\fBDefaultWindowManager\fR=\fI${SESMAN_BIN_DIR}/startwm.sh\fR -This contains full path to the default window manager startup script used by sesman to start a session +.TP +\fBDefaultWindowManager\fR=\fIfilename\fR +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" -The following parameters can be used in the \fB[logging]\fR section: +Following parameters can be used in the \fB[Logging]\fR section. -.TP -\fBLogFile\fR=\fI${SESMAN_LOG_DIR}/sesman.log\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 +.TP +\fBLogFile\fR=\fIfilename\fR +Log file path. It can be either absolute or relative. The default is +\fI./sesman.log\fR -.TP +.TP \fBLogLevel\fR=\fIlevel\fR 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 - -.TP -\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. - -.TP -\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. - -.SH "SESSIONS" -The following parameters can be used in the \fB[Sessions]\fR section: - -.TP -\fBX11DisplayOffset\fR=\fI\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. +\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 -\fBMaxSessions\fR=\fI\fR -Sets the maximum number of simultaneous session on terminal server. -.br -If unset or set to \fI0\fR, unlimited session are allowed. +\fBEnableSyslog\fR=\fI[0|1]\fR +If set to \fB1\fR, \fBtrue\fR or \fByes\fR, this option enables logging to +syslog. -.TP +.TP +\fBSyslogLevel\fR=\fIlevel\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" +Following parameters can be used in the \fB[Sessions]\fR section. + +.TP +\fBX11DisplayOffset\fR=\fInumber\fR +The first X display number available for xrdp-sesman. This prevents +xrdp-sesman from interfering with real X11 servers. The default is 10. + +.TP +\fBMaxSessions\fR=\fInumber\fR +Sets the maximum number of simultaneous sessions. If not set or set to +\fI0\fR, unlimited session are allowed. + +.TP \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. -.br +If set to \fB1\fR, \fBtrue\fR or \fByes\fR, every session will be killed +within 60 seconds after the user disconnects. -.TP -\fBIdleTimeLimit\fR=\fI\fR -Sets the the time limit before an idle session is disconnected. -.br -If set to \fI0\fR, automatic disconnection is disabled. -.br -\fI\-this option is currently ignored!\-\fR +.TP +\fBIdleTimeLimit\fR=\fInumber\fR +\fI\This option is currently ignored!\fR Time limit before an idle +session is disconnected. If set to \fI0\fR, automatic disconnection is +disabled. -.TP -\fBDisconnectedTimeLimit\fR=\fI\fR -Sets the time(in seconds) limit before a disconnected session is killed. -.br +.TP +\fBDisconnectedTimeLimit\fR=\fInumber\fR +Sets the time limit (in seconds) before a disconnected session is killed. If set to \fI0\fR, automatic killing is disabled. -.br -.TP +.TP \fBPolicy\fR=\fI[Default|UBD|UBI|UBC|UBDI|UBDC]\fR -Session allocation policy. By Default, a new session is created -for the combination when using Xrdp, and +Session allocation policy. By default, a new session is created +for the combination when using Xrdp, and for the combination 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 \fBUBD\fR - session per -.br +.br \fBUBI\fR - session per -.br +.br \fBUBC\fR - session per -.br +.br \fBUBDI\fR - session per -.br +.br \fBUBDC\fR - session per .br .br -Note that the criteria can not be turned off -and will always be checkt when for Xvnc connections. +Note that the \fBUser\fR and \fBBitPerPixel\fR criteria cannot be turned +off. For Xvnc connections, \fBDisplaySize\fR is always enabled as well. .br .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 -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 -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. +.TP +\fBMaxLoginRetry\fR=\fInumber\fR +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. -.TP -\fBTerminalServerUsers\fR=\fItsusers\fR -Only the users belonging to the group \fItsusers\fR are allowed to login on terminal server. -.br -If unset or set to an invalid or non\-existent group, login for all users is enabled. +.TP +\fBTerminalServerUsers\fR=\fIgroup\fR +Only the users belonging to the specified group are allowed to login on +terminal server. If unset or set to an invalid or non\-existent group, +login for all users is enabled. -.TP -\fBTerminalServerAdmins\fR=\fItsadmins\fR -Sets the group which a user shall belong to have session management rights. -.br -\fI\-this option is currently ignored!\-\fR +.TP +\fBTerminalServerAdmins\fR=\fIgroup\fR +\fIThis option is currently ignored!\fR Only members of this group can +have session management rights. -.SH "EXAMPLES" -This is an example \fBsesman.ini\fR: +.TP +\fBAlwaysGroupCheck\fR=\fI[0|1]\fR +If set to \fB1\fR, \fBtrue\fR or \fByes\fR, require group membership even +if the group specified in \fBTerminalServerUsers\fR doesn't exist. -.nf -[Globals] -ListenAddress=127.0.0.1 -ListenPort=3350 -EnableUserWindowManager=1 -UserWindowManager=startwm.sh -DefaultWindowManager=startwm.sh +.SH "X11 SERVER" +Following parameters can be used in the \fB[X11rdp]\fR, \fB[Xvnc]\fR and +\fB[Xorg]\fR sections. -[Logging] -LogFile=/usr/local/xrdp/sesman.log -LogLevel=DEBUG -EnableSyslog=0 -SyslogLevel=DEBUG +.TP +\fBparam0\fR=\fIfilename\fR +Path to the X11 server executable -[Sessions] -MaxSessions=10 -KillDisconnected=0 -IdleTimeLimit=0 -DisconnectedTimeLimit=0 +.TP +\fBparam\fR\fIN\fR=\fIstring\fR +Nth command line argument -[Security] -AllowRootLogin=1 -MaxLoginRetry=3 -TerminalServerUsers=tsusers -TerminalServerAdmins=tsadmins -.fi +.SH "CHANSRV" +Following parameters can be used in the \fB[Chansrv]\fR section. + +.TP +\fBFuseMountName\fR=\fIstring\fR +Directory for drive redirection, relative to the user home directory. +Created if it doesn't exist. Defaults to \fIxrdp_client\fR + +.SH "SESSIONS VARIABLES" +All entries it the \fB[SessionVariables]\fR section are set as +environment variables in the user's session. .SH "FILES" -${SESMAN_CFG_DIR}/sesman.ini +/etc/xrdp/sesman.ini .SH "SEE ALSO" -.BR sesman (8), -.BR sesrun (8), +.BR xrdp-sesman (8), +.BR xrdp-sesrun (8), .BR xrdp (8), .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 From 7aa35f1f57642be5ab8b632a15d440b5dd3b0c12 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:15 -0700 Subject: [PATCH 03/32] Fix typos in manual pages --- docs/man/xrdp-dis.1 | 2 +- docs/man/xrdp.ini.5 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/man/xrdp-dis.1 b/docs/man/xrdp-dis.1 index 089621ae..1f0490c0 100644 --- a/docs/man/xrdp-dis.1 +++ b/docs/man/xrdp-dis.1 @@ -7,7 +7,7 @@ xrdp\-dis \- xrdp disconnect utility .SH DESCRIPTION .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 .TP diff --git a/docs/man/xrdp.ini.5 b/docs/man/xrdp.ini.5 index 6f727971..e608b1fa 100644 --- a/docs/man/xrdp.ini.5 +++ b/docs/man/xrdp.ini.5 @@ -158,13 +158,13 @@ This option sets the logging level for syslog. It can have the same values of \f .SH "CHANNELS" 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. -Not all channels are supported in all cases, so setting a value to \fItrue\fP is a pre-requisite, but does not force its 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 Channels can also be enabled or disabled on a per connection basis by prefixing each setting with \fBchannel.\fP in the channel section. .TP \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 \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 \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 \fBrail\fP=\fI[0|1]\fP From a77ae440a782b5b11048e9aa35adfa7a60f1a4e4 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:15 -0700 Subject: [PATCH 04/32] Rename SESMAN_CFG_X11DISPLAYOFFSET to SESMAN_CFG_SESS_X11DISPLAYOFFSET Move it to other session options in config.h. X11DisplayOffset is part of the [Sessions] section. --- sesman/config.c | 2 +- sesman/config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sesman/config.c b/sesman/config.c index 5a904fc3..72a43117 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -347,7 +347,7 @@ config_read_sessions(int file, struct config_sessions *se, struct list *param_n, { 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)); } diff --git a/sesman/config.h b/sesman/config.h index d4e86105..14fc4f98 100644 --- a/sesman/config.h +++ b/sesman/config.h @@ -37,7 +37,6 @@ #define SESMAN_CFG_PORT "ListenPort" #define SESMAN_CFG_ENABLE_USERWM "EnableUserWindowManager" #define SESMAN_CFG_USERWM "UserWindowManager" -#define SESMAN_CFG_X11DISPLAYOFFSET "X11DisplayOffset" #define SESMAN_CFG_MAX_SESSION "MaxSessions" #define SESMAN_CFG_AUTH_FILE_PATH "AuthFilePath" @@ -66,6 +65,7 @@ #define SESMAN_CFG_SESS_KILL_DISC "KillDisconnected" #define SESMAN_CFG_SESS_IDLE_LIMIT "IdleTimeLimit" #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_DFLT_S "Default" From be1d034f91a998ecbcd6a4d06c88b6ca79aff901 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:15 -0700 Subject: [PATCH 05/32] Report pid and listening address/port for xrdp and xrdp-sesman For xrdp-sesman, don't report that the daemon is listening to a port if it fails to attach to that port. Don't use LOG_LEVEL_ALWAYS for startup message, it's not a critical error. --- sesman/sesman.c | 9 ++++----- xrdp/xrdp.c | 1 + xrdp/xrdp_listen.c | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sesman/sesman.c b/sesman/sesman.c index 64728376..828524fa 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -49,9 +49,6 @@ sesman_main_loop(void) tbus sck_obj; tbus robjs[8]; - /*main program loop*/ - log_message(LOG_LEVEL_INFO, "listening..."); - g_sck = g_tcp_socket(); if (g_sck < 0) { @@ -68,6 +65,8 @@ sesman_main_loop(void) 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); cont = 1; @@ -359,8 +358,8 @@ main(int argc, char **argv) } /* start program main loop */ - log_message(LOG_LEVEL_ALWAYS, - "starting sesman with pid %d", g_pid); + log_message(LOG_LEVEL_INFO, + "starting xrdp-sesman with pid %d", g_pid); /* make sure the /tmp/.X11-unix directory exist */ if (!g_directory_exist("/tmp/.X11-unix")) diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index 740b0e1c..b55a90cc 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -597,6 +597,7 @@ main(int argc, char **argv) g_sync_mutex = tc_mutex_create(); g_sync1_mutex = tc_mutex_create(); 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_term_event = g_create_wait_obj(text); diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c index b2b19ca2..4e9a58c6 100644 --- a/xrdp/xrdp_listen.c +++ b/xrdp/xrdp_listen.c @@ -370,6 +370,8 @@ xrdp_listen_main_loop(struct xrdp_listen *self) if (error == 0) { + log_message(LOG_LEVEL_INFO, "listening to port %s on %s", + port, address); if (tcp_nodelay) { if (g_tcp_set_no_delay(self->listen_trans->sck)) From b1527b7947b867a8dc6dd22bda9147713c10620b Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:16 -0700 Subject: [PATCH 06/32] Check string format in log_message Move "printflike" definition to arch.h, it's used both by log.h and os_calls.h. --- common/arch.h | 12 ++++++++++++ common/log.h | 2 +- common/os_calls.h | 11 ----------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/common/arch.h b/common/arch.h index d3ae460e..5c67cb66 100644 --- a/common/arch.h +++ b/common/arch.h @@ -19,6 +19,10 @@ #if !defined(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 in the makefile to override */ @@ -125,4 +129,12 @@ typedef signed long long tsi64; #endif #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 + #endif diff --git a/common/log.h b/common/log.h index 15307588..6654028b 100644 --- a/common/log.h +++ b/common/log.h @@ -171,7 +171,7 @@ log_end(void); * @return */ enum logReturns DEFAULT_CC -log_message(const enum logLevels lvl, const char *msg, ...); +log_message(const enum logLevels lvl, const char *msg, ...) printflike(2, 3); /** * diff --git a/common/os_calls.h b/common/os_calls.h index 2ed2cb81..0a58d4a8 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -21,10 +21,6 @@ #if !defined(OS_CALLS_H) #define OS_CALLS_H -#if defined(HAVE_CONFIG_H) -#include "config_ac.h" -#endif - #ifndef NULL #define NULL 0 #endif @@ -45,13 +41,6 @@ #define g_tcp_select g_sck_select #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_mk_temp_dir(const char* app_name); void APP_CC g_init(const char* app_name); From 77b380c0b5b6eb4f074a4a8735d109e226512508 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:16 -0700 Subject: [PATCH 07/32] Fix format warnings in log_message() calls --- common/os_calls.c | 10 ++++------ neutrinordp/xrdp-neutrinordp.c | 16 ++++++++-------- sesman/chansrv/chansrv.c | 3 +-- sesman/chansrv/clipboard.c | 3 ++- sesman/session.c | 2 +- vnc/vnc.c | 2 +- xrdp/xrdp_login_wnd.c | 9 +++------ xrdp/xrdp_mm.c | 14 +++++++------- xrdp/xrdp_wm.c | 2 +- 9 files changed, 28 insertions(+), 33 deletions(-) diff --git a/common/os_calls.c b/common/os_calls.c index 8ce5c25a..9a409591 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -668,7 +668,6 @@ int APP_CC g_tcp_connect(int sck, const char *address, const char *port) { int res = 0; - char errorMsg[256]; struct addrinfo p; struct addrinfo *h = (struct addrinfo *)NULL; struct addrinfo *rp = (struct addrinfo *)NULL; @@ -696,9 +695,8 @@ g_tcp_connect(int sck, const char *address, const char *port) } if (res != 0) { - snprintf(errorMsg, 255, "g_tcp_connect: getaddrinfo() failed: %s", - gai_strerror(res)); - log_message(LOG_LEVEL_ERROR, errorMsg); + log_message(LOG_LEVEL_ERROR, "g_tcp_connect: getaddrinfo() failed: %s", + gai_strerror(res)); } if (res > -1) { @@ -988,7 +986,7 @@ g_tcp_accept(int sck) { snprintf(ipAddr, 255, "A connection received from: %s port %d", inet_ntoa(s.sin_addr), ntohs(s.sin_port)); - log_message(LOG_LEVEL_INFO,ipAddr); + log_message(LOG_LEVEL_INFO, "%s", ipAddr); } return ret ; } @@ -1013,7 +1011,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", 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) { g_snprintf(addr, addr_bytes, "%s", inet_ntoa(s.sin_addr)); diff --git a/neutrinordp/xrdp-neutrinordp.c b/neutrinordp/xrdp-neutrinordp.c index 121bbe0c..b463f8a8 100644 --- a/neutrinordp/xrdp-neutrinordp.c +++ b/neutrinordp/xrdp-neutrinordp.c @@ -230,7 +230,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2, break; 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. Therefore we store this information and use it when we receive the first keyboard event @@ -246,7 +246,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2, break; case 100: /* mouse move */ - LLOGLN(12, ("mouse move %d %d", param1, param2)); + LLOGLN(12, ("mouse move %ld %ld", param1, param2)); x = param1; y = param2; flags = PTR_FLAGS_MOVE; @@ -254,7 +254,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2, break; 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; y = param2; flags = PTR_FLAGS_BUTTON1; @@ -262,7 +262,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2, break; 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; y = param2; flags = PTR_FLAGS_BUTTON1 | PTR_FLAGS_DOWN; @@ -270,7 +270,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2, break; 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; y = param2; flags = PTR_FLAGS_BUTTON2; @@ -278,7 +278,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2, break; 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; y = param2; flags = PTR_FLAGS_BUTTON2 | PTR_FLAGS_DOWN; @@ -286,7 +286,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2, break; 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; y = param2; flags = PTR_FLAGS_BUTTON3; @@ -294,7 +294,7 @@ lxrdp_event(struct mod *mod, int msg, long param1, long param2, break; 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; y = param2; flags = PTR_FLAGS_BUTTON3 | PTR_FLAGS_DOWN; diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index e3d2f5d2..95224e9c 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -734,8 +734,7 @@ process_message(void) rv = process_message_channel_data_response(s); break; default: - LOGM((LOG_LEVEL_ERROR, "process_message: error in process_message ", - "unknown msg %d", id)); + LOGM((LOG_LEVEL_ERROR, "process_message: unknown msg %d", id)); break; } diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index 5f01f241..cf98b5f2 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -1920,7 +1920,8 @@ clipboard_event_selection_notify(XEvent *xevent) for (index = 0; index < n_items; 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)); log_debug("clipboard_event_selection_notify: 0x%lx %s", atom, get_atom_text(atom)); diff --git a/sesman/session.c b/sesman/session.c index 02bb6fa7..28e00fc9 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -963,7 +963,7 @@ session_get_bypid(int pid) if (0 == dummy) { - log_message(LOG_LEVEL_ERROR, "internal error", pid); + log_message(LOG_LEVEL_ERROR, "session_get_bypid: out of memory"); return 0; } diff --git a/vnc/vnc.c b/vnc/vnc.c index 091978e0..604fd571 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -233,7 +233,7 @@ lib_process_channel_data(struct vnc *v, int chanid, int flags, int size, } 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); } diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c index c9fca912..76fc59b0 100644 --- a/xrdp/xrdp_login_wnd.c +++ b/xrdp/xrdp_login_wnd.c @@ -273,7 +273,6 @@ xrdp_wm_parse_domain_information(char *originalDomainInfo, int comboMax, int pos; int comboxindex; char index[2]; - char debugstr[256]; /* If the first char in the domain name is '_' we use the domain name as IP*/ @@ -300,11 +299,9 @@ xrdp_wm_parse_domain_information(char *originalDomainInfo, int comboMax, /* we just accept values 0-9 (one figure) */ g_strncpy(index, &originalDomainInfo[pos + 3], 1); comboxindex = g_htoi(index); - g_snprintf(debugstr, 255, "Value of index (as char): %s " - "(converted) : %d (max) : %d", index, comboxindex, - comboMax - 1); - debugstr[255] = 0; - log_message(LOG_LEVEL_DEBUG, debugstr); + log_message(LOG_LEVEL_DEBUG, + "index value as string: %s, as int: %d, max: %d", + index, comboxindex, comboMax - 1); /* limit to max number of items in combo box */ if ((comboxindex > 0) && (comboxindex < comboMax)) { diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 94be7e4f..28923405 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -375,7 +375,7 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self) g_snprintf(text, 255, "error finding proc mod_init in %s, not a valid " "xrdp backend", lib); xrdp_wm_log_msg(self->wm, text); - log_message(LOG_LEVEL_ERROR,text); + log_message(LOG_LEVEL_ERROR, "%s", text); } self->mod_init = (struct xrdp_mod * ( *)(void))func; @@ -391,7 +391,7 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self) g_snprintf(text, 255, "error finding proc mod_exit in %s, not a valid " "xrdp backend", lib); xrdp_wm_log_msg(self->wm, text); - log_message(LOG_LEVEL_ERROR,text); + log_message(LOG_LEVEL_ERROR, "%s", text); } self->mod_exit = (int ( *)(struct xrdp_mod *))func; @@ -416,7 +416,7 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self) g_snprintf(text, 255, "error loading %s specified in xrdp.ini, please " "add a valid entry like lib=libxrdp-vnc.so or similar", lib); xrdp_wm_log_msg(self->wm, text); - log_message(LOG_LEVEL_ERROR,text); + log_message(LOG_LEVEL_ERROR, "%s", text); return 1; } @@ -1489,7 +1489,7 @@ access_control(char *username, char *password, char *srv) else { log_message(LOG_LEVEL_ERROR, "Corrupt reply size or " - "version from sesman: %d", size); + "version from sesman: %ld", size); } } else @@ -1909,7 +1909,7 @@ xrdp_mm_connect(struct xrdp_mm *self) getPAMError(reply, pam_error, 127)); xrdp_wm_log_msg(self->wm, replytxt); - log_message(LOG_LEVEL_INFO, replytxt); + log_message(LOG_LEVEL_INFO, "%s", replytxt); additionalError = getPAMAdditionalErrorInfo(reply, self); if (additionalError) { @@ -1970,7 +1970,7 @@ xrdp_mm_connect(struct xrdp_mm *self) g_snprintf(errstr, 255, "Failure to connect to sesman: %s port: %s", ip, port); xrdp_wm_log_msg(self->wm, errstr); - log_message(LOG_LEVEL_ERROR,errstr); + log_message(LOG_LEVEL_ERROR, "%s", errstr); trans_delete(self->sesman_trans); self->sesman_trans = 0; self->sesman_trans_up = 0; @@ -1990,7 +1990,7 @@ xrdp_mm_connect(struct xrdp_mm *self) { /* connect error */ g_snprintf(errstr, 255, "Failure to connect to: %s", ip); - log_message(LOG_LEVEL_ERROR,errstr); + log_message(LOG_LEVEL_ERROR, "%s", errstr); xrdp_wm_log_msg(self->wm, errstr); rv = 1; /* failure */ } diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index ca466197..7b9165e7 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -45,7 +45,7 @@ xrdp_wm_create(struct xrdp_process *owner, pid = g_getpid(); g_snprintf(event_name, 255, "xrdp_%8.8x_wm_login_mode_event_%8.8x", 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->painter = xrdp_painter_create(self, self->session); self->cache = xrdp_cache_create(self, self->session, self->client_info); From 27ba5b4e86aebe9088234344f4d3546b60998c0d Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 8 Jul 2016 04:06:34 +0000 Subject: [PATCH 08/32] Rewrite add_string_to_logwindow() Make static, fix formatting, shorten some variable names, use += to add to variable, accept immutable strings. --- xrdp/xrdp_wm.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 7b9165e7..b5b2ff15 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -1857,22 +1857,21 @@ xrdp_wm_log_wnd_notify(struct xrdp_bitmap *wnd, return 0; } -void add_string_to_logwindow(char *msg, struct list *log) +static void +add_string_to_logwindow(const char *msg, struct list *log) { - - char *new_part_message; - char *current_pointer = msg ; - int processedlen = 0; + const char *new_part_message; + const char *current_pointer = msg; + int len_done = 0; do { - new_part_message = g_strndup(current_pointer, LOG_WINDOW_CHAR_PER_LINE) ; - g_writeln("%s",new_part_message); - list_add_item(log, (long)new_part_message); - processedlen = processedlen + g_strlen(new_part_message); - current_pointer = current_pointer + g_strlen(new_part_message) ; - } - while ((processedlen < g_strlen(msg)) && (processedlen < DEFAULT_STRING_LEN)); + new_part_message = g_strndup(current_pointer, LOG_WINDOW_CHAR_PER_LINE); + g_writeln("%s", new_part_message); + list_add_item(log, (tintptr) new_part_message); + len_done += g_strlen(new_part_message); + current_pointer += g_strlen(new_part_message); + } while ((len_done < g_strlen(msg)) && (len_done < DEFAULT_STRING_LEN)); } /*****************************************************************************/ From a1b7de56798463cca6702bc6fd2b1d599bfc234a Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:16 -0700 Subject: [PATCH 09/32] Make xrdp_wm_log_msg() log its output Accept variable arguments and the log level in xrdp_wm_log_msg(). Remove logging that is done automatically now. --- xrdp/xrdp.h | 4 +- xrdp/xrdp_mm.c | 105 ++++++++++++++++++++++--------------------------- xrdp/xrdp_wm.c | 18 +++++++-- 3 files changed, 64 insertions(+), 63 deletions(-) diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index e9bf69ef..1c7e9cad 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -37,6 +37,7 @@ #include "file.h" #include "file_loc.h" #include "xrdp_client_info.h" +#include "log.h" /* xrdp.c */ long APP_CC @@ -140,7 +141,8 @@ xrdp_wm_delete_all_children(struct xrdp_wm* self); int APP_CC xrdp_wm_show_log(struct xrdp_wm *self); 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 xrdp_wm_get_wait_objs(struct xrdp_wm* self, tbus* robjs, int* rc, tbus* wobjs, int* wc, int* timeout); diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 28923405..15f466b6 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -176,8 +176,8 @@ xrdp_mm_send_login(struct xrdp_mm *self) char *name; char *value; - xrdp_wm_log_msg(self->wm, "sending login info to session manager, " - "please wait..."); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG, + "sending login info to session manager, please wait..."); username = 0; password = 0; self->code = 0; @@ -210,7 +210,8 @@ xrdp_mm_send_login(struct xrdp_mm *self) 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; } @@ -277,7 +278,8 @@ xrdp_mm_send_login(struct xrdp_mm *self) 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; @@ -339,18 +341,18 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self) if (xrdp_mm_get_value(self, "lib", lib, 255) != 0) { - g_snprintf(text, 255, "no library name specified in xrdp.ini, please add " - "lib=libxrdp-vnc.so or similar"); - xrdp_wm_log_msg(self->wm, text); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR, + "no library name specified in xrdp.ini, please add " + "lib=libxrdp-vnc.so or similar"); return 1; } if (lib[0] == 0) { - g_snprintf(text, 255, "empty library name specified in xrdp.ini, please " - "add lib=libxrdp-vnc.so or similar"); - xrdp_wm_log_msg(self->wm, text); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR, + "empty library name specified in xrdp.ini, please " + "add lib=libxrdp-vnc.so or similar"); return 1; } @@ -372,10 +374,9 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self) if (func == 0) { - g_snprintf(text, 255, "error finding proc mod_init in %s, not a valid " - "xrdp backend", lib); - xrdp_wm_log_msg(self->wm, text); - log_message(LOG_LEVEL_ERROR, "%s", text); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR, + "error finding proc mod_init in %s, " + "not a valid xrdp backend", lib); } self->mod_init = (struct xrdp_mod * ( *)(void))func; @@ -388,10 +389,9 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self) if (func == 0) { - g_snprintf(text, 255, "error finding proc mod_exit in %s, not a valid " - "xrdp backend", lib); - xrdp_wm_log_msg(self->wm, text); - log_message(LOG_LEVEL_ERROR, "%s", text); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR, + "error finding proc mod_exit in %s, " + "not a valid xrdp backend", lib); } self->mod_exit = (int ( *)(struct xrdp_mod *))func; @@ -413,10 +413,10 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self) } else { - g_snprintf(text, 255, "error loading %s specified in xrdp.ini, please " - "add a valid entry like lib=libxrdp-vnc.so or similar", lib); - xrdp_wm_log_msg(self->wm, text); - log_message(LOG_LEVEL_ERROR, "%s", text); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR, + "error loading %s specified in xrdp.ini, please " + "add a valid entry like lib=libxrdp-vnc.so or " + "similar", lib); return 1; } @@ -1192,7 +1192,6 @@ xrdp_mm_process_login_response(struct xrdp_mm *self, struct stream *s) int ok; int display; int rv; - char text[256]; char ip[256]; char port[256]; @@ -1203,9 +1202,9 @@ xrdp_mm_process_login_response(struct xrdp_mm *self, struct stream *s) if (ok) { self->display = display; - g_snprintf(text, 255, "xrdp_mm_process_login_response: login successful " - "for display %d", display); - xrdp_wm_log_msg(self->wm, text); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, + "xrdp_mm_process_login_response: login successful " + "for display %d", display); if (xrdp_mm_setup_mod1(self) == 0) { @@ -1231,10 +1230,8 @@ xrdp_mm_process_login_response(struct xrdp_mm *self, struct stream *s) } else { - xrdp_wm_log_msg(self->wm, "xrdp_mm_process_login_response: " - "login failed"); - log_message(LOG_LEVEL_INFO,"xrdp_mm_process_login_response: " - "login failed"); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, + "xrdp_mm_process_login_response: login failed"); xrdp_wm_show_log(self->wm); 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); break; default: - xrdp_wm_log_msg(self->wm, "An undefined reply code was received from sesman"); - log_message(LOG_LEVEL_ERROR,"Fatal xrdp_mm_sesman_data_in: unknown cmd code %d", code); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR, + "Undefined reply code %d received from sesman", + code); cleanup_sesman_connection(self); break; } @@ -1801,8 +1799,6 @@ xrdp_mm_connect(struct xrdp_mm *self) char *name; char *value; char ip[256]; - char errstr[256]; - char text[256]; char port[8]; char chansrvport[256]; #ifdef ACCESS @@ -1820,8 +1816,6 @@ xrdp_mm_connect(struct xrdp_mm *self) /* make sure we start in correct state */ cleanup_states(self); 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(chansrvport, 0, sizeof(chansrvport)); rv = 0; /* success */ @@ -1884,10 +1878,10 @@ xrdp_mm_connect(struct xrdp_mm *self) if (use_pam_auth) { int reply; - char replytxt[128]; char pam_error[128]; 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"); */ 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 */ reply = access_control(pam_auth_username, pam_auth_password, pam_auth_sessionIP); - g_sprintf(replytxt, "Reply from access control: %s", - getPAMError(reply, pam_error, 127)); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, + "Reply from access control: %s", + getPAMError(reply, pam_error, 127)); - xrdp_wm_log_msg(self->wm, replytxt); - log_message(LOG_LEVEL_INFO, "%s", replytxt); additionalError = getPAMAdditionalErrorInfo(reply, self); - if (additionalError) + if (additionalError && additionalError[0]) { - g_snprintf(replytxt, 127, "%s", additionalError); - if (replytxt[0]) - { - xrdp_wm_log_msg(self->wm, replytxt); - } + xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "%s", additionalError); } 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->is_term = g_is_term; 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, text); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG, + "connecting to sesman ip %s port %s", ip, port); /* 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->header_size = 8; @@ -1961,16 +1950,15 @@ xrdp_mm_connect(struct xrdp_mm *self) if (ok) { /* 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; rv = xrdp_mm_send_login(self); } else { - g_snprintf(errstr, 255, "Failure to connect to sesman: %s port: %s", - ip, port); - xrdp_wm_log_msg(self->wm, errstr); - log_message(LOG_LEVEL_ERROR, "%s", errstr); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR, + "Error connecting to sesman: %s port: %s", + ip, port); trans_delete(self->sesman_trans); self->sesman_trans = 0; self->sesman_trans_up = 0; @@ -1989,9 +1977,8 @@ xrdp_mm_connect(struct xrdp_mm *self) else { /* connect error */ - g_snprintf(errstr, 255, "Failure to connect to: %s", ip); - log_message(LOG_LEVEL_ERROR, "%s", errstr); - xrdp_wm_log_msg(self->wm, errstr); + xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR, + "Error connecting to: %s", ip); rv = 1; /* failure */ } } @@ -2664,7 +2651,7 @@ server_msg(struct xrdp_mod *mod, char *msg, int code) } wm = (struct xrdp_wm *)(mod->wm); - return xrdp_wm_log_msg(wm, msg); + return xrdp_wm_log_msg(wm, LOG_LEVEL_DEBUG, "%s", msg); } /*****************************************************************************/ diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index b5b2ff15..4613816f 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -18,6 +18,8 @@ * simple window manager */ +#include +#include #include "xrdp.h" #include "log.h" @@ -678,8 +680,9 @@ xrdp_wm_init(struct xrdp_wm *self) { /* 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, "ERROR: The requested xrdp module not found in xrdp.ini," - " falling back to login window"); + xrdp_wm_log_msg(self, LOG_LEVEL_ERROR, + "ERROR: The requested xrdp module not found in " + "xrdp.ini, falling back to login window"); } list_delete(names); @@ -1965,8 +1968,17 @@ xrdp_wm_show_log(struct xrdp_wm *self) /*****************************************************************************/ 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); return 0; } From 6f5feb61e0e0683249d2db64bb8c04583a968583 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:16 -0700 Subject: [PATCH 10/32] Shorten and clarify log window messages Specify display in the "login failed" message. Print the section name that wasn't found. Remove stdout message about missing section, xrdp_wm_log_msg() already writes to stdout. --- xrdp/xrdp_mm.c | 5 ++--- xrdp/xrdp_wm.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 15f466b6..7e6c6cd7 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -1203,8 +1203,7 @@ xrdp_mm_process_login_response(struct xrdp_mm *self, struct stream *s) { self->display = display; xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, - "xrdp_mm_process_login_response: login successful " - "for display %d", display); + "login successful for display %d", display); if (xrdp_mm_setup_mod1(self) == 0) { @@ -1231,7 +1230,7 @@ xrdp_mm_process_login_response(struct xrdp_mm *self, struct stream *s) else { xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, - "xrdp_mm_process_login_response: login failed"); + "login failed for display %d", display); xrdp_wm_show_log(self->wm); if (self->wm->hide_log_window) { diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 4613816f..5fec41a4 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -679,10 +679,9 @@ xrdp_wm_init(struct xrdp_wm *self) else { /* 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, - "ERROR: The requested xrdp module not found in " - "xrdp.ini, falling back to login window"); + "Section \"%s\" not configured in xrdp.ini", + section_name); } list_delete(names); From f7ef9bb938ae9f227bc329cc46291461f7f9ba0a Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:16 -0700 Subject: [PATCH 11/32] Fix scp_init() invocation, it takes no arguments --- sesman/tools/sesadmin.c | 2 +- sesman/tools/sestest.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c index 3415b75b..3ee230a5 100644 --- a/sesman/tools/sesadmin.c +++ b/sesman/tools/sesadmin.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) } } - scp_init(&logging); + scp_init(); sock = g_tcp_socket(); if (sock < 0) diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c index e1c09cf2..0653355c 100644 --- a/sesman/tools/sestest.c +++ b/sesman/tools/sestest.c @@ -48,7 +48,7 @@ int main(int argc, char **argv) log.program_name = g_strdup("sestest"); log.log_file = g_strdup("sestest.log"); log_start_from_param(&log); - scp_init(&log); + scp_init(); sock = g_tcp_socket(); if (sock < 0) From f908528a004812c36a27a6705f8d2453cc9084c4 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:16 -0700 Subject: [PATCH 12/32] Downgrade "libscp initialized" to LOG_LEVEL_DEBUG, remove line number It's a bad style to start the log with a cryptic warning. --- sesman/libscp/libscp_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sesman/libscp/libscp_init.c b/sesman/libscp/libscp_init.c index eae57c6e..9d1e7308 100644 --- a/sesman/libscp/libscp_init.c +++ b/sesman/libscp/libscp_init.c @@ -43,7 +43,7 @@ scp_init() scp_lock_init(); - log_message(LOG_LEVEL_WARNING, "[init:%d] libscp initialized", __LINE__); + log_message(LOG_LEVEL_DEBUG, "libscp initialized"); return 0; } From 1ded8ec43726e9b65048be2c9f4fb044dbc0ec9d Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:17 -0700 Subject: [PATCH 13/32] Remove unused string support in scp_session_set_addr() Using the same argument for binary and text data is not a good idea. If string support is ever needed, it should be a separate function. Remove SCP_ADDRESS_TYPE_IPV4_BIN and SCP_ADDRESS_TYPE_IPV6_BIN, use SCP_ADDRESS_TYPE_IPV4 and SCP_ADDRESS_TYPE_IPV6, which simplifies the code. --- sesman/libscp/libscp_session.c | 36 +--------------------------------- sesman/libscp/libscp_session.h | 2 +- sesman/libscp/libscp_types.h | 4 ---- sesman/libscp/libscp_v1s.c | 4 ++-- sesman/libscp/libscp_v1s_mng.c | 4 ++-- 5 files changed, 6 insertions(+), 44 deletions(-) diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c index a1859aa5..91f93b54 100644 --- a/sesman/libscp/libscp_session.c +++ b/sesman/libscp/libscp_session.c @@ -396,49 +396,15 @@ scp_session_set_display(struct SCP_SESSION *s, SCP_DISPLAY display) /*******************************************************************/ 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) { 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); break; #ifdef IN6ADDR_ANY_INIT 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); break; #endif diff --git a/sesman/libscp/libscp_session.h b/sesman/libscp/libscp_session.h index b545af9e..4a9e9d70 100644 --- a/sesman/libscp/libscp_session.h +++ b/sesman/libscp/libscp_session.h @@ -83,7 +83,7 @@ int scp_session_set_hostname(struct SCP_SESSION* s, char* str); 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 scp_session_set_display(struct SCP_SESSION* s, SCP_DISPLAY display); diff --git a/sesman/libscp/libscp_types.h b/sesman/libscp/libscp_types.h index de851867..78d53e56 100644 --- a/sesman/libscp/libscp_types.h +++ b/sesman/libscp/libscp_types.h @@ -51,10 +51,6 @@ #define SCP_ADDRESS_TYPE_IPV4 0x00 #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_MANAGE 0x0001 #define SCP_COMMAND_SET_RSR 0x0002 diff --git a/sesman/libscp/libscp_v1s.c b/sesman/libscp/libscp_v1s.c index b7d422c7..6cdf0b00 100644 --- a/sesman/libscp/libscp_v1s.c +++ b/sesman/libscp/libscp_v1s.c @@ -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) { 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) { 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'; diff --git a/sesman/libscp/libscp_v1s_mng.c b/sesman/libscp/libscp_v1s_mng.c index 24553429..e48fc86b 100644 --- a/sesman/libscp/libscp_v1s_mng.c +++ b/sesman/libscp/libscp_v1s_mng.c @@ -90,12 +90,12 @@ scp_v1s_mng_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s) if (sz == SCP_ADDRESS_TYPE_IPV4) { 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) { 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 */ From b00ca6e03d856398624b9f2b2cc19f2ab867aa66 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 8 Jul 2016 04:26:59 +0000 Subject: [PATCH 14/32] Remove commented out config_read_logging(), the code is long dead --- sesman/config.c | 55 ------------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/sesman/config.c b/sesman/config.c index 72a43117..c1160693 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -182,61 +182,6 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n, return 0; } -/****************************************************************************** -int DEFAULT_CC -config_read_logging(int file, struct log_config* lc, struct list* param_n, - struct list* param_v) -{ - 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 config_read_security(int file, struct config_security *sc, From 951e6327576988251a9a479494e20d605efaad71 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:17 -0700 Subject: [PATCH 15/32] Make program_name constant, don't duplicate or free it --- common/log.c | 10 ++-------- common/log.h | 2 +- sesman/tools/sesadmin.c | 2 +- sesman/tools/sestest.c | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/common/log.c b/common/log.c index 54f625d7..1338287a 100644 --- a/common/log.c +++ b/common/log.c @@ -212,12 +212,6 @@ internal_log_end(struct log_config *l_cfg) l_cfg->log_file = 0; } - if (0 != l_cfg->program_name) - { - g_free(l_cfg->program_name); - l_cfg->program_name = 0; - } - ret = LOG_STARTUP_OK; return ret; } @@ -336,7 +330,7 @@ internal_config_read_logging(int file, struct log_config *lc, list_clear(param_n); /* setting defaults */ - lc->program_name = g_strdup(applicationName); + lc->program_name = applicationName; lc->log_file = 0; lc->fd = 0; lc->log_level = LOG_LEVEL_DEBUG; @@ -455,7 +449,7 @@ log_start_from_param(const struct log_config *iniParams) g_staticLogConfig->log_level = iniParams->log_level; g_staticLogConfig->log_lock = iniParams->log_lock; g_staticLogConfig->log_lock_attr = iniParams->log_lock_attr; - g_staticLogConfig->program_name = g_strdup(iniParams->program_name); + g_staticLogConfig->program_name = iniParams->program_name; g_staticLogConfig->syslog_level = iniParams->syslog_level; ret = internal_log_start(g_staticLogConfig); diff --git a/common/log.h b/common/log.h index 6654028b..b90ac660 100644 --- a/common/log.h +++ b/common/log.h @@ -65,7 +65,7 @@ enum logReturns struct log_config { - char *program_name; + const char *program_name; char *log_file; int fd; unsigned int log_level; diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c index 3ee230a5..98f727e6 100644 --- a/sesman/tools/sesadmin.c +++ b/sesman/tools/sesadmin.c @@ -59,7 +59,7 @@ int main(int argc, char **argv) serv[0] = '\0'; port[0] = '\0'; - logging.program_name = g_strdup("sesadmin"); + logging.program_name = "sesadmin"; logging.log_file = g_strdup("xrdp-sesadmin.log"); logging.log_level = LOG_LEVEL_DEBUG; logging.enable_syslog = 0; diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c index 0653355c..17795dfc 100644 --- a/sesman/tools/sestest.c +++ b/sesman/tools/sestest.c @@ -45,7 +45,7 @@ int main(int argc, char **argv) log.enable_syslog = 0; log.log_level = 99; - log.program_name = g_strdup("sestest"); + log.program_name = "sestest"; log.log_file = g_strdup("sestest.log"); log_start_from_param(&log); scp_init(); From a680d46edf747ec17456b6b8e69c95bc4e4407cb Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:17 -0700 Subject: [PATCH 16/32] Use -Wwrite-strings compiler flag if supported, add required macros String literals are const in C++. Using this warnings moves us closer to the stated goal of C++ compatibility, makes the code cleaner and lets compilers optimize the code better. Add m4/ax_append_compile_flags.m4 from Autoconf Archives for the AX_APPEND_COMPILE_FLAGS macro and m4/ax_check_compile_flag.m4 as its dependency. --- configure.ac | 1 + m4/ax_append_compile_flags.m4 | 67 +++++++++++++++++++++++++++++++ m4/ax_check_compile_flag.m4 | 74 +++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 m4/ax_append_compile_flags.m4 create mode 100644 m4/ax_check_compile_flag.m4 diff --git a/configure.ac b/configure.ac index 50eff683..63a82d57 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,7 @@ PKG_PROG_PKG_CONFIG m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AX_CFLAGS_WARN_ALL +AX_APPEND_COMPILE_FLAGS([-Wwrite-strings]) AX_GCC_FUNC_ATTRIBUTE([format]) case $host_os in diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4 new file mode 100644 index 00000000..2bb27ef2 --- /dev/null +++ b/m4/ax_append_compile_flags.m4 @@ -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 +# +# 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 . +# +# 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 diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 00000000..ca363971 --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -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 +# Copyright (c) 2011 Maarten Bosmans +# +# 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 . +# +# 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 From aeeb3d2c2e26677758a64db496c86020f99d2f1a Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:17 -0700 Subject: [PATCH 17/32] Fix warnings detected by -Wwrite-strings --- common/os_calls.c | 10 +++++----- common/os_calls.h | 6 +++--- common/ssl_calls.c | 4 ++-- common/ssl_calls.h | 2 +- genkeymap/genkeymap.c | 5 ++++- keygen/keygen.c | 2 +- libxrdp/libxrdp.c | 2 +- libxrdp/libxrdpinc.h | 2 +- mc/mc.c | 2 +- mc/mc.h | 4 ++-- neutrinordp/xrdp-neutrinordp.c | 2 +- neutrinordp/xrdp-neutrinordp.h | 4 ++-- rdp/rdp.c | 2 +- rdp/rdp.h | 4 ++-- sesman/chansrv/clipboard.c | 2 +- sesman/chansrv/clipboard_common.h | 3 ++- sesman/libscp/libscp_session.c | 18 +++++++++--------- sesman/libscp/libscp_session.h | 18 +++++++++--------- sesman/libscp/libscp_v1s.c | 7 ++++--- sesman/libscp/libscp_v1s.h | 7 ++++--- sesman/libscp/libscp_v1s_mng.c | 2 +- sesman/libscp/libscp_v1s_mng.h | 2 +- sesman/scp_v1.c | 4 ++-- sesman/scp_v1_mng.c | 4 ++-- vnc/vnc.c | 2 +- vnc/vnc.h | 6 +++--- xrdp/xrdp.h | 6 +++--- xrdp/xrdp_mm.c | 7 ++++--- xrdp/xrdp_painter.c | 4 ++-- xrdp/xrdp_types.h | 4 ++-- xrdp/xrdp_wm.c | 2 +- xup/xup.c | 2 +- xup/xup.h | 6 +++--- 33 files changed, 82 insertions(+), 75 deletions(-) diff --git a/common/os_calls.c b/common/os_calls.c index 9a409591..7d932a10 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -1810,7 +1810,7 @@ g_file_read(int fd, char *ptr, int len) /*****************************************************************************/ /* write to file, returns the number of bytes written or -1 on error */ 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) @@ -1947,7 +1947,7 @@ g_get_current_dir(char *dirname, int maxlen) /*****************************************************************************/ /* returns error, zero on success and -1 on failure */ int APP_CC -g_set_current_dir(char *dirname) +g_set_current_dir(const char *dirname) { #if defined(_WIN32) @@ -2116,7 +2116,7 @@ g_strlen(const char *text) /*****************************************************************************/ /* locates char in text */ -char* APP_CC +const char *APP_CC g_strchr(const char* text, int c) { if (text == NULL) @@ -2395,7 +2395,7 @@ g_htoi(char *str) int APP_CC g_pos(const char *str, const char *to_find) { - char *pp; + const char *pp; pp = strstr(str, to_find); @@ -3263,7 +3263,7 @@ g_save_to_bmp(const char* filename, char* data, int stride_bytes, data -= stride_bytes; if ((depth == 24) && (bits_per_pixel == 32)) { - line = malloc(file_stride_bytes); + line = (char *) malloc(file_stride_bytes); memset(line, 0, file_stride_bytes); for (index = 0; index < height; index++) { diff --git a/common/os_calls.h b/common/os_calls.h index 0a58d4a8..6a7cd093 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -104,14 +104,14 @@ int APP_CC g_file_open_ex(const char *file_name, int aread, int awrite, int acreate, int atrunc); 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_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_lock(int fd, int start, int len); 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_mkdir(const char* dirname); 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_directory_exist(const char* dirname); int APP_CC g_create_dir(const char* dirname); @@ -120,7 +120,7 @@ int APP_CC g_remove_dir(const char* dirname); int APP_CC g_file_delete(const char* filename); int APP_CC g_file_get_size(const char* filename); 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_strncpy(char* dest, const char* src, int len); char* APP_CC g_strcat(char* dest, const char* src); diff --git a/common/ssl_calls.c b/common/ssl_calls.c index b7eb6131..3d9e1c2e 100644 --- a/common/ssl_calls.c +++ b/common/ssl_calls.c @@ -111,7 +111,7 @@ ssl_sha1_clear(void *sha1_info) /*****************************************************************************/ 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); } @@ -560,7 +560,7 @@ ssl_tls_create(struct trans *trans, const char *key, const char *cert) /*****************************************************************************/ 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)) { diff --git a/common/ssl_calls.h b/common/ssl_calls.h index 6cfe73a3..c470e63a 100644 --- a/common/ssl_calls.h +++ b/common/ssl_calls.h @@ -41,7 +41,7 @@ ssl_sha1_info_delete(void* sha1_info); void APP_CC ssl_sha1_clear(void* sha1_info); 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 ssl_sha1_complete(void* sha1_info, char* data); void* APP_CC diff --git a/genkeymap/genkeymap.c b/genkeymap/genkeymap.c index a92d45f9..d0907f32 100644 --- a/genkeymap/genkeymap.c +++ b/genkeymap/genkeymap.c @@ -48,7 +48,10 @@ int main(int argc, char **argv) char text[256]; char *displayname = NULL; 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 i; int idx; diff --git a/keygen/keygen.c b/keygen/keygen.c index bafcaf1c..12970100 100644 --- a/keygen/keygen.c +++ b/keygen/keygen.c @@ -282,7 +282,7 @@ sign_key(char *e_data, int e_len, char *n_data, int n_len, /*****************************************************************************/ 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 error; diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c index daa7ca75..c3763bf5 100644 --- a/libxrdp/libxrdp.c +++ b/libxrdp/libxrdp.c @@ -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 exist */ 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 count = 0; diff --git a/libxrdp/libxrdpinc.h b/libxrdp/libxrdpinc.h index b23fd340..275b674a 100644 --- a/libxrdp/libxrdpinc.h +++ b/libxrdp/libxrdpinc.h @@ -189,7 +189,7 @@ int DEFAULT_CC libxrdp_query_channel(struct xrdp_session *session, int index, char *channel_name, int *channel_flags); 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 libxrdp_send_to_channel(struct xrdp_session *session, int channel_id, char *data, int data_len, diff --git a/mc/mc.c b/mc/mc.c index c1ec958c..3bcf16f1 100644 --- a/mc/mc.c +++ b/mc/mc.c @@ -75,7 +75,7 @@ lib_mod_end(struct mod *mod) /******************************************************************************/ /* return error */ 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; } diff --git a/mc/mc.h b/mc/mc.h index a28ade47..65297942 100644 --- a/mc/mc.h +++ b/mc/mc.h @@ -37,7 +37,7 @@ struct mod long param3, long param4); int (*mod_signal)(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_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount, tbus* write_objs, int* wcount, int* timeout); @@ -80,7 +80,7 @@ struct mod int (*server_query_channel)(struct mod* v, int index, char* channel_name, 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, char* data, int data_len, int total_data_len, int flags); diff --git a/neutrinordp/xrdp-neutrinordp.c b/neutrinordp/xrdp-neutrinordp.c index b463f8a8..8290b049 100644 --- a/neutrinordp/xrdp-neutrinordp.c +++ b/neutrinordp/xrdp-neutrinordp.c @@ -428,7 +428,7 @@ lxrdp_end(struct mod *mod) /******************************************************************************/ /* return error */ 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; diff --git a/neutrinordp/xrdp-neutrinordp.h b/neutrinordp/xrdp-neutrinordp.h index 4e0f5d10..79bb460d 100644 --- a/neutrinordp/xrdp-neutrinordp.h +++ b/neutrinordp/xrdp-neutrinordp.h @@ -71,7 +71,7 @@ struct mod long param3, long param4); int (*mod_signal)(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_get_wait_objs)(struct mod *v, tbus *read_objs, int *rcount, tbus *write_objs, int *wcount, int *timeout); @@ -114,7 +114,7 @@ struct mod int (*server_query_channel)(struct mod *v, int index, char *channel_name, 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, char *data, int data_len, int total_data_len, int flags); diff --git a/rdp/rdp.c b/rdp/rdp.c index abbbab73..ffced90b 100644 --- a/rdp/rdp.c +++ b/rdp/rdp.c @@ -242,7 +242,7 @@ lib_mod_end(struct mod *mod) /******************************************************************************/ /* return error */ 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) { diff --git a/rdp/rdp.h b/rdp/rdp.h index da8c1321..ff04fafa 100644 --- a/rdp/rdp.h +++ b/rdp/rdp.h @@ -262,7 +262,7 @@ struct mod long param3, long param4); int (*mod_signal)(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_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount, tbus* write_objs, int* wcount, int* timeout); @@ -305,7 +305,7 @@ struct mod int (*server_query_channel)(struct mod* v, int index, char* channel_name, 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, char* data, int data_len, int total_data_len, int flags); diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index cf98b5f2..7a9795d6 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -582,7 +582,7 @@ clipboard_send_format_ack(void) /*****************************************************************************/ /* returns number of bytes written */ 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 lnum_chars; diff --git a/sesman/chansrv/clipboard_common.h b/sesman/chansrv/clipboard_common.h index 5a74de66..1944b760 100644 --- a/sesman/chansrv/clipboard_common.h +++ b/sesman/chansrv/clipboard_common.h @@ -127,7 +127,8 @@ struct clip_file_desc /* CLIPRDR_FILEDESCRIPTOR */ 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); #endif diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c index 91f93b54..e6c77058 100644 --- a/sesman/libscp/libscp_session.c +++ b/sesman/libscp/libscp_session.c @@ -164,7 +164,7 @@ scp_session_set_rsr(struct SCP_SESSION *s, tui8 rsr) /*******************************************************************/ 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) { @@ -180,7 +180,7 @@ scp_session_set_locale(struct SCP_SESSION *s, char *str) /*******************************************************************/ 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) { @@ -206,7 +206,7 @@ scp_session_set_username(struct SCP_SESSION *s, char *str) /*******************************************************************/ 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) { @@ -232,7 +232,7 @@ scp_session_set_password(struct SCP_SESSION *s, char *str) /*******************************************************************/ 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) { @@ -258,7 +258,7 @@ scp_session_set_domain(struct SCP_SESSION *s, char *str) /*******************************************************************/ 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) { @@ -284,7 +284,7 @@ scp_session_set_program(struct SCP_SESSION *s, char *str) /*******************************************************************/ 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) { @@ -310,7 +310,7 @@ scp_session_set_directory(struct SCP_SESSION *s, char *str) /*******************************************************************/ 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) { @@ -336,7 +336,7 @@ scp_session_set_client_ip(struct SCP_SESSION *s, char *str) /*******************************************************************/ 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) { @@ -362,7 +362,7 @@ scp_session_set_hostname(struct SCP_SESSION *s, char *str) /*******************************************************************/ 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) { diff --git a/sesman/libscp/libscp_session.h b/sesman/libscp/libscp_session.h index 4a9e9d70..51b6d03e 100644 --- a/sesman/libscp/libscp_session.h +++ b/sesman/libscp/libscp_session.h @@ -59,28 +59,28 @@ int scp_session_set_rsr(struct SCP_SESSION* s, tui8 rsr); int -scp_session_set_locale(struct SCP_SESSION* s, char* str); +scp_session_set_locale(struct SCP_SESSION* s, const char *str); int -scp_session_set_username(struct SCP_SESSION* s, char* str); +scp_session_set_username(struct SCP_SESSION* s, const char *str); int -scp_session_set_password(struct SCP_SESSION* s, char* str); +scp_session_set_password(struct SCP_SESSION* s, const char *str); int -scp_session_set_domain(struct SCP_SESSION* s, char* str); +scp_session_set_domain(struct SCP_SESSION* s, const char *str); int -scp_session_set_program(struct SCP_SESSION* s, char* str); +scp_session_set_program(struct SCP_SESSION* s, const char *str); int -scp_session_set_directory(struct SCP_SESSION* s, char* str); +scp_session_set_directory(struct SCP_SESSION* s, const char *str); 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 -scp_session_set_hostname(struct SCP_SESSION* s, char* str); +scp_session_set_hostname(struct SCP_SESSION* s, const char *str); int scp_session_set_addr(struct SCP_SESSION* s, int type, const void* addr); @@ -89,7 +89,7 @@ int scp_session_set_display(struct SCP_SESSION* s, SCP_DISPLAY display); int -scp_session_set_errstr(struct SCP_SESSION* s, char* str); +scp_session_set_errstr(struct SCP_SESSION* s, const char *str); /** * diff --git a/sesman/libscp/libscp_v1s.c b/sesman/libscp/libscp_v1s.c index 6cdf0b00..284c9b52 100644 --- a/sesman/libscp/libscp_v1s.c +++ b/sesman/libscp/libscp_v1s.c @@ -202,7 +202,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION *c, struct SCP_SES } 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; @@ -235,7 +235,8 @@ scp_v1s_deny_connection(struct SCP_CONNECTION *c, char *reason) } 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; tui32 version; @@ -392,7 +393,7 @@ scp_v1s_connect_new_session(struct SCP_CONNECTION *c, SCP_DISPLAY d) /* 032 */ 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; diff --git a/sesman/libscp/libscp_v1s.h b/sesman/libscp/libscp_v1s.h index cc29d70d..69e64038 100644 --- a/sesman/libscp/libscp_v1s.h +++ b/sesman/libscp/libscp_v1s.h @@ -53,10 +53,11 @@ scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk); */ /* 002 */ 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 -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 */ enum SCP_SERVER_STATES_E @@ -72,7 +73,7 @@ scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d); /* 032 */ 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 */ enum SCP_SERVER_STATES_E diff --git a/sesman/libscp/libscp_v1s_mng.c b/sesman/libscp/libscp_v1s_mng.c index e48fc86b..d8c5290d 100644 --- a/sesman/libscp/libscp_v1s_mng.c +++ b/sesman/libscp/libscp_v1s_mng.c @@ -138,7 +138,7 @@ scp_v1s_mng_allow_connection(struct SCP_CONNECTION *c, struct SCP_SESSION *s) /* 003 */ 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; diff --git a/sesman/libscp/libscp_v1s_mng.h b/sesman/libscp/libscp_v1s_mng.h index 867931a5..437a06d2 100644 --- a/sesman/libscp/libscp_v1s_mng.h +++ b/sesman/libscp/libscp_v1s_mng.h @@ -61,7 +61,7 @@ scp_v1s_mng_allow_connection(struct SCP_CONNECTION* c, struct SCP_SESSION* s); */ /* 003 */ 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); /** * diff --git a/sesman/scp_v1.c b/sesman/scp_v1.c index 92e1dad5..1501606d 100644 --- a/sesman/scp_v1.c +++ b/sesman/scp_v1.c @@ -31,7 +31,7 @@ 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 @@ -209,7 +209,7 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) 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) { diff --git a/sesman/scp_v1_mng.c b/sesman/scp_v1_mng.c index 2624644a..29496466 100644 --- a/sesman/scp_v1_mng.c +++ b/sesman/scp_v1_mng.c @@ -30,7 +30,7 @@ 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 @@ -109,7 +109,7 @@ scp_v1_mng_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) 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) { diff --git a/vnc/vnc.c b/vnc/vnc.c index 604fd571..a72c8dd1 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -1396,7 +1396,7 @@ lib_mod_end(struct vnc *v) /******************************************************************************/ 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) { diff --git a/vnc/vnc.h b/vnc/vnc.h index 6d1ddb8f..34f408ca 100644 --- a/vnc/vnc.h +++ b/vnc/vnc.h @@ -37,7 +37,7 @@ struct vnc long param3, long param4); int (*mod_signal)(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_get_wait_objs)(struct vnc* v, tbus* read_objs, int* rcount, tbus* write_objs, int* wcount, int* timeout); @@ -54,7 +54,7 @@ struct vnc 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_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_set_clip)(struct vnc* v, int x, int y, int cx, int cy); int (*server_reset_clip)(struct vnc* v); @@ -80,7 +80,7 @@ struct vnc int (*server_query_channel)(struct vnc* v, int index, char* channel_name, 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, char* data, int data_len, int total_data_len, int flags); diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 1c7e9cad..15013942 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -266,9 +266,9 @@ xrdp_painter_draw_bitmap(struct xrdp_painter* self, struct xrdp_bitmap* to_draw, int x, int y, int cx, int cy); 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 -xrdp_painter_text_height(struct xrdp_painter* self, char* text); +xrdp_painter_text_height(struct xrdp_painter* self, const char *text); int APP_CC xrdp_painter_draw_text(struct xrdp_painter* self, struct xrdp_bitmap* bitmap, @@ -466,7 +466,7 @@ int DEFAULT_CC server_query_channel(struct xrdp_mod* mod, int index, char* channel_name, int* channel_flags); 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 server_send_to_channel(struct xrdp_mod* mod, int channel_id, char* data, int data_len, diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 7e6c6cd7..dfc04152 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -291,7 +291,8 @@ xrdp_mm_send_login(struct xrdp_mm *self) then it copies the corresponding login_values item into 'dest' 'dest' must be at least 'dest_len' + 1 bytes in size */ 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 *value; @@ -1111,7 +1112,7 @@ xrdp_mm_chan_send_init(struct xrdp_mm *self) /*****************************************************************************/ /* connect to chansrv */ 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; @@ -3145,7 +3146,7 @@ server_query_channel(struct xrdp_mod *mod, int index, char *channel_name, /*****************************************************************************/ /* returns -1 on error */ 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; diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c index 4b36b1ea..f5605717 100644 --- a/xrdp/xrdp_painter.c +++ b/xrdp/xrdp_painter.c @@ -262,7 +262,7 @@ xrdp_painter_rop(int rop, int src, int dst) /*****************************************************************************/ 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 rv; @@ -299,7 +299,7 @@ xrdp_painter_text_width(struct xrdp_painter *self, char *text) /*****************************************************************************/ 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 rv; diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index d6c7ccb1..e462a881 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -42,7 +42,7 @@ struct xrdp_mod long param3, long param4); int (*mod_signal)(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_get_wait_objs)(struct xrdp_mod* v, tbus* read_objs, int* rcount, tbus* write_objs, int* wcount, int* timeout); @@ -88,7 +88,7 @@ struct xrdp_mod int (*server_query_channel)(struct xrdp_mod* v, int index, char* channel_name, 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, char* data, int data_len, int total_data_len, int flags); diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 5fec41a4..3bb326f3 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -548,7 +548,7 @@ xrdp_wm_init(struct xrdp_wm *self) struct list *names; struct list *values; char *q; - char *r; + const char *r; char param[256]; char section_name[256]; char cfg_file[256]; diff --git a/xup/xup.c b/xup/xup.c index b4a5df1e..ef424b40 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -1479,7 +1479,7 @@ lib_mod_end(struct mod *mod) /******************************************************************************/ /* return error */ 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) { diff --git a/xup/xup.h b/xup/xup.h index 85aff9fe..8c91996d 100644 --- a/xup/xup.h +++ b/xup/xup.h @@ -39,7 +39,7 @@ struct mod tbus param3, tbus param4); int (*mod_signal)(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_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount, tbus* write_objs, int* wcount, int* timeout); @@ -58,7 +58,7 @@ struct mod int srcx, int srcy); 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_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_set_clip)(struct mod* v, int x, int y, int cx, int cy); int (*server_reset_clip)(struct mod* v); @@ -84,7 +84,7 @@ struct mod int (*server_query_channel)(struct mod* v, int index, char* channel_name, 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, char* data, int data_len, int total_data_len, int flags); From aaa89ad4e6b5484b246ec9ecb7d93248e1fa74cd Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:17 -0700 Subject: [PATCH 18/32] Use const unsigned for hex arrays Some constants are too big for the signed type. --- rdp/rdp_rdp.c | 10 +++++----- sesman/chansrv/chansrv.c | 2 +- sesman/chansrv/rail.c | 4 ++-- xrdp/xrdp_bitmap.c | 2 +- xrdpapi/xrdpapi.c | 6 ++++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/rdp/rdp_rdp.c b/rdp/rdp_rdp.c index d5c8e27f..cede7b02 100644 --- a/rdp/rdp_rdp.c +++ b/rdp/rdp_rdp.c @@ -312,7 +312,7 @@ rdp_rdp_out_colcache_caps(struct rdp_rdp *self, struct stream *s) return 0; } -static char caps_0x0d[] = +static const unsigned char caps_0x0d[] = { 0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -327,11 +327,11 @@ static char caps_0x0d[] = 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, 0x08, 0x00, 0xFE, 0x00, 0x08, 0x00, @@ -345,7 +345,7 @@ static char caps_0x10[] = /* Output unknown capability sets */ static int APP_CC 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, length); diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index 95224e9c..c1f41499 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -55,7 +55,7 @@ static tbus g_thread_done_event = 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 }; int g_display_num = 0; diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index cad16471..8a23973a 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -1148,8 +1148,8 @@ rail_data_in(struct stream *s, int chan_id, int chan_flags, int length, return 0; } -static int g_crc_seed = 0xffffffff; -static int g_crc_table[256] = +static const unsigned int g_crc_seed = 0xffffffff; +static const unsigned int g_crc_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c index 6a062d51..e99e2bfe 100644 --- a/xrdp/xrdp_bitmap.c +++ b/xrdp/xrdp_bitmap.c @@ -38,7 +38,7 @@ while (0) -static const int g_crc_table[256] = +static const unsigned int g_crc_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, diff --git a/xrdpapi/xrdpapi.c b/xrdpapi/xrdpapi.c index baa1187a..ac303534 100644 --- a/xrdpapi/xrdpapi.c +++ b/xrdpapi/xrdpapi.c @@ -53,8 +53,10 @@ static int send_init(struct wts_obj *wts); static int can_send(int sck, int millis); static int can_recv(int sck, int millis); -static char g_xrdpapi_magic[12] = -{ 0x78, 0x32, 0x10, 0x67, 0x00, 0x92, 0x30, 0x56, 0xff, 0xd8, 0xa9, 0x1f }; +static const unsigned char g_xrdpapi_magic[12] = +{ + 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 From 4b05bb2ebd365415accc6dfb9a856b71a3a345f6 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:17 -0700 Subject: [PATCH 19/32] Mark g_drdynvc_chan_id as extern in g_drdynvc_chan_id, it's in chansrv.c --- sesman/chansrv/drdynvc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sesman/chansrv/drdynvc.c b/sesman/chansrv/drdynvc.c index 5b9224ca..dfd8a878 100644 --- a/sesman/chansrv/drdynvc.c +++ b/sesman/chansrv/drdynvc.c @@ -18,7 +18,7 @@ #include "drdynvc.h" -int g_drdynvc_chan_id; +extern int g_drdynvc_chan_id; /* in chansrv.c */ int g_drdynvc_inited = 0; static int APP_CC drdynvc_send_capability_request(uint16_t version); From bde4925f0eb01c319086d1d1cc156e7090c0a2d9 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:18 -0700 Subject: [PATCH 20/32] Cast appdata_ptr explicitly, needed for C++ compatibility --- sesman/verify_user_pam.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sesman/verify_user_pam.c b/sesman/verify_user_pam.c index a2b3f93a..29f21225 100644 --- a/sesman/verify_user_pam.c +++ b/sesman/verify_user_pam.c @@ -61,12 +61,12 @@ verify_pam_conv(int num_msg, const struct pam_message **msg, switch (msg[i]->msg_style) { 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_retcode = PAM_SUCCESS; break; 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_retcode = PAM_SUCCESS; break; From 6ab8c5ac6e444e507d0875c3409c576044750b01 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:18 -0700 Subject: [PATCH 21/32] Don't include X11/Xlib.h for XPoint, define a replacement XRDP modules are not X11 clients and should not generally need X11 headers. There is no need to match the X11 structure. --- neutrinordp/xrdp-neutrinordp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/neutrinordp/xrdp-neutrinordp.c b/neutrinordp/xrdp-neutrinordp.c index 8290b049..9fb3b20d 100644 --- a/neutrinordp/xrdp-neutrinordp.c +++ b/neutrinordp/xrdp-neutrinordp.c @@ -22,7 +22,6 @@ #include "xrdp_rail.h" #include "log.h" #include -#include #ifdef XRDP_DEBUG #define LOG_LEVEL 99 @@ -1368,7 +1367,9 @@ lfreerdp_polygon_sc(rdpContext *context, POLYGON_SC_ORDER *polygon_sc) { struct mod *mod; int i, npoints; - XPoint points[4]; + struct { + short x, y; + } points[4]; int fgcolor; int server_bpp, client_bpp; From a24df49241adc7c49dff777742d668f1d6c690ad Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:18 -0700 Subject: [PATCH 22/32] Introduce glib style macros for allocating memory with type --- common/os_calls.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/os_calls.h b/common/os_calls.h index 6a7cd093..a843b2e7 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -25,6 +25,7 @@ #define NULL 0 #endif +#include #include "arch.h" #define g_tcp_can_recv g_sck_can_recv @@ -183,4 +184,10 @@ int APP_CC g_shmdt(const void *shmaddr); int APP_CC g_gethostname(char *name, 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 From 5829323ad88f8120730968cfe165e590a7fb2d59 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:18 -0700 Subject: [PATCH 23/32] Use g_new or g_new0 when C++ compiler would complain about implicit cast --- common/log.c | 2 +- common/ssl_calls.c | 2 +- sesman/chansrv/chansrv.c | 2 +- sesman/chansrv/devredir.c | 8 +++++--- sesman/chansrv/irp.c | 3 ++- sesman/chansrv/rail.c | 2 +- sesman/chansrv/smartcard.c | 3 ++- sesman/chansrv/smartcard_pcsc.c | 4 ++-- sesman/libscp/libscp_connection.c | 2 +- sesman/libscp/libscp_v1c.c | 8 ++++---- sesman/libscp/libscp_v1c_mng.c | 2 +- sesman/sesman.c | 2 +- sesman/session.c | 4 ++-- sesman/sig.c | 2 +- sesman/verify_user_pam.c | 4 ++-- xrdp/xrdp_mm.c | 4 ++-- xrdp/xrdp_wm.c | 2 +- xup/xup.c | 2 +- 18 files changed, 31 insertions(+), 27 deletions(-) diff --git a/common/log.c b/common/log.c index 1338287a..77bcc6d6 100644 --- a/common/log.c +++ b/common/log.c @@ -395,7 +395,7 @@ enum logReturns DEFAULT_CC internalInitAndAllocStruct(void) { 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) { diff --git a/common/ssl_calls.c b/common/ssl_calls.c index 3d9e1c2e..e3d3e67e 100644 --- a/common/ssl_calls.c +++ b/common/ssl_calls.c @@ -187,7 +187,7 @@ ssl_des3_decrypt_info_create(const char *key, const char* ivec) const tui8 *lkey; 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); lkey = (const tui8 *) key; livec = (const tui8 *) ivec; diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index c1f41499..a521581d 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -97,7 +97,7 @@ add_timeout(int msoffset, void (*callback)(void *data), void *data) LOG(10, ("add_timeout:")); now = g_time3(); - tobj = g_malloc(sizeof(struct timeout_obj), 1); + tobj = g_new0(struct timeout_obj, 1); tobj->mstime = now + msoffset; tobj->callback = callback; tobj->data = data; diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index c29c7e43..bb10a6c9 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -962,7 +962,8 @@ dev_redir_proc_query_dir_response(IRP *irp, //log_debug("FileNameLength: %d", FileNameLength); 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"); fuse_data = devredir_fuse_data_peek(irp); @@ -1378,7 +1379,8 @@ devredir_fuse_data_enqueue(IRP *irp, void *vp) if (irp == NULL) return -1; - if ((fd = calloc(1, sizeof(FUSE_DATA))) == NULL) + fd = g_new0(FUSE_DATA, 1); + if (fd == NULL) return -1; 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)); src = unicode; - dest = g_malloc(bytes_to_alloc, 1); + dest = g_new0(char, bytes_to_alloc); dest_saved = dest; for (i = 0; i < len; i += 2) diff --git a/sesman/chansrv/irp.c b/sesman/chansrv/irp.c index 2a5209d8..ad318cb1 100644 --- a/sesman/chansrv/irp.c +++ b/sesman/chansrv/irp.c @@ -77,7 +77,8 @@ IRP * devredir_irp_new() log_debug("entered"); /* 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!"); return NULL; diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index 8a23973a..36e39889 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -238,7 +238,7 @@ rail_get_window_data_safe(Window window) { 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); g_free(rv); return rail_get_window_data(window); diff --git a/sesman/chansrv/smartcard.c b/sesman/chansrv/smartcard.c index 38d80c8b..1e692909 100644 --- a/sesman/chansrv/smartcard.c +++ b/sesman/chansrv/smartcard.c @@ -900,7 +900,8 @@ scard_add_new_device(tui32 device_id) return -1; } - if ((sc = g_malloc(sizeof(SMARTCARD), 1)) == NULL) + sc = g_new0(SMARTCARD, 1); + if (sc == NULL) { log_error("system out of memory"); return -1; diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index bf3d11bb..16938bf9 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -97,7 +97,7 @@ create_uds_client(struct trans *con) { 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) { return 0; @@ -606,7 +606,7 @@ scard_process_list_readers(struct trans *con, struct stream *in_s) g_free(groups); 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->cchReaders = cchReaders; scard_send_list_readers(pcscListReaders, lcontext->context, diff --git a/sesman/libscp/libscp_connection.c b/sesman/libscp/libscp_connection.c index 6366d51a..a04c4388 100644 --- a/sesman/libscp/libscp_connection.c +++ b/sesman/libscp/libscp_connection.c @@ -33,7 +33,7 @@ scp_connection_create(int sck) { struct SCP_CONNECTION *conn; - conn = g_malloc(sizeof(struct SCP_CONNECTION), 0); + conn = g_new(struct SCP_CONNECTION, 1); if (0 == conn) { diff --git a/sesman/libscp/libscp_v1c.c b/sesman/libscp/libscp_v1c.c index 7d1b9db8..7bc9a1d3 100644 --- a/sesman/libscp/libscp_v1c.c +++ b/sesman/libscp/libscp_v1c.c @@ -224,7 +224,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION *c, int *scount, in_uint32_be(c->in_s, sescnt); sestmp = sescnt; - ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0); + ds = g_new(struct SCP_DISCONNECTED_SESSION, sescnt); if (ds == 0) { @@ -429,7 +429,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s) g_free(s->errstr); } - s->errstr = g_malloc(dim + 1, 0); + s->errstr = g_new(char, dim + 1); if (s->errstr == 0) { @@ -450,7 +450,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s) g_free(s->errstr); } - s->errstr = g_malloc(dim + 1, 0); + s->errstr = g_new(char, dim + 1); if (s->errstr == 0) { @@ -471,7 +471,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s) g_free(s->errstr); } - s->errstr = g_malloc(dim + 1, 0); + s->errstr = g_new(char, dim + 1); if (s->errstr == 0) { diff --git a/sesman/libscp/libscp_v1c_mng.c b/sesman/libscp/libscp_v1c_mng.c index 59762e36..d9b43b98 100644 --- a/sesman/libscp/libscp_v1c_mng.c +++ b/sesman/libscp/libscp_v1c_mng.c @@ -199,7 +199,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION *c, int *scount, 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) { diff --git a/sesman/sesman.c b/sesman/sesman.c index 828524fa..c9666943 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -247,7 +247,7 @@ main(int argc, char **argv) } /* reading config */ - g_cfg = g_malloc(sizeof(struct config_sesman), 1); + g_cfg = g_new0(struct config_sesman, 1); if (0 == g_cfg) { diff --git a/sesman/session.c b/sesman/session.c index 28e00fc9..79128e5e 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -959,7 +959,7 @@ session_get_bypid(int pid) struct session_chain *tmp; struct session_item *dummy; - dummy = g_malloc(sizeof(struct session_item), 1); + dummy = g_new0(struct session_item, 1); if (0 == dummy) { @@ -1033,7 +1033,7 @@ session_get_byuser(char *user, int *cnt, unsigned char flags) } /* malloc() an array of disconnected sessions */ - sess = g_malloc(count *sizeof(struct SCP_DISCONNECTED_SESSION), 1); + sess = g_new0(struct SCP_DISCONNECTED_SESSION, count); if (sess == 0) { diff --git a/sesman/sig.c b/sesman/sig.c index b10be5fb..3cc3395a 100644 --- a/sesman/sig.c +++ b/sesman/sig.c @@ -75,7 +75,7 @@ sig_sesman_reload_cfg(int sig) return; } - cfg = g_malloc(sizeof(struct config_sesman), 1); + cfg = g_new0(struct config_sesman, 1); if (0 == cfg) { diff --git a/sesman/verify_user_pam.c b/sesman/verify_user_pam.c index 29f21225..43783211 100644 --- a/sesman/verify_user_pam.c +++ b/sesman/verify_user_pam.c @@ -54,7 +54,7 @@ verify_pam_conv(int num_msg, const struct pam_message **msg, struct pam_response *reply; 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++) { @@ -109,7 +109,7 @@ auth_userpass(char *user, char *pass, int *errorcode) char service_name[256]; 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.pass, pass, 255); auth_info->pamc.conv = &verify_pam_conv; diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index dfc04152..f1a01efa 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -764,7 +764,7 @@ xrdp_mm_process_rail_create_window(struct xrdp_mm* self, struct stream* s) in_uint16_le(s, title_bytes); 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); rwso.title_info[title_bytes] = 0; } @@ -947,7 +947,7 @@ xrdp_mm_process_rail_update_window_text(struct xrdp_mm* self, struct stream* s) g_memset(&rwso, 0, sizeof(rwso)); 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); rwso.title_info[size] = 0; g_writeln(" set window title %s size %d 0x%8.8x", rwso.title_info, size, flags); diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 3bb326f3..548742ac 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -62,7 +62,7 @@ xrdp_wm_create(struct xrdp_process *owner, self->current_surface_index = 0xffff; /* screen */ /* 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; } diff --git a/xup/xup.c b/xup/xup.c index ef424b40..ada25c42 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -697,7 +697,7 @@ process_server_window_new_update(struct mod *mod, struct stream *s) 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); rwso.title_info[title_bytes] = 0; } From d1efb0d5baa661367b0fe74130457cb932a66e3b Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:19 -0700 Subject: [PATCH 24/32] Fix signed to unsigned comparisons reported by g++ 6.1.0 --- common/os_calls.c | 2 +- rdp/rdp_rdp.c | 6 +++--- sesman/chansrv/chansrv.c | 6 ++++-- sesman/chansrv/chansrv_fuse.c | 2 +- sesman/chansrv/devredir.c | 6 +++--- sesman/chansrv/rail.c | 4 ++-- sesman/chansrv/smartcard.c | 2 +- sesman/chansrv/smartcard_pcsc.c | 4 ++-- vnc/vnc.c | 2 +- 9 files changed, 18 insertions(+), 16 deletions(-) diff --git a/common/os_calls.c b/common/os_calls.c index 7d932a10..6ad7a78d 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -2213,7 +2213,7 @@ g_strdup(const char *in) char *APP_CC g_strndup(const char *in, const unsigned int maxlen) { - int len; + unsigned int len; char *p; if (in == 0) diff --git a/rdp/rdp_rdp.c b/rdp/rdp_rdp.c index cede7b02..1e7952c5 100644 --- a/rdp/rdp_rdp.c +++ b/rdp/rdp_rdp.c @@ -415,9 +415,9 @@ rdp_rdp_send_confirm_active(struct rdp_rdp *self, struct stream *s) static int APP_CC rdp_rdp_process_color_pointer_pdu(struct rdp_rdp *self, struct stream *s) { - int cache_idx; - int dlen; - int mlen; + unsigned int cache_idx; + unsigned int dlen; + unsigned int mlen; struct rdp_cursor *cursor; in_uint16_le(s, cache_idx); diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index a521581d..0596b5ff 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -1628,7 +1628,8 @@ struct_from_dvc_chan_id(tui32 dvc_chan_id) 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]; } @@ -1644,7 +1645,8 @@ remove_struct_with_chan_id(tui32 dvc_chan_id) 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; return 0; diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index 0bb9ceff..143b7d6c 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -295,7 +295,7 @@ int devredir_file_read(void *fusep, tui32 device_id, tui32 FileId, tui32 Length, tui64 Offset); 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); diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index bb10a6c9..3014e53a 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -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) { - int i; + unsigned int i; int j; tui32 device_count; tui32 device_type; @@ -899,7 +899,7 @@ dev_redir_proc_query_dir_response(IRP *irp, tui32 status; char filename[256]; - int i = 0; + unsigned int i = 0; xstream_rd_u32_le(s_in, Length); @@ -1256,7 +1256,7 @@ devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId, int APP_CC 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; IRP *irp; diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index 36e39889..3470cece 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -184,7 +184,7 @@ rail_send_key_esc(int window_id) static struct rail_window_data* APP_CC rail_get_window_data(Window window) { - int bytes; + unsigned int bytes; Atom actual_type_return; int actual_format_return; unsigned long nitems_return; @@ -557,7 +557,7 @@ my_timeout(void* data) static int APP_CC rail_process_activate(struct stream *s, int size) { - int window_id; + unsigned int window_id; int enabled; int index; XWindowAttributes window_attributes; diff --git a/sesman/chansrv/smartcard.c b/sesman/chansrv/smartcard.c index 1e692909..41fe66a4 100644 --- a/sesman/chansrv/smartcard.c +++ b/sesman/chansrv/smartcard.c @@ -1256,7 +1256,7 @@ scard_send_GetStatusChange(IRP* irp, char *context, int context_bytes, struct stream *s; tui32 ioctl; int bytes; - int i; + unsigned int i; int num_chars; int index; twchar w_reader_name[100]; diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index 16938bf9..29bd5a23 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -145,7 +145,7 @@ get_uds_client_by_id(int uds_client_id) /*****************************************************************************/ struct pcsc_context * get_pcsc_context_by_app_context(struct pcsc_uds_client *uds_client, - int app_context) + tui32 app_context) { struct pcsc_context *rv; int index; @@ -173,7 +173,7 @@ get_pcsc_context_by_app_context(struct pcsc_uds_client *uds_client, /*****************************************************************************/ struct pcsc_card * 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_context *lcontext; diff --git a/vnc/vnc.c b/vnc/vnc.c index a72c8dd1..99245b53 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -587,7 +587,7 @@ lib_framebuffer_update(struct vnc *v) int cy; int srcx; int srcy; - int encoding; + unsigned int encoding; int Bpp; int pixel; int r; From c5ca0332be2e552950d7b45e51faf53f6a012345 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 8 Jul 2016 00:40:33 +0000 Subject: [PATCH 25/32] Use cast when applying boolean OR to enum --- sesman/session.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sesman/session.c b/sesman/session.c index 79128e5e..64079a8f 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -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 */ 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; case SCP_SESSION_TYPE_XRDP: /* 1 */ type = SESMAN_SESSION_TYPE_XRDP; /* 1 */ From 7cd9a5c4afce79ee10119bc5545c693290671bcb Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 8 Jul 2016 00:41:28 +0000 Subject: [PATCH 26/32] Cast fifo_remove_item() to XRDP_ENC_DATA* or XRDP_ENC_DATA_DONE* as needed --- xrdp/xrdp_encoder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xrdp/xrdp_encoder.c b/xrdp/xrdp_encoder.c index 18aa6a15..ff6db7b7 100644 --- a/xrdp/xrdp_encoder.c +++ b/xrdp/xrdp_encoder.c @@ -167,7 +167,7 @@ xrdp_encoder_delete(struct xrdp_encoder *self) { while (!fifo_is_empty(fifo)) { - enc = fifo_remove_item(fifo); + enc = (XRDP_ENC_DATA *) fifo_remove_item(fifo); if (enc == 0) { continue; @@ -185,7 +185,7 @@ xrdp_encoder_delete(struct xrdp_encoder *self) { 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) { continue; From 2cb3af8ac305c3387ce6f83e85c3bc76fbc4b979 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 8 Jul 2016 00:58:48 +0000 Subject: [PATCH 27/32] Cast the result of g_shmat() to the destination type --- xup/xup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xup/xup.c b/xup/xup.c index ada25c42..b841985e 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -1088,7 +1088,7 @@ process_server_paint_rect_shmem(struct mod *amod, struct stream *s) if (amod->screen_shmem_id_mapped == 0) { 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) { /* failed */ @@ -1199,7 +1199,7 @@ process_server_paint_rect_shmem_ex(struct mod *amod, struct stream *s) if (amod->screen_shmem_id_mapped == 0) { 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) { /* failed */ From 28a1a090b3463042d2c03964f42da1f0f18f2c23 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 8 Jul 2016 01:33:29 +0000 Subject: [PATCH 28/32] Use correct types for ssl and ctx fields in struct ssl_tls --- common/ssl_calls.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/ssl_calls.h b/common/ssl_calls.h index c470e63a..aa7cffb1 100644 --- a/common/ssl_calls.h +++ b/common/ssl_calls.h @@ -84,8 +84,8 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len, /* ssl_tls */ struct ssl_tls { - void *ssl; /* SSL * */ - void *ctx; /* SSL_CTX * */ + struct ssl_st *ssl; /* SSL * */ + struct ssl_ctx_st *ctx; /* SSL_CTX * */ char *cert; char *key; struct trans *trans; From cbe413bd8b9d74b75af90c875c84bdd273752f73 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:18 -0700 Subject: [PATCH 29/32] Fix return type of devredir_fuse_data_peek and devredir_fuse_data_dequeue --- sesman/chansrv/devredir.c | 4 ++-- sesman/chansrv/devredir.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index 3014e53a..2ce30286 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -1321,7 +1321,7 @@ dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId, * @return FUSE_DATA on success, or NULL on failure *****************************************************************************/ -void * APP_CC +FUSE_DATA *APP_CC devredir_fuse_data_peek(IRP *irp) { log_debug("returning %p", irp->fd_head); @@ -1334,7 +1334,7 @@ devredir_fuse_data_peek(IRP *irp) * @return FUSE_DATA on success, NULL on failure *****************************************************************************/ -void * APP_CC +FUSE_DATA *APP_CC devredir_fuse_data_dequeue(IRP *irp) { FUSE_DATA *head; diff --git a/sesman/chansrv/devredir.h b/sesman/chansrv/devredir.h index 8e2cb957..b49eb1dd 100644 --- a/sesman/chansrv/devredir.h +++ b/sesman/chansrv/devredir.h @@ -27,8 +27,8 @@ #define USE_SHORT_NAMES_IN_DIR_LISTING -void *devredir_fuse_data_peek(IRP *irp); -void *devredir_fuse_data_dequeue(IRP *irp); +FUSE_DATA *devredir_fuse_data_peek(IRP *irp); +FUSE_DATA *devredir_fuse_data_dequeue(IRP *irp); int devredir_fuse_data_enqueue(IRP *irp, void *vp); int APP_CC dev_redir_init(void); From 0c72ee237192b8e7e73070b6ec9273666b997d26 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 8 Jul 2016 01:24:31 +0000 Subject: [PATCH 30/32] Use char* for TLS send and receive This is consistent with ssl_tls_read() and ssl_tls_write(). C++ warnings are fixed without adding any casts. --- common/trans.c | 8 ++++---- common/trans.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/trans.c b/common/trans.c index 9611f768..9e877d5c 100644 --- a/common/trans.c +++ b/common/trans.c @@ -28,7 +28,7 @@ /*****************************************************************************/ 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) { @@ -39,7 +39,7 @@ trans_tls_recv(struct trans *self, void *ptr, int len) /*****************************************************************************/ 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) { @@ -61,14 +61,14 @@ trans_tls_can_recv(struct trans *self, int sck, int millis) /*****************************************************************************/ 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); } /*****************************************************************************/ 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); } diff --git a/common/trans.h b/common/trans.h index 639e64d1..1bb15bcf 100644 --- a/common/trans.h +++ b/common/trans.h @@ -41,8 +41,8 @@ typedef int (DEFAULT_CC *ttrans_data_in)(struct trans* self); typedef int (DEFAULT_CC *ttrans_conn_in)(struct trans* self, struct trans* new_self); 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_send_proc) (struct trans *self, const void *data, 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 char *data, int len); typedef int (APP_CC *trans_can_recv_proc) (struct trans *self, int sck, int millis); /* optional source info */ From 2c13ef5c6dd90ee2dcbcba282b2ee702e2ee9f84 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 8 Jul 2016 01:47:31 +0000 Subject: [PATCH 31/32] Use enum logLevels consistently for log levels --- common/log.h | 4 ++-- sesman/chansrv/chansrv.c | 10 +++++----- sesman/tools/sestest.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/log.h b/common/log.h index b90ac660..61a05d9c 100644 --- a/common/log.h +++ b/common/log.h @@ -68,9 +68,9 @@ struct log_config const char *program_name; char *log_file; int fd; - unsigned int log_level; + enum logLevels log_level; int enable_syslog; - unsigned int syslog_level; + enum logLevels syslog_level; pthread_mutex_t log_lock; pthread_mutexattr_t log_lock_attr; }; diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index 0596b5ff..d272806c 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -1401,8 +1401,8 @@ get_log_path() } /*****************************************************************************/ -static unsigned int APP_CC -get_log_level(const char* level_str, unsigned int default_level) +static enum logLevels APP_CC +get_log_level(const char* level_str, enum logLevels default_level) { static const char* levels[] = { "LOG_LEVEL_ALWAYS", @@ -1421,7 +1421,7 @@ get_log_level(const char* level_str, unsigned int default_level) { if (g_strcasecmp(levels[i], level_str) == 0) { - return i; + return (enum logLevels) i; } } return default_level; @@ -1466,7 +1466,7 @@ main(int argc, char **argv) char log_file[256]; enum logReturns error; struct log_config logconfig; - unsigned int log_level; + enum logLevels log_level; g_init("xrdp-chansrv"); /* os_calls */ @@ -1498,7 +1498,7 @@ main(int argc, char **argv) logconfig.fd = -1; logconfig.log_level = log_level; logconfig.enable_syslog = 0; - logconfig.syslog_level = 0; + logconfig.syslog_level = LOG_LEVEL_ALWAYS; error = log_start_from_param(&logconfig); if (error != LOG_STARTUP_OK) diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c index 17795dfc..081bc88b 100644 --- a/sesman/tools/sestest.c +++ b/sesman/tools/sestest.c @@ -44,7 +44,7 @@ int main(int argc, char **argv) int sock; log.enable_syslog = 0; - log.log_level = 99; + log.log_level = LOG_LEVEL_DEBUG; log.program_name = "sestest"; log.log_file = g_strdup("sestest.log"); log_start_from_param(&log); From ace7d2c822937a9cb0637946f85d1fbd63562c44 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 8 Jul 2016 05:09:09 +0000 Subject: [PATCH 32/32] Declare unified module interface and use it in modules This fixes loading modules compiled with a C++ compiler. Remote thandle type, it's unused. Use tintptr for module data. Don't cast pointers to long, they won't fit on Win64. --- common/arch.h | 11 ++++++++++- mc/mc.c | 10 ++++++---- neutrinordp/xrdp-neutrinordp.c | 10 ++++++---- rdp/rdp.c | 10 ++++++---- vnc/vnc.c | 9 +++++---- xup/xup.c | 10 ++++++---- 6 files changed, 39 insertions(+), 21 deletions(-) diff --git a/common/arch.h b/common/arch.h index 5c67cb66..7070d6ae 100644 --- a/common/arch.h +++ b/common/arch.h @@ -113,7 +113,6 @@ typedef __int64 tbus; #else typedef long tbus; #endif -typedef tbus thandle; typedef tbus tintptr; /* wide char, socket */ #if defined(_WIN32) @@ -137,4 +136,14 @@ typedef signed long long tsi64; #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 diff --git a/mc/mc.c b/mc/mc.c index 3bcf16f1..3e0909d4 100644 --- a/mc/mc.c +++ b/mc/mc.c @@ -81,7 +81,7 @@ lib_mod_set_param(struct mod *mod, const char *name, char *value) } /******************************************************************************/ -struct mod *EXPORT_CC +tintptr EXPORT_CC mod_init(void) { struct mod *mod; @@ -89,20 +89,22 @@ mod_init(void) mod = (struct mod *)g_malloc(sizeof(struct mod), 1); mod->size = sizeof(struct mod); mod->version = CURRENT_MOD_VER; - mod->handle = (long)mod; + mod->handle = (tintptr) mod; mod->mod_connect = lib_mod_connect; mod->mod_start = lib_mod_start; mod->mod_event = lib_mod_event; mod->mod_signal = lib_mod_signal; mod->mod_end = lib_mod_end; mod->mod_set_param = lib_mod_set_param; - return mod; + return (tintptr) mod; } /******************************************************************************/ int EXPORT_CC -mod_exit(struct mod *mod) +mod_exit(tintptr handle) { + struct mod *mod = (struct mod *) handle; + if (mod == 0) { return 0; diff --git a/neutrinordp/xrdp-neutrinordp.c b/neutrinordp/xrdp-neutrinordp.c index 9fb3b20d..34ed9c2c 100644 --- a/neutrinordp/xrdp-neutrinordp.c +++ b/neutrinordp/xrdp-neutrinordp.c @@ -1955,7 +1955,7 @@ lfreerdp_verify_certificate(freerdp *instance, char *subject, char *issuer, } /******************************************************************************/ -struct mod *EXPORT_CC +tintptr EXPORT_CC mod_init(void) { struct mod *mod; @@ -1968,7 +1968,7 @@ mod_init(void) mod->vmaj, mod->vmin, mod->vrev)); mod->size = sizeof(struct mod); mod->version = CURRENT_MOD_VER; - mod->handle = (tbus)mod; + mod->handle = (tintptr) mod; mod->mod_connect = lxrdp_connect; mod->mod_start = lxrdp_start; mod->mod_event = lxrdp_event; @@ -1995,13 +1995,15 @@ mod_init(void) lcon->modi = mod; LLOGLN(10, ("mod_init: mod %p", mod)); - return mod; + return (tintptr) mod; } /******************************************************************************/ int EXPORT_CC -mod_exit(struct mod *mod) +mod_exit(tintptr handle) { + struct mod *mod = (struct mod *) handle; + LLOGLN(0, ("mod_exit:")); if (mod == 0) diff --git a/rdp/rdp.c b/rdp/rdp.c index ffced90b..5dc13363 100644 --- a/rdp/rdp.c +++ b/rdp/rdp.c @@ -318,7 +318,7 @@ lib_mod_check_wait_objs(struct mod *mod) } /******************************************************************************/ -struct mod *EXPORT_CC +tintptr EXPORT_CC mod_init(void) { struct mod *mod; @@ -327,7 +327,7 @@ mod_init(void) mod = (struct mod *)g_malloc(sizeof(struct mod), 1); mod->size = sizeof(struct mod); mod->version = CURRENT_MOD_VER; - mod->handle = (long)mod; + mod->handle = (tintptr) mod; mod->mod_connect = lib_mod_connect; mod->mod_start = lib_mod_start; mod->mod_event = lib_mod_event; @@ -338,13 +338,15 @@ mod_init(void) mod->mod_check_wait_objs = lib_mod_check_wait_objs; mod->rdp_layer = rdp_rdp_create(mod); DEBUG(("out mod_init")); - return mod; + return (tintptr) mod; } /******************************************************************************/ int EXPORT_CC -mod_exit(struct mod *mod) +mod_exit(tintptr handle) { + struct mod *mod = (struct mod *) handle; + DEBUG(("in mod_exit")); g_free(mod); DEBUG(("out mod_exit")); diff --git a/vnc/vnc.c b/vnc/vnc.c index 99245b53..8da35f5a 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -1465,7 +1465,7 @@ lib_mod_check_wait_objs(struct vnc *v) } /******************************************************************************/ -struct vnc *EXPORT_CC +tintptr EXPORT_CC mod_init(void) { struct vnc *v; @@ -1474,7 +1474,7 @@ mod_init(void) /* set client functions */ v->size = sizeof(struct vnc); v->version = CURRENT_MOD_VER; - v->handle = (long)v; + v->handle = (tintptr) v; v->mod_connect = lib_mod_connect; v->mod_start = lib_mod_start; v->mod_event = lib_mod_event; @@ -1483,13 +1483,14 @@ mod_init(void) v->mod_set_param = lib_mod_set_param; v->mod_get_wait_objs = lib_mod_get_wait_objs; v->mod_check_wait_objs = lib_mod_check_wait_objs; - return v; + return (tintptr) v; } /******************************************************************************/ 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"); if (v == 0) diff --git a/xup/xup.c b/xup/xup.c index b841985e..e2c34ca8 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -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) { struct mod *mod; @@ -1560,7 +1560,7 @@ mod_init(void) mod = (struct mod *)g_malloc(sizeof(struct mod), 1); mod->size = sizeof(struct mod); mod->version = CURRENT_MOD_VER; - mod->handle = (tbus)mod; + mod->handle = (tintptr) mod; mod->mod_connect = lib_mod_connect; mod->mod_start = lib_mod_start; 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_check_wait_objs = lib_mod_check_wait_objs; mod->mod_frame_ack = lib_mod_frame_ack; - return mod; + return (tintptr) mod; } /******************************************************************************/ int EXPORT_CC -mod_exit(struct mod *mod) +mod_exit(tintptr handle) { + struct mod *mod = (struct mod *) handle; + if (mod == 0) { return 0;