From 4f45b4c06585fab6e7123ef88ec7bda9288f5d46 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Fri, 8 Nov 2013 11:21:23 -0800 Subject: added define for common types --- common/arch.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common') diff --git a/common/arch.h b/common/arch.h index 6a29b0a9..fe5736db 100644 --- a/common/arch.h +++ b/common/arch.h @@ -62,6 +62,8 @@ #define EXPORT_CC #endif +#ifndef DEFINED_Ts +#define DEFINED_Ts typedef char ti8; typedef unsigned char tui8; typedef signed char tsi8; @@ -94,5 +96,6 @@ typedef int tsock; typedef unsigned long long tui64; typedef signed long long tsi64; #endif +#endif #endif -- cgit v1.2.1 From f221258610b9a7377c30c3c9e5b0f3a04ac255ae Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Wed, 20 Nov 2013 22:28:47 -0800 Subject: common: add unknown arch check --- common/arch.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'common') diff --git a/common/arch.h b/common/arch.h index fe5736db..988153c2 100644 --- a/common/arch.h +++ b/common/arch.h @@ -32,6 +32,12 @@ defined(__AIX__) || defined(__PPC__) || defined(__mips__) || \ defined(__ia64__) || defined(__ppc__) || defined(__arm__) #define NEED_ALIGN +#elif defined(__x86__) || defined(__x86_64__) || \ + defined(__AMD64__) || defined(_M_IX86) || \ + defined(__i386__) +#define NO_NEED_ALIGN +#else +#warning unknown arch #endif #endif -- cgit v1.2.1 From 1deac46fdcad0c9e5d9b063350fdc0e5617855cc Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Wed, 4 Dec 2013 15:26:23 -0800 Subject: common: add trans_get_wait_objs_rw to header --- common/trans.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'common') diff --git a/common/trans.h b/common/trans.h index 350f05cc..31c90721 100644 --- a/common/trans.h +++ b/common/trans.h @@ -66,6 +66,10 @@ trans_delete(struct trans* self); int APP_CC trans_get_wait_objs(struct trans* self, tbus* objs, int* count); int APP_CC +trans_get_wait_objs_rw(struct trans *self, + tbus *robjs, int *rcount, + tbus *wobjs, int *wcount); +int APP_CC trans_check_wait_objs(struct trans* self); int APP_CC trans_force_read_s(struct trans* self, struct stream* in_s, int size); -- cgit v1.2.1 From 3c218ad3f2e4bdfbaab0303d7edfa3106bfed46f Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Wed, 4 Dec 2013 15:27:49 -0800 Subject: common: try to send data in trans_write_copy --- common/trans.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common') diff --git a/common/trans.c b/common/trans.c index bb349298..c418877e 100644 --- a/common/trans.c +++ b/common/trans.c @@ -471,6 +471,15 @@ trans_write_copy(struct trans *self) } temp_s->next_packet = (char *) wait_s; } + + /* try to send */ + if (send_waiting(self, 0) != 0) + { + /* error */ + self->status = TRANS_STATUS_DOWN; + return 1; + } + return 0; } -- cgit v1.2.1 From ff12a1d7990cdd7460012b036797e1a872abfb45 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Fri, 10 Jan 2014 21:55:15 -0800 Subject: added tbool --- common/arch.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/arch.h b/common/arch.h index 988153c2..b4eb4719 100644 --- a/common/arch.h +++ b/common/arch.h @@ -79,6 +79,7 @@ typedef signed short tsi16; typedef int ti32; typedef unsigned int tui32; typedef signed int tsi32; +typedef int tbool; #if defined(_WIN64) /* Microsoft's VC++ compiler uses the more backwards-compatible LLP64 model. Most other 64 bit compilers(Solaris, AIX, HP, Linux, Mac OS X) use @@ -102,6 +103,6 @@ typedef int tsock; typedef unsigned long long tui64; typedef signed long long tsi64; #endif -#endif +#endif /* DEFINED_Ts */ #endif -- cgit v1.2.1 From 02aa39c79d533cf6d5932363913ddad277f0e8ed Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sun, 12 Jan 2014 18:24:07 -0800 Subject: added keyboard type and subtype to struct xrdp_client_info --- common/xrdp_client_info.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common') diff --git a/common/xrdp_client_info.h b/common/xrdp_client_info.h index acd145e6..1d7242bd 100644 --- a/common/xrdp_client_info.h +++ b/common/xrdp_client_info.h @@ -110,6 +110,9 @@ struct xrdp_client_info int multimon; /* 0 = deny , 1 = allow */ int monitorCount; /* number of monitors detected (max = 16) */ struct monitor_info minfo[16]; /* client monitor data */ + + int keyboard_type; + int keyboard_subtype; }; #endif -- cgit v1.2.1 From 48228cae2eaa0847b07f899811dd7f0ab8a7365e Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Tue, 28 Jan 2014 10:38:36 -0800 Subject: common: added shm to os_calls --- common/os_calls.c | 16 ++++++++++++++++ common/os_calls.h | 2 ++ 2 files changed, 18 insertions(+) (limited to 'common') diff --git a/common/os_calls.c b/common/os_calls.c index 2d5b4280..bb26d246 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include #include #include @@ -3118,3 +3120,17 @@ g_text2bool(const char *s) } return 0; } + +/*****************************************************************************/ +void * APP_CC +g_shmat(int shmid) +{ + return shmat(shmid, 0, 0); +} + +/*****************************************************************************/ +int APP_CC +g_shmdt(const void *shmaddr) +{ + return shmdt(shmaddr); +} diff --git a/common/os_calls.h b/common/os_calls.h index b6e1c91a..2bee6077 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -161,5 +161,7 @@ int APP_CC g_time1(void); int APP_CC g_time2(void); int APP_CC g_time3(void); int APP_CC g_text2bool(const char *s); +void * APP_CC g_shmat(int shmid); +int APP_CC g_shmdt(const void *shmaddr); #endif -- cgit v1.2.1 From 4e6d57dbe5cf231648425c686265ecc9bb8c5b7b Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 8 Feb 2014 18:05:52 -0800 Subject: common: some notes and compile fixes --- common/os_calls.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/os_calls.c b/common/os_calls.c index bb26d246..ee9792b1 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -1,7 +1,7 @@ /** * xrdp: A Remote Desktop Protocol server. * - * Copyright (C) Jay Sorg 2004-2013 + * Copyright (C) Jay Sorg 2004-2014 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,11 @@ * put all the os / arch define in here you want */ +/* To test for Windows (64 bit or 32 bit) use _WIN32 and _WIN64 in addition + for 64 bit windows. _WIN32 is defined for both. + To test for Linux use __linux__. + To test for BSD use BSD */ + #if defined(HAVE_CONFIG_H) #include "config_ac.h" #endif @@ -60,6 +65,13 @@ #include #include +/* this is so we can use #ifdef BSD later */ +/* This is the recommended way of detecting BSD in the + FreeBSD Porter's Handbook. */ +#if (defined(__unix__) || defined(unix)) && !defined(USG) +#include +#endif + #include "os_calls.h" #include "arch.h" #include "log.h" @@ -596,9 +608,11 @@ g_tcp_local_socket(void) } /*****************************************************************************/ +/* returns error */ int APP_CC g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) { +#if defined(SO_PEERCRED) int ucred_length; struct myucred { @@ -625,6 +639,9 @@ g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) *gid = credentials.gid; } return 0; +#else + return 1; +#endif } /*****************************************************************************/ @@ -3122,15 +3139,25 @@ g_text2bool(const char *s) } /*****************************************************************************/ +/* returns pointer or nil on error */ void * APP_CC g_shmat(int shmid) { - return shmat(shmid, 0, 0); +#if defined(_WIN32) + return 0; +#else + return shmat(shmid, 0, 0); +#endif } /*****************************************************************************/ +/* returns -1 on error */ int APP_CC g_shmdt(const void *shmaddr) { +#if defined(_WIN32) + return -1; +#else return shmdt(shmaddr); +#endif } -- cgit v1.2.1 From 43e388b7e5e6bea5c79a462afc24edbf91de91fd Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 8 Feb 2014 21:48:44 -0800 Subject: remove some warning, move gethostname to os_calls --- common/os_calls.c | 14 +++++++++++++- common/os_calls.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/os_calls.c b/common/os_calls.c index ee9792b1..80b2d235 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -613,7 +613,11 @@ int APP_CC g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) { #if defined(SO_PEERCRED) +#if defined(_WIN32) int ucred_length; +#else + unsigned int ucred_length; +#endif struct myucred { pid_t pid; @@ -3151,7 +3155,7 @@ g_shmat(int shmid) } /*****************************************************************************/ -/* returns -1 on error */ +/* returns -1 on error 0 on success */ int APP_CC g_shmdt(const void *shmaddr) { @@ -3161,3 +3165,11 @@ g_shmdt(const void *shmaddr) return shmdt(shmaddr); #endif } + +/*****************************************************************************/ +/* returns -1 on error 0 on success */ +int APP_CC +g_gethostname(char *name, int len) +{ + return gethostname(name, len); +} diff --git a/common/os_calls.h b/common/os_calls.h index 2bee6077..06ce8494 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -163,5 +163,6 @@ int APP_CC g_time3(void); int APP_CC g_text2bool(const char *s); void * APP_CC g_shmat(int shmid); int APP_CC g_shmdt(const void *shmaddr); +int APP_CC g_gethostname(char *name, int len); #endif -- cgit v1.2.1 From b0a18321864ad8dc3f2308d2c920f85e2500f5d1 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Tue, 18 Feb 2014 10:28:20 -0800 Subject: common: update client_info struct --- common/xrdp_client_info.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'common') diff --git a/common/xrdp_client_info.h b/common/xrdp_client_info.h index 1d7242bd..50c9f143 100644 --- a/common/xrdp_client_info.h +++ b/common/xrdp_client_info.h @@ -113,6 +113,14 @@ struct xrdp_client_info int keyboard_type; int keyboard_subtype; + + int png_codec_id; + int png_prop_len; + char png_prop[64]; + int vendor_flags[4]; + int mcs_connection_type; + int mcs_early_capability_flags; + }; #endif -- cgit v1.2.1 From 926cd095fc01cadd4fd139b55df6f0c139207a01 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Thu, 20 Feb 2014 23:15:24 -0800 Subject: common: added des3 calls for fips --- common/ssl_calls.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++- common/ssl_calls.h | 12 ++++++++- 2 files changed, 89 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/ssl_calls.c b/common/ssl_calls.c index 4cb706f3..0c7e3f0d 100644 --- a/common/ssl_calls.c +++ b/common/ssl_calls.c @@ -1,7 +1,7 @@ /** * xrdp: A Remote Desktop Protocol server. * - * Copyright (C) Jay Sorg 2004-2012 + * Copyright (C) Jay Sorg 2004-2014 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -157,6 +158,82 @@ ssl_md5_complete(void *md5_info, char *data) MD5_Final((tui8 *)data, (MD5_CTX *)md5_info); } +/*****************************************************************************/ +void *APP_CC +ssl_des3_encrypt_info_create(const char *key, const char* ivec) +{ + EVP_CIPHER_CTX *des3_ctx; + const tui8 *lkey; + const tui8 *livec; + + des3_ctx = (EVP_CIPHER_CTX *) g_malloc(sizeof(EVP_CIPHER_CTX), 1); + EVP_CIPHER_CTX_init(des3_ctx); + lkey = (const tui8 *) key; + livec = (const tui8 *) ivec; + EVP_EncryptInit_ex(des3_ctx, EVP_des_ede3_cbc(), NULL, lkey, livec); + EVP_CIPHER_CTX_set_padding(des3_ctx, 0); + return des3_ctx; +} + +/*****************************************************************************/ +void *APP_CC +ssl_des3_decrypt_info_create(const char *key, const char* ivec) +{ + EVP_CIPHER_CTX *des3_ctx; + const tui8 *lkey; + const tui8 *livec; + + des3_ctx = g_malloc(sizeof(EVP_CIPHER_CTX), 1); + EVP_CIPHER_CTX_init(des3_ctx); + lkey = (const tui8 *) key; + livec = (const tui8 *) ivec; + EVP_DecryptInit_ex(des3_ctx, EVP_des_ede3_cbc(), NULL, lkey, livec); + EVP_CIPHER_CTX_set_padding(des3_ctx, 0); + return des3_ctx; +} + +/*****************************************************************************/ +void APP_CC +ssl_des3_info_delete(void *des3) +{ + EVP_CIPHER_CTX *des3_ctx; + + des3_ctx = (EVP_CIPHER_CTX *) des3; + EVP_CIPHER_CTX_cleanup(des3_ctx); +} + +/*****************************************************************************/ +int APP_CC +ssl_des3_encrypt(void *des3, int length, const char *in_data, char *out_data) +{ + EVP_CIPHER_CTX *des3_ctx; + int len; + const tui8 *lin_data; + tui8 *lout_data; + + des3_ctx = (EVP_CIPHER_CTX *) des3; + lin_data = (const tui8 *) in_data; + lout_data = (tui8 *) out_data; + EVP_EncryptUpdate(des3_ctx, lout_data, &len, lin_data, length); + return 0; +} + +/*****************************************************************************/ +int APP_CC +ssl_des3_decrypt(void *des3, int length, const char *in_data, char *out_data) +{ + EVP_CIPHER_CTX *des3_ctx; + int len; + const tui8 *lin_data; + tui8 *lout_data; + + des3_ctx = (EVP_CIPHER_CTX *) des3; + lin_data = (const tui8 *) in_data; + lout_data = (tui8 *) out_data; + EVP_DecryptUpdate(des3_ctx, lout_data, &len, lin_data, length); + return 0; +} + /*****************************************************************************/ static void APP_CC ssl_reverse_it(char *p, int len) diff --git a/common/ssl_calls.h b/common/ssl_calls.h index 3b59537a..ab29675c 100644 --- a/common/ssl_calls.h +++ b/common/ssl_calls.h @@ -1,7 +1,7 @@ /** * xrdp: A Remote Desktop Protocol server. * - * Copyright (C) Jay Sorg 2004-2013 + * Copyright (C) Jay Sorg 2004-2014 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,16 @@ void APP_CC ssl_md5_transform(void* md5_info, char* data, int len); void APP_CC ssl_md5_complete(void* md5_info, char* data); +void *APP_CC +ssl_des3_encrypt_info_create(const char *key, const char* ivec); +void *APP_CC +ssl_des3_decrypt_info_create(const char *key, const char* ivec); +void APP_CC +ssl_des3_info_delete(void *des3); +int APP_CC +ssl_des3_encrypt(void *des3, int length, const char *in_data, char *out_data); +int APP_CC +ssl_des3_decrypt(void *des3, int length, const char *in_data, char *out_data); int APP_CC ssl_mod_exp(char* out, int out_len, char* in, int in_len, char* mod, int mod_len, char* exp, int exp_len); -- cgit v1.2.1 From 2921400083fc4fe873c483c99326daec398c68fe Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sun, 23 Feb 2014 12:27:41 -0800 Subject: common: check for nil in fips cleanup --- common/ssl_calls.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/ssl_calls.c b/common/ssl_calls.c index 0c7e3f0d..92569be5 100644 --- a/common/ssl_calls.c +++ b/common/ssl_calls.c @@ -199,7 +199,10 @@ ssl_des3_info_delete(void *des3) EVP_CIPHER_CTX *des3_ctx; des3_ctx = (EVP_CIPHER_CTX *) des3; - EVP_CIPHER_CTX_cleanup(des3_ctx); + if (des3_ctx != 0) + { + EVP_CIPHER_CTX_cleanup(des3_ctx); + } } /*****************************************************************************/ -- cgit v1.2.1 From 25ad4d8a36b35277e7547484eb4ffe7fc4c1a698 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sun, 23 Feb 2014 20:40:13 -0800 Subject: common: add more fips ssl calls --- common/ssl_calls.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/ssl_calls.h | 10 +++++++++ 2 files changed, 76 insertions(+) (limited to 'common') diff --git a/common/ssl_calls.c b/common/ssl_calls.c index 92569be5..a187edc9 100644 --- a/common/ssl_calls.c +++ b/common/ssl_calls.c @@ -158,6 +158,8 @@ ssl_md5_complete(void *md5_info, char *data) MD5_Final((tui8 *)data, (MD5_CTX *)md5_info); } +/* FIPS stuff */ + /*****************************************************************************/ void *APP_CC ssl_des3_encrypt_info_create(const char *key, const char* ivec) @@ -202,6 +204,7 @@ ssl_des3_info_delete(void *des3) if (des3_ctx != 0) { EVP_CIPHER_CTX_cleanup(des3_ctx); + g_free(des3_ctx); } } @@ -217,6 +220,7 @@ ssl_des3_encrypt(void *des3, int length, const char *in_data, char *out_data) des3_ctx = (EVP_CIPHER_CTX *) des3; lin_data = (const tui8 *) in_data; lout_data = (tui8 *) out_data; + len = 0; EVP_EncryptUpdate(des3_ctx, lout_data, &len, lin_data, length); return 0; } @@ -233,10 +237,72 @@ ssl_des3_decrypt(void *des3, int length, const char *in_data, char *out_data) des3_ctx = (EVP_CIPHER_CTX *) des3; lin_data = (const tui8 *) in_data; lout_data = (tui8 *) out_data; + len = 0; EVP_DecryptUpdate(des3_ctx, lout_data, &len, lin_data, length); return 0; } +/*****************************************************************************/ +void * APP_CC +ssl_hmac_info_create(void) +{ + HMAC_CTX *hmac_ctx; + + hmac_ctx = (HMAC_CTX *) g_malloc(sizeof(HMAC_CTX), 1); + HMAC_CTX_init(hmac_ctx); + return hmac_ctx; +} + +/*****************************************************************************/ +void APP_CC +ssl_hmac_info_delete(void *hmac) +{ + HMAC_CTX *hmac_ctx; + + hmac_ctx = (HMAC_CTX *) hmac; + if (hmac_ctx != 0) + { + HMAC_CTX_cleanup(hmac_ctx); + g_free(hmac_ctx); + } +} + +/*****************************************************************************/ +void APP_CC +ssl_hmac_sha1_init(void *hmac, const char *data, int len) +{ + HMAC_CTX *hmac_ctx; + + hmac_ctx = (HMAC_CTX *) hmac; + HMAC_Init_ex(hmac_ctx, data, len, EVP_sha1(), NULL); +} + +/*****************************************************************************/ +void APP_CC +ssl_hmac_transform(void *hmac, const char *data, int len) +{ + HMAC_CTX *hmac_ctx; + const tui8 *ldata; + + hmac_ctx = (HMAC_CTX *) hmac; + ldata = (const tui8*) data; + HMAC_Update(hmac_ctx, ldata, len); +} + +/*****************************************************************************/ +void APP_CC +ssl_hmac_complete(void *hmac, char *data, int len) +{ + HMAC_CTX *hmac_ctx; + tui8* ldata; + tui32 llen; + + hmac_ctx = (HMAC_CTX *) hmac; + ldata = (tui8 *) data; + llen = len; + HMAC_Final(hmac_ctx, ldata, &llen); +} + /*****************************************************************************/ static void APP_CC ssl_reverse_it(char *p, int len) diff --git a/common/ssl_calls.h b/common/ssl_calls.h index ab29675c..40acfb5b 100644 --- a/common/ssl_calls.h +++ b/common/ssl_calls.h @@ -63,6 +63,16 @@ int APP_CC ssl_des3_encrypt(void *des3, int length, const char *in_data, char *out_data); int APP_CC ssl_des3_decrypt(void *des3, int length, const char *in_data, char *out_data); +void * APP_CC +ssl_hmac_info_create(void); +void APP_CC +ssl_hmac_info_delete(void *hmac); +void APP_CC +ssl_hmac_sha1_init(void *hmac, const char *data, int len); +void APP_CC +ssl_hmac_transform(void *hmac, const char *data, int len); +void APP_CC +ssl_hmac_complete(void *hmac, char *data, int len); int APP_CC ssl_mod_exp(char* out, int out_len, char* in, int in_len, char* mod, int mod_len, char* exp, int exp_len); -- cgit v1.2.1 From f6fb5a32ed0ccc341eae749abd5b44cd2a73903c Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Tue, 25 Feb 2014 20:33:19 -0800 Subject: common: added some trans options used in fast path --- common/trans.c | 5 ++++- common/trans.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/trans.c b/common/trans.c index c418877e..aced0667 100644 --- a/common/trans.c +++ b/common/trans.c @@ -282,7 +282,10 @@ trans_check_wait_objs(struct trans *self) if (self->trans_data_in != 0) { rv = self->trans_data_in(self); - init_stream(self->in_s, 0); + if (self->no_stream_init_on_data_in == 0) + { + init_stream(self->in_s, 0); + } } } } diff --git a/common/trans.h b/common/trans.h index 31c90721..c2e5e0df 100644 --- a/common/trans.h +++ b/common/trans.h @@ -57,6 +57,8 @@ struct trans struct stream* wait_s; char addr[256]; char port[256]; + int no_stream_init_on_data_in; + int extra_flags; /* user defined */ }; struct trans* APP_CC -- cgit v1.2.1