From 5523847540f32265b7d6d75d68bd63931491ef39 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Sat, 22 Aug 2020 18:05:24 +0100 Subject: [PATCH 1/2] Allow FuseMountName for chansrv to be absolute path --- common/Makefile.am | 3 +- common/log.c | 1 + common/os_calls.c | 26 +++--- common/os_calls.h | 2 +- common/string_calls.c | 136 ++++++++++++++++++++++++++++++++ common/string_calls.h | 81 +++++++++++++++++++ docs/man/sesman.ini.5.in | 36 ++++++++- libxrdp/xrdp_rdp.c | 1 + neutrinordp/xrdp-neutrinordp.c | 1 + sesman/chansrv/chansrv_config.c | 16 +++- sesman/chansrv/chansrv_config.h | 3 + sesman/chansrv/chansrv_fuse.c | 107 +++++++++++++++++++++---- sesman/config.c | 1 + sesman/sesman.ini.in | 7 +- xrdp/xrdp_listen.c | 1 + xrdp/xrdp_login_wnd.c | 1 + xrdp/xrdp_mm.c | 1 + xrdp/xrdp_wm.c | 1 + 18 files changed, 386 insertions(+), 39 deletions(-) create mode 100644 common/string_calls.c create mode 100644 common/string_calls.h diff --git a/common/Makefile.am b/common/Makefile.am index 7563b82b..d8bdc615 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -54,11 +54,12 @@ libcommon_la_SOURCES = \ log.h \ os_calls.c \ os_calls.h \ - os_calls.h \ parse.h \ rail.h \ ssl_calls.c \ ssl_calls.h \ + string_calls.c \ + string_calls.h \ thread_calls.c \ thread_calls.h \ trans.c \ diff --git a/common/log.c b/common/log.c index a045adfc..ef462f84 100644 --- a/common/log.c +++ b/common/log.c @@ -31,6 +31,7 @@ #include "file.h" #include "os_calls.h" #include "thread_calls.h" +#include "string_calls.h" /* Add a define here so that the log.h will hold more information * when compiled from this C file. diff --git a/common/os_calls.c b/common/os_calls.c index 5ed7db12..6f3bd219 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -3307,6 +3307,17 @@ g_setsid(void) #endif } +/*****************************************************************************/ +int +g_getlogin(char *name, unsigned int len) +{ +#if defined(_WIN32) + return -1; +#else + return getlogin_r(name, len); +#endif +} + /*****************************************************************************/ int g_setlogin(const char *name) @@ -3760,21 +3771,6 @@ g_save_to_bmp(const char* filename, char* data, int stride_bytes, return 0; } -/*****************************************************************************/ -/* returns boolean */ -int -g_text2bool(const char *s) -{ - if ( (g_atoi(s) != 0) || - (0 == g_strcasecmp(s, "true")) || - (0 == g_strcasecmp(s, "on")) || - (0 == g_strcasecmp(s, "yes"))) - { - return 1; - } - return 0; -} - /*****************************************************************************/ /* returns pointer or nil on error */ void * diff --git a/common/os_calls.h b/common/os_calls.h index 0245f0b9..d21248fa 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -162,6 +162,7 @@ int g_getuid(void); int g_getgid(void); int g_setuid(int pid); int g_setsid(void); +int g_getlogin(char *name, unsigned int len); int g_setlogin(const char *name); int g_waitchild(void); int g_waitpid(int pid); @@ -180,7 +181,6 @@ int g_time2(void); int g_time3(void); int g_save_to_bmp(const char* filename, char* data, int stride_bytes, int width, int height, int depth, int bits_per_pixel); -int g_text2bool(const char *s); void * g_shmat(int shmid); int g_shmdt(const void *shmaddr); int g_gethostname(char *name, int len); diff --git a/common/string_calls.c b/common/string_calls.c new file mode 100644 index 00000000..cb6468bc --- /dev/null +++ b/common/string_calls.c @@ -0,0 +1,136 @@ +/** + * xrdp: A Remote Desktop Protocol server. + * + * Copyright (C) Jay Sorg 2004-2020 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * generic string handling calls + */ + +#include +#include +#include + +#include "string_calls.h" + +unsigned int +g_format_info_string(char* dest, unsigned int len, + const char* format, + const struct info_string_tag map[]) +{ + unsigned int result = 0; + const char *copy_from; /* Data to add to output */ + unsigned int copy_len; /* Length of above */ + unsigned int skip; /* Date to skip over in format string */ + const char *p; + const struct info_string_tag *m; + + for ( ; *format != '\0'; format += skip) + { + if (*format == '%') + { + char ch= *(format + 1); + if (ch== '%') + { + /* '%%' in format - replace with single '%' */ + copy_from = format; + copy_len= 1; + skip = 2; + } + else if (ch== '\0') + { + /* Percent at end of string - ignore */ + copy_from = NULL; + copy_len= 0; + skip = 1; + } + else + { + /* Look up the character in the map, assuming failure */ + copy_from = NULL; + copy_len= 0; + skip = 2; + + for (m = map ; m->ch != '\0' ; ++m) + { + if (ch == m->ch) + { + copy_from = m->val; + copy_len = strlen(copy_from); + break; + } + } + } + } + else if ((p = strchr(format, '%')) != NULL) + { + /* Copy up to the next '%' */ + copy_from = format; + copy_len = p - format; + skip = copy_len; + } + else + { + /* Copy the rest of the format string */ + copy_from = format; + copy_len = strlen(format); + skip = copy_len; + } + + /* Update the result before any truncation */ + result += copy_len; + + /* Do we have room in the output buffer for any more data? We + * must always write a terminator if possible */ + if (len > 1) + { + if (copy_len > (len - 1)) + { + copy_len = len - 1; + } + memcpy(dest, copy_from, copy_len); + dest += copy_len; + len -= copy_len; + } + } + + /* Room for a terminator? */ + if (len > 0) + { + *dest = '\0'; + } + + return result; +} + +/******************************************************************************/ +const char * +g_bool2text(int value) +{ + return value ? "true" : "false"; +} + +/*****************************************************************************/ +int +g_text2bool(const char *s) +{ + if ( (atoi(s) != 0) || + (0 == strcasecmp(s, "true")) || + (0 == strcasecmp(s, "on")) || + (0 == strcasecmp(s, "yes"))) + { + return 1; + } + return 0; +} diff --git a/common/string_calls.h b/common/string_calls.h new file mode 100644 index 00000000..32aa62fd --- /dev/null +++ b/common/string_calls.h @@ -0,0 +1,81 @@ +/** + * xrdp: A Remote Desktop Protocol server. + * + * Copyright (C) Jay Sorg 2004-2020 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * generic string handling calls + */ + +#if !defined(STRING_CALLS_H) +#define STRING_CALLS_H + +/** + * Map a character to a string value + * + * This structure is used by g_format_info_string() to specify the + * string which chould be output for %'ch', where ch is a character + */ +struct info_string_tag +{ + char ch; + const char *val; +}; + +#define INFO_STRING_END_OF_LIST { '\0', NULL } + +/** + * Processes a format string for general info + * + * @param[out] dest Destination buffer + * @param[in] len Length of buffer, including space for a terminator + * @param[in] format Format string to process + * @param[in] map Array of struct info_string_tag. + * + * Where a '%' is encountered in the format string, the map is scanned + * and the corresponding string is copied instead of '%'. + * + * '%%' is always replaced with a single '%' in the output. % strings + * not present in the map are ignored. + * + * The map is terminated with INFO_STRING_END_OF_LIST + * + * Caller can check for buffer truncation by comparing the result with + * the buffer length (as in snprintf()) + */ +unsigned int +g_format_info_string(char* dest, unsigned int len, + const char* format, + const struct info_string_tag map[]); + + +/** + * Converts a boolean to a string for output + * + * @param[in] value Value to convert + * @return String representation + */ +const char * +g_bool2text(int value); + +/** + * Converts a string to a boolean value + * + * @param[in] s String to convert + * @return machine representation + */ +int +g_text2bool(const char *s); + +#endif diff --git a/docs/man/sesman.ini.5.in b/docs/man/sesman.ini.5.in index 5b6aac92..a60d7fef 100644 --- a/docs/man/sesman.ini.5.in +++ b/docs/man/sesman.ini.5.in @@ -246,8 +246,27 @@ 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. +Directory for drive redirection. Created if it doesn't exist. If not specified, defaults to \fIxrdp_client\fR. +If first character is not a '/', this is relative to $HOME. +.P +.RS +If first character is a '/' this is an absolute path. The following +substitutions are made in this string:- + %U - Username + %u - Numeric UID + %% - Percent character +.P +If this format is used:- +.HP 3 +1) The directory path permissions MUST be configured correctly by +the system administrator or the system itself - xrdp-chansrv will not +do this for you (although it will create the final directories owned by +the user). +.HP 3 +2) The desktop may not automatically display a link for the redirected +drive. To fix this, consult the docs for your chosen desktop. +.RE .TP \fBFileUmask\fR=\fImode\fR @@ -257,6 +276,21 @@ files on your redirected drives. This may not be approprate for all environents, and so you can change this value to allow other users to access your remote files if required. +.TP +\fBEnableFuseMount\fR=\fI[true|false]\fR +Defaults to \fItrue\fR. +Set to \fIfalse\fR to disable xrdp-chansrv's use of the FUSE system +feature, even if it has been built with this feature enabled. +.P +.RS +Setting this value to \fIfalse\fR will disable the following application +features:- +.P +- drive redirection +.P +- copying-and-pasting of files +.RE + .SH "SESSIONS VARIABLES" All entries in the \fB[SessionVariables]\fR section are set as environment variables in the user's session. diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index f5616991..da36b3a6 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -26,6 +26,7 @@ #include "ms-rdpbcgr.h" #include "log.h" #include "ssl_calls.h" +#include "string_calls.h" #if defined(XRDP_NEUTRINORDP) #include diff --git a/neutrinordp/xrdp-neutrinordp.c b/neutrinordp/xrdp-neutrinordp.c index 651b5096..50ae1bf8 100644 --- a/neutrinordp/xrdp-neutrinordp.c +++ b/neutrinordp/xrdp-neutrinordp.c @@ -26,6 +26,7 @@ #include "xrdp_rail.h" #include "trans.h" #include "log.h" +#include "string_calls.h" #include #if defined(VERSION_STRUCT_RDP_FREERDP) diff --git a/sesman/chansrv/chansrv_config.c b/sesman/chansrv/chansrv_config.c index c265ff02..ad8789ec 100644 --- a/sesman/chansrv/chansrv_config.c +++ b/sesman/chansrv/chansrv_config.c @@ -31,10 +31,12 @@ #include "os_calls.h" #include "chansrv_config.h" +#include "string_calls.h" /* Default settings */ #define DEFAULT_USE_UNIX_SOCKET 0 #define DEFAULT_RESTRICT_OUTBOUND_CLIPBOARD 0 +#define DEFAULT_ENABLE_FUSE_MOUNT 1 #define DEFAULT_FUSE_MOUNT_NAME "xrdp-client" #define DEFAULT_FILE_UMASK 077 @@ -155,6 +157,10 @@ read_config_chansrv(log_func_t logmsg, const char *name = (const char *)list_get_item(names, index); const char *value = (const char *)list_get_item(values, index); + if (g_strcasecmp(name, "EnableFuseMount") == 0) + { + cfg->enable_fuse_mount = g_text2bool(value); + } if (g_strcasecmp(name, "FuseMountName") == 0) { g_free(cfg->fuse_mount_name); @@ -196,6 +202,7 @@ new_config(void) else { cfg->use_unix_socket = DEFAULT_USE_UNIX_SOCKET; + cfg->enable_fuse_mount = DEFAULT_ENABLE_FUSE_MOUNT; cfg->restrict_outbound_clipboard = DEFAULT_RESTRICT_OUTBOUND_CLIPBOARD; cfg->fuse_mount_name = fuse_mount_name; cfg->file_umask = DEFAULT_FILE_UMASK; @@ -271,13 +278,16 @@ void config_dump(struct config_chansrv *config) { g_writeln("Global configuration:"); - g_writeln(" UseUnixSocket (derived): %d", config->use_unix_socket); + g_writeln(" UseUnixSocket (derived): %s", + g_bool2text(config->use_unix_socket)); g_writeln("\nSecurity configuration:"); - g_writeln(" RestrictOutboundClipboard: %d", - config->restrict_outbound_clipboard); + g_writeln(" RestrictOutboundClipboard: %s", + g_bool2text(config->restrict_outbound_clipboard)); g_writeln("\nChansrv configuration:"); + g_writeln(" EnableFuseMount %s", + g_bool2text(config->enable_fuse_mount)); g_writeln(" FuseMountName: %s", config->fuse_mount_name); g_writeln(" FileMask: 0%o", config->file_umask); } diff --git a/sesman/chansrv/chansrv_config.h b/sesman/chansrv/chansrv_config.h index 72d301cd..3d0ff379 100644 --- a/sesman/chansrv/chansrv_config.h +++ b/sesman/chansrv/chansrv_config.h @@ -26,6 +26,9 @@ struct config_chansrv /** Whether to use a UNIX socket for chansrv */ int use_unix_socket; + /** Whether the FUSE mount is enabled or not */ + int enable_fuse_mount; + /** RestrictOutboundClipboard setting from sesman.ini */ int restrict_outbound_clipboard; diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index b4411291..d5a53a9a 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -144,6 +144,7 @@ void xfuse_devredir_cb_file_close(struct state_close *fip) #include "arch.h" #include "os_calls.h" +#include "string_calls.h" #include "clipboard_file.h" #include "chansrv_fuse.h" #include "chansrv_xfs.h" @@ -392,6 +393,8 @@ static const char *filename_on_device(const char *full_path); static void update_inode_file_attributes(const struct file_attr *fattr, tui32 change_mask, XFS_INODE *xinode); static char *get_name_for_entry_in_parent(fuse_ino_t parent, const char *name); +static unsigned int format_user_info(char *dest, unsigned int len, + const char *format); /*****************************************************************************/ int @@ -446,7 +449,7 @@ xfuse_handle_from_fuse_handle(uint64_t handle) /** * Initialize FUSE subsystem * - * @return 0 on success, -1 on failure + * @return 0 on success, -1 on failure, 1 for feature disabled *****************************************************************************/ int @@ -458,6 +461,21 @@ xfuse_init(void) if (g_xfuse_inited) { LOG_DEVEL(LOG_LEVEL_DEBUG, "already inited"); + return 0; + } + + /* This feature may be disabled */ + if (!g_cfg->enable_fuse_mount) + { + /* + * Only log the 'disabled mounts' message one time + */ + static int disabled_mounts_msg_shown = 0; + if (!disabled_mounts_msg_shown) + { + LOG(LOG_LEVEL_INFO, "FUSE mounts are disabled by config"); + disabled_mounts_msg_shown = 1; + } return 1; } @@ -469,13 +487,27 @@ xfuse_init(void) load_fuse_config(); - /* define FUSE mount point to ~/xrdp_client, ~/thinclient_drives */ - g_snprintf(g_fuse_root_path, 255, "%s/%s", g_getenv("HOME"), g_cfg->fuse_mount_name); + /* define FUSE mount point */ + if (g_cfg->fuse_mount_name[0] == '/') + { + /* String is an absolute path to the mount point containing + * %u or %U characters */ + format_user_info(g_fuse_root_path, sizeof(g_fuse_root_path), + g_cfg->fuse_mount_name); + } + else + { + /* mount_name is relative to $HOME, e.g. ~/xrdp_client, + * or ~/thinclient_drives */ + g_snprintf(g_fuse_root_path, sizeof(g_fuse_root_path), "%s/%s", + g_getenv("HOME"), g_cfg->fuse_mount_name); + } g_snprintf(g_fuse_clipboard_path, 255, "%s/.clipboard", g_fuse_root_path); /* if FUSE mount point does not exist, create it */ if (!g_directory_exist(g_fuse_root_path)) { + (void)g_create_path(g_fuse_root_path); if (!g_create_dir(g_fuse_root_path)) { LOG_DEVEL(LOG_LEVEL_ERROR, "mkdir %s failed. If %s is already mounted, you must " @@ -748,23 +780,38 @@ xfuse_file_contents_range(int stream_id, const char *data, int data_bytes) int xfuse_add_clip_dir_item(const char *filename, int flags, int size, int lindex) { - LOG_DEVEL(LOG_LEVEL_DEBUG, "entered: filename=%s flags=%d size=%d lindex=%d", + LOG_DEVEL(LOG_LEVEL_DEBUG, + "entered: filename=%s flags=%d size=%d lindex=%d", filename, flags, size, lindex); - /* add entry to xrdp_fs */ - XFS_INODE *xinode = xfs_add_entry( g_xfs, - g_clipboard_inum, /* parent inode */ - filename, - (0666 | S_IFREG)); - if (xinode == NULL) - { - LOG_DEVEL(LOG_LEVEL_DEBUG, "failed to create file in xrdp filesystem"); - return -1; - } - xinode->size = size; - xinode->lindex = lindex; + int result = -1; - return 0; + if (g_xfs == NULL) + { + LOG_DEVEL(LOG_LEVEL_ERROR, + "xfuse_add_clip_dir_item() called with no filesystem") + } + else + { + /* add entry to xrdp_fs */ + XFS_INODE *xinode = xfs_add_entry( g_xfs, + g_clipboard_inum, /* parent inode */ + filename, + (0666 | S_IFREG)); + if (xinode == NULL) + { + LOG(LOG_LEVEL_INFO, + "failed to create file %s in xrdp filesystem", filename); + } + else + { + xinode->size = size; + xinode->lindex = lindex; + result = 0; + } + } + + return result; } /** @@ -2609,4 +2656,30 @@ static char *get_name_for_entry_in_parent(fuse_ino_t parent, const char *name) return result; } +/* + * Scans a user-provided string substituting %u/%U for UID/username + */ +static unsigned int format_user_info(char *dest, unsigned int len, + const char *format) +{ + char uidstr[64]; + char username[64]; + const struct info_string_tag map[] = + { + {'u', uidstr}, + {'U', username}, + INFO_STRING_END_OF_LIST + }; + + int uid = g_getuid(); + g_snprintf(uidstr, sizeof(uidstr), "%d", uid); + if (g_getlogin(username, sizeof(username)) != 0) + { + /* Fall back to UID */ + g_strncpy(username, uidstr, sizeof(username) - 1); + } + + return g_format_info_string(dest, len, format, map); +} + #endif /* end else #ifndef XRDP_FUSE */ diff --git a/sesman/config.c b/sesman/config.c index 142f3ced..481ae760 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -33,6 +33,7 @@ #include "file.h" #include "sesman.h" #include "log.h" +#include "string_calls.h" /***************************************************************************//** * diff --git a/sesman/sesman.ini.in b/sesman/sesman.ini.in index da4aaa0c..b709650d 100644 --- a/sesman/sesman.ini.in +++ b/sesman/sesman.ini.in @@ -114,11 +114,16 @@ param=-dpi param=96 [Chansrv] -; drive redirection, defaults to xrdp_client if not set +; drive redirection +; See sesman.ini(5) for the format of this parameter +#FuseMountName=/run/user/%u/thinclient_drives +#FuseMountName=/media/thinclient_drives/%U/thinclient_drives FuseMountName=thinclient_drives ; this value allows only the user to acess their own mapped drives. ; Make this more permissive (e.g. 022) if required. FileUmask=077 +; Can be used to disable FUSE functionality - see sesman.ini(5) +#EnableFuseMount=false [ChansrvLogging] ; Note: one log file is created per display and the LogFile config value diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c index a8bb205a..dc327cd8 100644 --- a/xrdp/xrdp_listen.c +++ b/xrdp/xrdp_listen.c @@ -24,6 +24,7 @@ #include "xrdp.h" #include "log.h" +#include "string_calls.h" /* 'g_process' is protected by the semaphore 'g_process_sem'. One thread sets g_process and waits for the other to process it */ diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c index 8fb72e62..530c0ca2 100644 --- a/xrdp/xrdp_login_wnd.c +++ b/xrdp/xrdp_login_wnd.c @@ -25,6 +25,7 @@ #include "base64.h" #include "xrdp.h" #include "log.h" +#include "string_calls.h" #define ASK "ask" #define ASK_LEN g_strlen(ASK) diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 0e225b33..7d4bb86d 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -23,6 +23,7 @@ #endif #include "xrdp.h" #include "log.h" +#include "string_calls.h" #ifndef USE_NOPAM #if defined(HAVE__PAM_TYPES_H) diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 0350c856..558be618 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -27,6 +27,7 @@ #include "xrdp.h" #include "ms-rdpbcgr.h" #include "log.h" +#include "string_calls.h" #define LLOG_LEVEL 1 #define LLOGLN(_level, _args) \ From 0a1a8f40e52934718df666e64696e79802802d7e Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Mon, 21 Dec 2020 12:36:00 +0000 Subject: [PATCH 2/2] Moved a lot of string funcs to string_calls module --- common/base64.c | 2 +- common/file.c | 1 + common/list.c | 1 + common/os_calls.c | 514 +----------------------------- common/os_calls.h | 21 -- common/ssl_calls.c | 1 + common/string_calls.c | 543 +++++++++++++++++++++++++++++++- common/string_calls.h | 29 +- common/trans.c | 1 + keygen/keygen.c | 1 + libxrdp/libxrdp.c | 1 + libxrdp/xrdp_channel.c | 1 + libxrdp/xrdp_orders_rail.c | 1 + libxrdp/xrdp_sec.c | 1 + sesman/access.c | 1 + sesman/chansrv/chansrv.c | 1 + sesman/chansrv/clipboard.c | 1 + sesman/chansrv/clipboard_file.c | 1 + sesman/chansrv/devredir.c | 1 + sesman/chansrv/irp.c | 1 + sesman/chansrv/rail.c | 1 + sesman/chansrv/smartcard.c | 1 + sesman/chansrv/smartcard_pcsc.c | 1 + sesman/env.c | 1 + sesman/libscp/libscp_session.c | 1 + sesman/libscp/libscp_v0.c | 1 + sesman/libscp/libscp_v1c.c | 1 + sesman/libscp/libscp_v1c_mng.c | 1 + sesman/libscp/libscp_v1s.c | 1 + sesman/libscp/libscp_v1s_mng.c | 1 + sesman/sesman.c | 1 + sesman/session.c | 1 + sesman/tools/sesadmin.c | 1 + sesman/tools/sesrun.c | 1 + sesman/tools/sestest.c | 1 + sesman/verify_user_pam.c | 1 + sesman/xauth.c | 1 + vnc/vnc.c | 1 + xrdp/funcs.c | 1 + xrdp/lang.c | 1 + xrdp/xrdp.c | 1 + xrdp/xrdp_bitmap.c | 1 + xrdp/xrdp_painter.c | 1 + xup/xup.c | 1 + 44 files changed, 597 insertions(+), 551 deletions(-) diff --git a/common/base64.c b/common/base64.c index 55f92401..a5b83dfa 100644 --- a/common/base64.c +++ b/common/base64.c @@ -22,7 +22,7 @@ #include #endif -#include "os_calls.h" +#include "string_calls.h" #include #include diff --git a/common/file.c b/common/file.c index b796f5b0..3a66bba3 100644 --- a/common/file.c +++ b/common/file.c @@ -24,6 +24,7 @@ #include "arch.h" #include "os_calls.h" +#include "string_calls.h" #include "list.h" #include "file.h" #include "parse.h" diff --git a/common/list.c b/common/list.c index 8224c353..4597b9cb 100644 --- a/common/list.c +++ b/common/list.c @@ -24,6 +24,7 @@ #include "arch.h" #include "os_calls.h" +#include "string_calls.h" #include "list.h" /*****************************************************************************/ diff --git a/common/os_calls.c b/common/os_calls.c index 6f3bd219..897dd5a1 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -76,7 +76,7 @@ #endif #include "os_calls.h" -#include "arch.h" +#include "string_calls.h" #include "log.h" /* for clearenv() */ @@ -2509,518 +2509,6 @@ g_file_get_size(const char *filename) #endif } -/*****************************************************************************/ -/* returns length of text */ -int -g_strlen(const char *text) -{ - if (text == NULL) - { - return 0; - } - - return strlen(text); -} - -/*****************************************************************************/ -/* locates char in text */ -const char * -g_strchr(const char* text, int c) -{ - if (text == NULL) - { - return 0; - } - - return strchr(text,c); -} - -/*****************************************************************************/ -/* returns dest */ -char * -g_strcpy(char *dest, const char *src) -{ - if (src == 0 && dest != 0) - { - dest[0] = 0; - return dest; - } - - if (dest == 0 || src == 0) - { - return 0; - } - - return strcpy(dest, src); -} - -/*****************************************************************************/ -/* returns dest */ -char * -g_strncpy(char *dest, const char *src, int len) -{ - char *rv; - - if (src == 0 && dest != 0) - { - dest[0] = 0; - return dest; - } - - if (dest == 0 || src == 0) - { - return 0; - } - - rv = strncpy(dest, src, len); - dest[len] = 0; - return rv; -} - -/*****************************************************************************/ -/* returns dest */ -char * -g_strcat(char *dest, const char *src) -{ - if (dest == 0 || src == 0) - { - return dest; - } - - return strcat(dest, src); -} - -/*****************************************************************************/ -/* returns dest */ -char * -g_strncat(char *dest, const char *src, int len) -{ - if (dest == 0 || src == 0) - { - return dest; - } - - return strncat(dest, src, len); -} - -/*****************************************************************************/ -/* if in = 0, return 0 else return newly alloced copy of in */ -char * -g_strdup(const char *in) -{ - int len; - char *p; - - if (in == 0) - { - return 0; - } - - len = g_strlen(in); - p = (char *)g_malloc(len + 1, 0); - - if (p != NULL) - { - g_strcpy(p, in); - } - - return p; -} - -/*****************************************************************************/ -/* if in = 0, return 0 else return newly alloced copy of input string - * if the input string is larger than maxlen the returned string will be - * truncated. All strings returned will include null termination*/ -char * -g_strndup(const char *in, const unsigned int maxlen) -{ - unsigned int len; - char *p; - - if (in == 0) - { - return 0; - } - - len = g_strlen(in); - - if (len > maxlen) - { - len = maxlen - 1; - } - - p = (char *)g_malloc(len + 2, 0); - - if (p != NULL) - { - g_strncpy(p, in, len + 1); - } - - return p; -} - -/*****************************************************************************/ -int -g_strcmp(const char *c1, const char *c2) -{ - return strcmp(c1, c2); -} - -/*****************************************************************************/ -int -g_strncmp(const char *c1, const char *c2, int len) -{ - return strncmp(c1, c2, len); -} - -/*****************************************************************************/ -/* compare up to delim */ -int -g_strncmp_d(const char *s1, const char *s2, const char delim, int n) -{ - char c1; - char c2; - - c1 = 0; - c2 = 0; - while (n > 0) - { - c1 = *(s1++); - c2 = *(s2++); - if ((c1 == 0) || (c1 != c2) || (c1 == delim) || (c2 == delim)) - { - return c1 - c2; - } - n--; - } - return c1 - c2; -} - -/*****************************************************************************/ -int -g_strcasecmp(const char *c1, const char *c2) -{ -#if defined(_WIN32) - return stricmp(c1, c2); -#else - return strcasecmp(c1, c2); -#endif -} - -/*****************************************************************************/ -int -g_strncasecmp(const char *c1, const char *c2, int len) -{ -#if defined(_WIN32) - return strnicmp(c1, c2, len); -#else - return strncasecmp(c1, c2, len); -#endif -} - -/*****************************************************************************/ -int -g_atoi(const char *str) -{ - if (str == 0) - { - return 0; - } - - return atoi(str); -} - -/*****************************************************************************/ -int -g_htoi(char *str) -{ - int len; - int index; - int rv; - int val; - int shift; - - rv = 0; - len = strlen(str); - index = len - 1; - shift = 0; - - while (index >= 0) - { - val = 0; - - switch (str[index]) - { - case '1': - val = 1; - break; - case '2': - val = 2; - break; - case '3': - val = 3; - break; - case '4': - val = 4; - break; - case '5': - val = 5; - break; - case '6': - val = 6; - break; - case '7': - val = 7; - break; - case '8': - val = 8; - break; - case '9': - val = 9; - break; - case 'a': - case 'A': - val = 10; - break; - case 'b': - case 'B': - val = 11; - break; - case 'c': - case 'C': - val = 12; - break; - case 'd': - case 'D': - val = 13; - break; - case 'e': - case 'E': - val = 14; - break; - case 'f': - case 'F': - val = 15; - break; - } - - rv = rv | (val << shift); - index--; - shift += 4; - } - - return rv; -} - -/*****************************************************************************/ -/* returns number of bytes copied into out_str */ -int -g_bytes_to_hexstr(const void *bytes, int num_bytes, char *out_str, - int bytes_out_str) -{ - int rv; - int index; - char *lout_str; - const tui8 *lbytes; - - rv = 0; - lbytes = (const tui8 *) bytes; - lout_str = out_str; - for (index = 0; index < num_bytes; index++) - { - if (bytes_out_str < 3) - { - break; - } - g_snprintf(lout_str, bytes_out_str, "%2.2x", lbytes[index]); - lout_str += 2; - bytes_out_str -= 2; - rv += 2; - } - return rv; -} - -/*****************************************************************************/ -int -g_pos(const char *str, const char *to_find) -{ - const char *pp; - - pp = strstr(str, to_find); - - if (pp == 0) - { - return -1; - } - - return (pp - str); -} - -/*****************************************************************************/ -int -g_mbstowcs(twchar *dest, const char *src, int n) -{ - wchar_t *ldest; - int rv; - - ldest = (wchar_t *)dest; - rv = mbstowcs(ldest, src, n); - return rv; -} - -/*****************************************************************************/ -int -g_wcstombs(char *dest, const twchar *src, int n) -{ - const wchar_t *lsrc; - int rv; - - lsrc = (const wchar_t *)src; - rv = wcstombs(dest, lsrc, n); - return rv; -} - -/*****************************************************************************/ -/* returns error */ -/* trim spaces and tabs, anything <= space */ -/* trim_flags 1 trim left, 2 trim right, 3 trim both, 4 trim through */ -/* this will always shorten the string or not change it */ -int -g_strtrim(char *str, int trim_flags) -{ - int index; - int len; - int text1_index; - int got_char; - wchar_t *text; - wchar_t *text1; - - len = mbstowcs(0, str, 0); - - if (len < 1) - { - return 0; - } - - if ((trim_flags < 1) || (trim_flags > 4)) - { - return 1; - } - - text = (wchar_t *)malloc(len * sizeof(wchar_t) + 8); - text1 = (wchar_t *)malloc(len * sizeof(wchar_t) + 8); - if (text == NULL || text1 == NULL) - { - free(text); - free(text1); - return 1; - } - text1_index = 0; - mbstowcs(text, str, len + 1); - - switch (trim_flags) - { - case 4: /* trim through */ - - for (index = 0; index < len; index++) - { - if (text[index] > 32) - { - text1[text1_index] = text[index]; - text1_index++; - } - } - - text1[text1_index] = 0; - break; - case 3: /* trim both */ - got_char = 0; - - for (index = 0; index < len; index++) - { - if (got_char) - { - text1[text1_index] = text[index]; - text1_index++; - } - else - { - if (text[index] > 32) - { - text1[text1_index] = text[index]; - text1_index++; - got_char = 1; - } - } - } - - text1[text1_index] = 0; - len = text1_index; - - /* trim right */ - for (index = len - 1; index >= 0; index--) - { - if (text1[index] > 32) - { - break; - } - } - - text1_index = index + 1; - text1[text1_index] = 0; - break; - case 2: /* trim right */ - - /* copy it */ - for (index = 0; index < len; index++) - { - text1[text1_index] = text[index]; - text1_index++; - } - - /* trim right */ - for (index = len - 1; index >= 0; index--) - { - if (text1[index] > 32) - { - break; - } - } - - text1_index = index + 1; - text1[text1_index] = 0; - break; - case 1: /* trim left */ - got_char = 0; - - for (index = 0; index < len; index++) - { - if (got_char) - { - text1[text1_index] = text[index]; - text1_index++; - } - else - { - if (text[index] > 32) - { - text1[text1_index] = text[index]; - text1_index++; - got_char = 1; - } - } - } - - text1[text1_index] = 0; - break; - } - - wcstombs(str, text1, text1_index + 1); - free(text); - free(text1); - return 0; -} - /*****************************************************************************/ long g_load_library(char *in) diff --git a/common/os_calls.h b/common/os_calls.h index d21248fa..99454044 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -119,27 +119,6 @@ int g_create_path(const char* path); int g_remove_dir(const char* dirname); int g_file_delete(const char* filename); int g_file_get_size(const char* filename); -int g_strlen(const char* text); -const char *g_strchr(const char *text, int c); -char* g_strcpy(char* dest, const char* src); -char* g_strncpy(char* dest, const char* src, int len); -char* g_strcat(char* dest, const char* src); -char* g_strncat(char* dest, const char* src, int len); -char* g_strdup(const char* in); -char* g_strndup(const char* in, const unsigned int maxlen); -int g_strcmp(const char* c1, const char* c2); -int g_strncmp(const char* c1, const char* c2, int len); -int g_strncmp_d(const char* c1, const char* c2, const char delim, int len); -int g_strcasecmp(const char* c1, const char* c2); -int g_strncasecmp(const char* c1, const char* c2, int len); -int g_atoi(const char* str); -int g_htoi(char* str); -int g_bytes_to_hexstr(const void *bytes, int num_bytes, char *out_str, - int bytes_out_str); -int g_pos(const char* str, const char* to_find); -int g_mbstowcs(twchar* dest, const char* src, int n); -int g_wcstombs(char* dest, const twchar* src, int n); -int g_strtrim(char* str, int trim_flags); long g_load_library(char* in); int g_free_library(long lib); void* g_get_proc_address(long lib, const char* name); diff --git a/common/ssl_calls.c b/common/ssl_calls.c index f86dc063..aee18c28 100644 --- a/common/ssl_calls.c +++ b/common/ssl_calls.c @@ -36,6 +36,7 @@ #include #include "os_calls.h" +#include "string_calls.h" #include "arch.h" #include "ssl_calls.h" #include "trans.h" diff --git a/common/string_calls.c b/common/string_calls.c index cb6468bc..6023347b 100644 --- a/common/string_calls.c +++ b/common/string_calls.c @@ -18,16 +18,20 @@ * generic string handling calls */ +#if defined(HAVE_CONFIG_H) +#include "config_ac.h" +#endif #include #include #include #include "string_calls.h" +#include "os_calls.h" unsigned int -g_format_info_string(char* dest, unsigned int len, - const char* format, - const struct info_string_tag map[]) +g_format_info_string(char *dest, unsigned int len, + const char *format, + const struct info_string_tag map[]) { unsigned int result = 0; const char *copy_from; /* Data to add to output */ @@ -40,26 +44,26 @@ g_format_info_string(char* dest, unsigned int len, { if (*format == '%') { - char ch= *(format + 1); - if (ch== '%') + char ch = *(format + 1); + if (ch == '%') { /* '%%' in format - replace with single '%' */ copy_from = format; - copy_len= 1; + copy_len = 1; skip = 2; } - else if (ch== '\0') + else if (ch == '\0') { /* Percent at end of string - ignore */ copy_from = NULL; - copy_len= 0; + copy_len = 0; skip = 1; } else { /* Look up the character in the map, assuming failure */ copy_from = NULL; - copy_len= 0; + copy_len = 0; skip = 2; for (m = map ; m->ch != '\0' ; ++m) @@ -125,12 +129,525 @@ g_bool2text(int value) int g_text2bool(const char *s) { - if ( (atoi(s) != 0) || - (0 == strcasecmp(s, "true")) || - (0 == strcasecmp(s, "on")) || - (0 == strcasecmp(s, "yes"))) + if ( (g_atoi(s) != 0) || + (0 == g_strcasecmp(s, "true")) || + (0 == g_strcasecmp(s, "on")) || + (0 == g_strcasecmp(s, "yes"))) { return 1; } return 0; } + +/*****************************************************************************/ +/* returns length of text */ +int +g_strlen(const char *text) +{ + if (text == NULL) + { + return 0; + } + + return strlen(text); +} + +/*****************************************************************************/ +/* locates char in text */ +const char * +g_strchr(const char *text, int c) +{ + if (text == NULL) + { + return 0; + } + + return strchr(text, c); +} + +/*****************************************************************************/ +/* returns dest */ +char * +g_strcpy(char *dest, const char *src) +{ + if (src == 0 && dest != 0) + { + dest[0] = 0; + return dest; + } + + if (dest == 0 || src == 0) + { + return 0; + } + + return strcpy(dest, src); +} + +/*****************************************************************************/ +/* returns dest */ +char * +g_strncpy(char *dest, const char *src, int len) +{ + char *rv; + + if (src == 0 && dest != 0) + { + dest[0] = 0; + return dest; + } + + if (dest == 0 || src == 0) + { + return 0; + } + + rv = strncpy(dest, src, len); + dest[len] = 0; + return rv; +} + +/*****************************************************************************/ +/* returns dest */ +char * +g_strcat(char *dest, const char *src) +{ + if (dest == 0 || src == 0) + { + return dest; + } + + return strcat(dest, src); +} + +/*****************************************************************************/ +/* returns dest */ +char * +g_strncat(char *dest, const char *src, int len) +{ + if (dest == 0 || src == 0) + { + return dest; + } + + return strncat(dest, src, len); +} + +/*****************************************************************************/ +/* if in = 0, return 0 else return newly alloced copy of in */ +char * +g_strdup(const char *in) +{ + int len; + char *p; + + if (in == 0) + { + return 0; + } + + len = g_strlen(in); + p = (char *)g_malloc(len + 1, 0); + + if (p != NULL) + { + g_strcpy(p, in); + } + + return p; +} + +/*****************************************************************************/ +/* if in = 0, return 0 else return newly alloced copy of input string + * if the input string is larger than maxlen the returned string will be + * truncated. All strings returned will include null termination*/ +char * +g_strndup(const char *in, const unsigned int maxlen) +{ + unsigned int len; + char *p; + + if (in == 0) + { + return 0; + } + + len = g_strlen(in); + + if (len > maxlen) + { + len = maxlen - 1; + } + + p = (char *)g_malloc(len + 2, 0); + + if (p != NULL) + { + g_strncpy(p, in, len + 1); + } + + return p; +} + +/*****************************************************************************/ +int +g_strcmp(const char *c1, const char *c2) +{ + return strcmp(c1, c2); +} + +/*****************************************************************************/ +int +g_strncmp(const char *c1, const char *c2, int len) +{ + return strncmp(c1, c2, len); +} + +/*****************************************************************************/ +/* compare up to delim */ +int +g_strncmp_d(const char *s1, const char *s2, const char delim, int n) +{ + char c1; + char c2; + + c1 = 0; + c2 = 0; + while (n > 0) + { + c1 = *(s1++); + c2 = *(s2++); + if ((c1 == 0) || (c1 != c2) || (c1 == delim) || (c2 == delim)) + { + return c1 - c2; + } + n--; + } + return c1 - c2; +} + +/*****************************************************************************/ +int +g_strcasecmp(const char *c1, const char *c2) +{ +#if defined(_WIN32) + return stricmp(c1, c2); +#else + return strcasecmp(c1, c2); +#endif +} + +/*****************************************************************************/ +int +g_strncasecmp(const char *c1, const char *c2, int len) +{ +#if defined(_WIN32) + return strnicmp(c1, c2, len); +#else + return strncasecmp(c1, c2, len); +#endif +} + +/*****************************************************************************/ +int +g_atoi(const char *str) +{ + if (str == 0) + { + return 0; + } + + return atoi(str); +} + +/*****************************************************************************/ +int +g_htoi(char *str) +{ + int len; + int index; + int rv; + int val; + int shift; + + rv = 0; + len = strlen(str); + index = len - 1; + shift = 0; + + while (index >= 0) + { + val = 0; + + switch (str[index]) + { + case '1': + val = 1; + break; + case '2': + val = 2; + break; + case '3': + val = 3; + break; + case '4': + val = 4; + break; + case '5': + val = 5; + break; + case '6': + val = 6; + break; + case '7': + val = 7; + break; + case '8': + val = 8; + break; + case '9': + val = 9; + break; + case 'a': + case 'A': + val = 10; + break; + case 'b': + case 'B': + val = 11; + break; + case 'c': + case 'C': + val = 12; + break; + case 'd': + case 'D': + val = 13; + break; + case 'e': + case 'E': + val = 14; + break; + case 'f': + case 'F': + val = 15; + break; + } + + rv = rv | (val << shift); + index--; + shift += 4; + } + + return rv; +} + +/*****************************************************************************/ +/* returns number of bytes copied into out_str */ +int +g_bytes_to_hexstr(const void *bytes, int num_bytes, char *out_str, + int bytes_out_str) +{ + int rv; + int index; + char *lout_str; + const tui8 *lbytes; + + rv = 0; + lbytes = (const tui8 *) bytes; + lout_str = out_str; + for (index = 0; index < num_bytes; index++) + { + if (bytes_out_str < 3) + { + break; + } + g_snprintf(lout_str, bytes_out_str, "%2.2x", lbytes[index]); + lout_str += 2; + bytes_out_str -= 2; + rv += 2; + } + return rv; +} + +/*****************************************************************************/ +int +g_pos(const char *str, const char *to_find) +{ + const char *pp; + + pp = strstr(str, to_find); + + if (pp == 0) + { + return -1; + } + + return (pp - str); +} + +/*****************************************************************************/ +int +g_mbstowcs(twchar *dest, const char *src, int n) +{ + wchar_t *ldest; + int rv; + + ldest = (wchar_t *)dest; + rv = mbstowcs(ldest, src, n); + return rv; +} + +/*****************************************************************************/ +int +g_wcstombs(char *dest, const twchar *src, int n) +{ + const wchar_t *lsrc; + int rv; + + lsrc = (const wchar_t *)src; + rv = wcstombs(dest, lsrc, n); + return rv; +} + +/*****************************************************************************/ +/* returns error */ +/* trim spaces and tabs, anything <= space */ +/* trim_flags 1 trim left, 2 trim right, 3 trim both, 4 trim through */ +/* this will always shorten the string or not change it */ +int +g_strtrim(char *str, int trim_flags) +{ + int index; + int len; + int text1_index; + int got_char; + wchar_t *text; + wchar_t *text1; + + len = mbstowcs(0, str, 0); + + if (len < 1) + { + return 0; + } + + if ((trim_flags < 1) || (trim_flags > 4)) + { + return 1; + } + + text = (wchar_t *)malloc(len * sizeof(wchar_t) + 8); + text1 = (wchar_t *)malloc(len * sizeof(wchar_t) + 8); + if (text == NULL || text1 == NULL) + { + free(text); + free(text1); + return 1; + } + text1_index = 0; + mbstowcs(text, str, len + 1); + + switch (trim_flags) + { + case 4: /* trim through */ + + for (index = 0; index < len; index++) + { + if (text[index] > 32) + { + text1[text1_index] = text[index]; + text1_index++; + } + } + + text1[text1_index] = 0; + break; + case 3: /* trim both */ + got_char = 0; + + for (index = 0; index < len; index++) + { + if (got_char) + { + text1[text1_index] = text[index]; + text1_index++; + } + else + { + if (text[index] > 32) + { + text1[text1_index] = text[index]; + text1_index++; + got_char = 1; + } + } + } + + text1[text1_index] = 0; + len = text1_index; + + /* trim right */ + for (index = len - 1; index >= 0; index--) + { + if (text1[index] > 32) + { + break; + } + } + + text1_index = index + 1; + text1[text1_index] = 0; + break; + case 2: /* trim right */ + + /* copy it */ + for (index = 0; index < len; index++) + { + text1[text1_index] = text[index]; + text1_index++; + } + + /* trim right */ + for (index = len - 1; index >= 0; index--) + { + if (text1[index] > 32) + { + break; + } + } + + text1_index = index + 1; + text1[text1_index] = 0; + break; + case 1: /* trim left */ + got_char = 0; + + for (index = 0; index < len; index++) + { + if (got_char) + { + text1[text1_index] = text[index]; + text1_index++; + } + else + { + if (text[index] > 32) + { + text1[text1_index] = text[index]; + text1_index++; + got_char = 1; + } + } + } + + text1[text1_index] = 0; + break; + } + + wcstombs(str, text1, text1_index + 1); + free(text); + free(text1); + return 0; +} + diff --git a/common/string_calls.h b/common/string_calls.h index 32aa62fd..cce332ac 100644 --- a/common/string_calls.h +++ b/common/string_calls.h @@ -21,6 +21,8 @@ #if !defined(STRING_CALLS_H) #define STRING_CALLS_H +#include "arch.h" + /** * Map a character to a string value * @@ -55,9 +57,9 @@ struct info_string_tag * the buffer length (as in snprintf()) */ unsigned int -g_format_info_string(char* dest, unsigned int len, - const char* format, - const struct info_string_tag map[]); +g_format_info_string(char *dest, unsigned int len, + const char *format, + const struct info_string_tag map[]); /** @@ -78,4 +80,25 @@ g_bool2text(int value); int g_text2bool(const char *s); +int g_strlen(const char *text); +const char *g_strchr(const char *text, int c); +char *g_strcpy(char *dest, const char *src); +char *g_strncpy(char *dest, const char *src, int len); +char *g_strcat(char *dest, const char *src); +char *g_strncat(char *dest, const char *src, int len); +char *g_strdup(const char *in); +char *g_strndup(const char *in, const unsigned int maxlen); +int g_strcmp(const char *c1, const char *c2); +int g_strncmp(const char *c1, const char *c2, int len); +int g_strncmp_d(const char *c1, const char *c2, const char delim, int len); +int g_strcasecmp(const char *c1, const char *c2); +int g_strncasecmp(const char *c1, const char *c2, int len); +int g_atoi(const char *str); +int g_htoi(char *str); +int g_bytes_to_hexstr(const void *bytes, int num_bytes, char *out_str, + int bytes_out_str); +int g_pos(const char *str, const char *to_find); +int g_mbstowcs(twchar *dest, const char *src, int n); +int g_wcstombs(char *dest, const twchar *src, int n); +int g_strtrim(char *str, int trim_flags); #endif diff --git a/common/trans.c b/common/trans.c index 6a0be5d4..c8820a54 100644 --- a/common/trans.c +++ b/common/trans.c @@ -23,6 +23,7 @@ #endif #include "os_calls.h" +#include "string_calls.h" #include "trans.h" #include "arch.h" #include "parse.h" diff --git a/keygen/keygen.c b/keygen/keygen.c index 74be4d6e..e1c1e95c 100644 --- a/keygen/keygen.c +++ b/keygen/keygen.c @@ -30,6 +30,7 @@ #endif #include "os_calls.h" +#include "string_calls.h" #include "ssl_calls.h" #include "arch.h" #include "list.h" diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c index fd3615b0..14edb29e 100644 --- a/libxrdp/libxrdp.c +++ b/libxrdp/libxrdp.c @@ -23,6 +23,7 @@ #endif #include "libxrdp.h" +#include "string_calls.h" #include "xrdp_orders_rail.h" #include "ms-rdpbcgr.h" diff --git a/libxrdp/xrdp_channel.c b/libxrdp/xrdp_channel.c index 125ac085..8e8a25ed 100644 --- a/libxrdp/xrdp_channel.c +++ b/libxrdp/xrdp_channel.c @@ -23,6 +23,7 @@ #endif #include "libxrdp.h" +#include "string_calls.h" /* todo, move these to constants.h */ //#define CHANNEL_CHUNK_LENGTH 1600 /* todo, why is this so small? */ diff --git a/libxrdp/xrdp_orders_rail.c b/libxrdp/xrdp_orders_rail.c index 26dab686..735b92e1 100644 --- a/libxrdp/xrdp_orders_rail.c +++ b/libxrdp/xrdp_orders_rail.c @@ -23,6 +23,7 @@ #include "libxrdp.h" #include "ms-rdpegdi.h" #include "xrdp_rail.h" +#include "string_calls.h" /* [MS-RDPERP]: Remote Desktop Protocol: Remote Programs Virtual Channel Extension diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c index 7317c639..f912ac1d 100644 --- a/libxrdp/xrdp_sec.c +++ b/libxrdp/xrdp_sec.c @@ -25,6 +25,7 @@ #include "libxrdp.h" #include "ms-rdpbcgr.h" #include "log.h" +#include "string_calls.h" #define LOG_LEVEL 1 #define LLOG(_level, _args) \ diff --git a/sesman/access.c b/sesman/access.c index b54378b9..4b8489aa 100644 --- a/sesman/access.c +++ b/sesman/access.c @@ -29,6 +29,7 @@ #endif #include "sesman.h" +#include "string_calls.h" extern struct config_sesman *g_cfg; /* in sesman.c */ diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index abd66f77..4bca525e 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -23,6 +23,7 @@ #include "arch.h" #include "os_calls.h" +#include "string_calls.h" #include "thread_calls.h" #include "trans.h" #include "chansrv.h" diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index e617f966..04382092 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -169,6 +169,7 @@ x-special/gnome-copied-files #include "arch.h" #include "parse.h" #include "os_calls.h" +#include "string_calls.h" #include "chansrv.h" #include "chansrv_config.h" #include "clipboard.h" diff --git a/sesman/chansrv/clipboard_file.c b/sesman/chansrv/clipboard_file.c index 29f16b03..13a4c7c4 100644 --- a/sesman/chansrv/clipboard_file.c +++ b/sesman/chansrv/clipboard_file.c @@ -33,6 +33,7 @@ #include "arch.h" #include "parse.h" #include "os_calls.h" +#include "string_calls.h" #include "list.h" #include "chansrv.h" #include "clipboard.h" diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index 4b56d534..1dbf3975 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -49,6 +49,7 @@ #include "arch.h" #include "parse.h" #include "os_calls.h" +#include "string_calls.h" #include "log.h" #include "chansrv.h" #include "chansrv_fuse.h" diff --git a/sesman/chansrv/irp.c b/sesman/chansrv/irp.c index 989d8a96..a1bf9a4d 100644 --- a/sesman/chansrv/irp.c +++ b/sesman/chansrv/irp.c @@ -28,6 +28,7 @@ #include "chansrv.h" #include "parse.h" #include "os_calls.h" +#include "string_calls.h" #include "irp.h" IRP *g_irp_head = NULL; diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index 341d492b..ad074dab 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -39,6 +39,7 @@ #include "xcommon.h" #include "log.h" #include "os_calls.h" +#include "string_calls.h" #include "thread_calls.h" #include "list.h" diff --git a/sesman/chansrv/smartcard.c b/sesman/chansrv/smartcard.c index 061f407f..69e639e9 100644 --- a/sesman/chansrv/smartcard.c +++ b/sesman/chansrv/smartcard.c @@ -28,6 +28,7 @@ #include #include "os_calls.h" +#include "string_calls.h" #include "smartcard.h" #include "log.h" #include "irp.h" diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index 2ec14f05..7eb20712 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -33,6 +33,7 @@ #define PCSC_STANDIN 1 #include "os_calls.h" +#include "string_calls.h" #include "smartcard.h" #include "log.h" #include "irp.h" diff --git a/sesman/env.c b/sesman/env.c index 4b786f22..6cb711c0 100644 --- a/sesman/env.c +++ b/sesman/env.c @@ -34,6 +34,7 @@ #include "list.h" #include "sesman.h" #include "ssl_calls.h" +#include "string_calls.h" extern unsigned char g_fixedkey[8]; /* in sesman.c */ extern struct config_sesman *g_cfg; /* in sesman.c */ diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c index ddb2eb3e..99629f31 100644 --- a/sesman/libscp/libscp_session.c +++ b/sesman/libscp/libscp_session.c @@ -29,6 +29,7 @@ #endif #include "libscp_session.h" +#include "string_calls.h" #include #include diff --git a/sesman/libscp/libscp_v0.c b/sesman/libscp/libscp_v0.c index e1327ad2..7b9ce548 100644 --- a/sesman/libscp/libscp_v0.c +++ b/sesman/libscp/libscp_v0.c @@ -31,6 +31,7 @@ #include "libscp_v0.h" #include "os_calls.h" +#include "string_calls.h" extern struct log_config *s_log; diff --git a/sesman/libscp/libscp_v1c.c b/sesman/libscp/libscp_v1c.c index 93239176..95d21382 100644 --- a/sesman/libscp/libscp_v1c.c +++ b/sesman/libscp/libscp_v1c.c @@ -29,6 +29,7 @@ #endif #include "libscp_v1c.h" +#include "string_calls.h" #include #include diff --git a/sesman/libscp/libscp_v1c_mng.c b/sesman/libscp/libscp_v1c_mng.c index 368f249a..d528d37a 100644 --- a/sesman/libscp/libscp_v1c_mng.c +++ b/sesman/libscp/libscp_v1c_mng.c @@ -29,6 +29,7 @@ #endif #include "libscp_v1c_mng.h" +#include "string_calls.h" #include #include diff --git a/sesman/libscp/libscp_v1s.c b/sesman/libscp/libscp_v1s.c index 2465a0f2..e2cf558b 100644 --- a/sesman/libscp/libscp_v1s.c +++ b/sesman/libscp/libscp_v1s.c @@ -32,6 +32,7 @@ #define LIBSCP_V1S_C #include "libscp_v1s.h" +#include "string_calls.h" //extern struct log_config* s_log; diff --git a/sesman/libscp/libscp_v1s_mng.c b/sesman/libscp/libscp_v1s_mng.c index df104bba..7f6e3576 100644 --- a/sesman/libscp/libscp_v1s_mng.c +++ b/sesman/libscp/libscp_v1s_mng.c @@ -32,6 +32,7 @@ #define LIBSCP_V1S_MNG_C #include "libscp_v1s_mng.h" +#include "string_calls.h" //extern struct log_config* s_log; diff --git a/sesman/sesman.c b/sesman/sesman.c index 6713de67..88ed884f 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -32,6 +32,7 @@ #include "sesman.h" #include "xrdp_configure_options.h" +#include "string_calls.h" struct sesman_startup_params { diff --git a/sesman/session.c b/sesman/session.c index f2a54c19..6ea772e2 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -41,6 +41,7 @@ #include "libscp_types.h" #include "xauth.h" #include "xrdp_sockets.h" +#include "string_calls.h" #ifndef PR_SET_NO_NEW_PRIVS #define PR_SET_NO_NEW_PRIVS 38 diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c index bd5144a3..b8949301 100644 --- a/sesman/tools/sesadmin.c +++ b/sesman/tools/sesadmin.c @@ -27,6 +27,7 @@ #include "parse.h" #include "log.h" #include "libscp.h" +#include "string_calls.h" #include #include diff --git a/sesman/tools/sesrun.c b/sesman/tools/sesrun.c index 59f3e42a..3b8ca595 100644 --- a/sesman/tools/sesrun.c +++ b/sesman/tools/sesrun.c @@ -37,6 +37,7 @@ #include "config.h" #include "log.h" #include "tcp.h" +#include "string_calls.h" #if !defined(PACKAGE_VERSION) #define PACKAGE_VERSION "???" diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c index d67b1a49..9d9d45af 100644 --- a/sesman/tools/sestest.c +++ b/sesman/tools/sestest.c @@ -26,6 +26,7 @@ #include "libscp.h" #include "parse.h" #include "log.h" +#include "string_calls.h" #include diff --git a/sesman/verify_user_pam.c b/sesman/verify_user_pam.c index 2ded2660..3fbb9279 100644 --- a/sesman/verify_user_pam.c +++ b/sesman/verify_user_pam.c @@ -30,6 +30,7 @@ #include "arch.h" #include "os_calls.h" +#include "string_calls.h" #include #include diff --git a/sesman/xauth.c b/sesman/xauth.c index 8dcff3d9..a7e788bf 100644 --- a/sesman/xauth.c +++ b/sesman/xauth.c @@ -30,6 +30,7 @@ #include #include "log.h" #include "os_calls.h" +#include "string_calls.h" /******************************************************************************/ diff --git a/vnc/vnc.c b/vnc/vnc.c index 42e7f4c1..68532e91 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -34,6 +34,7 @@ #include "log.h" #include "trans.h" #include "ssl_calls.h" +#include "string_calls.h" #include "xrdp_client_info.h" #define LLOG_LEVEL 1 diff --git a/xrdp/funcs.c b/xrdp/funcs.c index d22927ac..02b10e84 100644 --- a/xrdp/funcs.c +++ b/xrdp/funcs.c @@ -23,6 +23,7 @@ #endif #include "xrdp.h" +#include "string_calls.h" /*****************************************************************************/ /* returns boolean */ diff --git a/xrdp/lang.c b/xrdp/lang.c index 723883a1..bed1edbb 100644 --- a/xrdp/lang.c +++ b/xrdp/lang.c @@ -26,6 +26,7 @@ #include "xrdp.h" #include "ms-rdpbcgr.h" #include "log.h" +#include "string_calls.h" /* map for rdp to x11 scancodes code1 is regular scancode, code2 is extended scancode */ diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index 3460f313..d9eb30bc 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -27,6 +27,7 @@ #include "xrdp.h" #include "log.h" #include "xrdp_configure_options.h" +#include "string_calls.h" #if !defined(PACKAGE_VERSION) #define PACKAGE_VERSION "???" diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c index 627f73c7..109b1e50 100644 --- a/xrdp/xrdp_bitmap.c +++ b/xrdp/xrdp_bitmap.c @@ -29,6 +29,7 @@ #include "xrdp.h" #include "log.h" +#include "string_calls.h" #define LLOG_LEVEL 1 #define LLOGLN(_level, _args) \ diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c index 97ae5cc3..6a37c214 100644 --- a/xrdp/xrdp_painter.c +++ b/xrdp/xrdp_painter.c @@ -23,6 +23,7 @@ #endif #include "xrdp.h" +#include "string_calls.h" #if defined(XRDP_PAINTER) #include /* libpainter */ diff --git a/xup/xup.c b/xup/xup.c index 81d4c732..2f257508 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -25,6 +25,7 @@ #include "xup.h" #include "log.h" #include "trans.h" +#include "string_calls.h" #define LOG_LEVEL 1 #define LLOG(_level, _args) \