diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2014-03-09 20:35:37 -0700 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2014-03-09 20:35:37 -0700 |
commit | 5384e241f1e0d225c9439236ab3ba9364ad5b583 (patch) | |
tree | 9ef1ec0201a7a94f6b7bcde6876b1f68d8b2e52f /common | |
parent | ef00f6653b47d92466412bb6a821c4d713b19e22 (diff) | |
parent | 0a2b3a2fd7e1e55cbc9afc2b26f5be5e63c511c0 (diff) | |
download | xrdp-proprietary-5384e241f1e0d225c9439236ab3ba9364ad5b583.tar.gz xrdp-proprietary-5384e241f1e0d225c9439236ab3ba9364ad5b583.zip |
Merge branch 'master' of github.com:neutrinolabs/xrdp
Diffstat (limited to 'common')
-rw-r--r-- | common/arch.h | 10 | ||||
-rw-r--r-- | common/os_calls.c | 57 | ||||
-rw-r--r-- | common/os_calls.h | 3 | ||||
-rw-r--r-- | common/ssl_calls.c | 148 | ||||
-rw-r--r-- | common/ssl_calls.h | 22 | ||||
-rw-r--r-- | common/trans.c | 14 | ||||
-rw-r--r-- | common/trans.h | 6 | ||||
-rw-r--r-- | common/xrdp_client_info.h | 11 |
8 files changed, 267 insertions, 4 deletions
diff --git a/common/arch.h b/common/arch.h index 6a29b0a9..b4eb4719 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 @@ -62,6 +68,8 @@ #define EXPORT_CC #endif +#ifndef DEFINED_Ts +#define DEFINED_Ts typedef char ti8; typedef unsigned char tui8; typedef signed char tsi8; @@ -71,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 @@ -94,5 +103,6 @@ typedef int tsock; typedef unsigned long long tui64; typedef signed long long tsi64; #endif +#endif /* DEFINED_Ts */ #endif diff --git a/common/os_calls.c b/common/os_calls.c index 2d5b4280..80b2d235 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 @@ -42,6 +47,8 @@ #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> +#include <sys/ipc.h> +#include <sys/shm.h> #include <dlfcn.h> #include <arpa/inet.h> #include <netdb.h> @@ -58,6 +65,13 @@ #include <stdio.h> #include <locale.h> +/* 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 <sys/param.h> +#endif + #include "os_calls.h" #include "arch.h" #include "log.h" @@ -594,10 +608,16 @@ 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) +#if defined(_WIN32) int ucred_length; +#else + unsigned int ucred_length; +#endif struct myucred { pid_t pid; @@ -623,6 +643,9 @@ g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) *gid = credentials.gid; } return 0; +#else + return 1; +#endif } /*****************************************************************************/ @@ -3118,3 +3141,35 @@ g_text2bool(const char *s) } return 0; } + +/*****************************************************************************/ +/* returns pointer or nil on error */ +void * APP_CC +g_shmat(int shmid) +{ +#if defined(_WIN32) + return 0; +#else + return shmat(shmid, 0, 0); +#endif +} + +/*****************************************************************************/ +/* returns -1 on error 0 on success */ +int APP_CC +g_shmdt(const void *shmaddr) +{ +#if defined(_WIN32) + return -1; +#else + 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 b6e1c91a..06ce8494 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -161,5 +161,8 @@ 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); +int APP_CC g_gethostname(char *name, int len); #endif diff --git a/common/ssl_calls.c b/common/ssl_calls.c index 4cb706f3..a187edc9 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 <openssl/rc4.h> #include <openssl/md5.h> #include <openssl/sha.h> +#include <openssl/hmac.h> #include <openssl/bn.h> #include <openssl/rsa.h> @@ -157,6 +158,151 @@ 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) +{ + 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; + if (des3_ctx != 0) + { + EVP_CIPHER_CTX_cleanup(des3_ctx); + g_free(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; + len = 0; + 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; + 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 3b59537a..40acfb5b 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,26 @@ 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); +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); diff --git a/common/trans.c b/common/trans.c index bb349298..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); + } } } } @@ -471,6 +474,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; } diff --git a/common/trans.h b/common/trans.h index 350f05cc..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 @@ -66,6 +68,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); diff --git a/common/xrdp_client_info.h b/common/xrdp_client_info.h index acd145e6..50c9f143 100644 --- a/common/xrdp_client_info.h +++ b/common/xrdp_client_info.h @@ -110,6 +110,17 @@ 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; + + 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 |