Removed dependency from ma_global.h

Closes #2959
pull/2993/head
Rene Cannao 6 years ago committed by René Cannaò
parent f188821e46
commit df5bf138e4

@ -50,10 +50,6 @@
#include <sys/ioctl.h>
#if !defined(__FreeBSD__) && !defined(__APPLE__)
#define HAVE_BOOL
//#include "my_pthread.h"
#endif
#include "mysql.h"
#include "mariadb_com.h"

@ -24,11 +24,6 @@ extern ClickHouse_Authentication *GloClickHouseAuth;
#undef max_allowed_packet
#endif
#if defined(__FreeBSD__) || defined(__APPLE__)
typedef uint8_t uint8;
typedef uint8_t uchar;
#endif
//#define RESULTSET_BUFLEN 16300
#ifndef CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA
@ -130,7 +125,7 @@ static inline int write_encoded_length_and_string(unsigned char *p, uint64_t val
return l+val;
}
void proxy_compute_sha1_hash_multi(uint8 *digest, const char *buf1, int len1, const char *buf2, int len2) {
void proxy_compute_sha1_hash_multi(uint8_t *digest, const char *buf1, int len1, const char *buf2, int len2) {
PROXY_TRACE();
SHA_CTX sha1_context;
@ -140,7 +135,7 @@ void proxy_compute_sha1_hash_multi(uint8 *digest, const char *buf1, int len1, co
SHA1_Final(digest, &sha1_context);
}
void proxy_compute_sha1_hash(uint8 *digest, const char *buf, int len) {
void proxy_compute_sha1_hash(uint8_t *digest, const char *buf, int len) {
PROXY_TRACE();
SHA_CTX sha1_context;
@ -149,13 +144,13 @@ void proxy_compute_sha1_hash(uint8 *digest, const char *buf, int len) {
SHA1_Final(digest, &sha1_context);
}
void proxy_compute_two_stage_sha1_hash(const char *password, size_t pass_len, uint8 *hash_stage1, uint8 *hash_stage2) {
void proxy_compute_two_stage_sha1_hash(const char *password, size_t pass_len, uint8_t *hash_stage1, uint8_t *hash_stage2) {
proxy_compute_sha1_hash(hash_stage1, password, pass_len);
proxy_compute_sha1_hash(hash_stage2, (const char *) hash_stage1, SHA_DIGEST_LENGTH);
}
void proxy_my_crypt(char *to, const uchar *s1, const uchar *s2, uint len) {
const uint8 *s1_end= s1 + len;
void proxy_my_crypt(char *to, const uint8_t *s1, const uint8_t *s2, uint len) {
const uint8_t *s1_end= s1 + len;
while (s1 < s1_end)
*to++= *s1++ ^ *s2++;
}
@ -189,23 +184,23 @@ void unhex_pass(uint8_t *out, const char *in) {
void proxy_scramble(char *to, const char *message, const char *password)
{
uint8 hash_stage1[SHA_DIGEST_LENGTH];
uint8 hash_stage2[SHA_DIGEST_LENGTH];
uint8_t hash_stage1[SHA_DIGEST_LENGTH];
uint8_t hash_stage2[SHA_DIGEST_LENGTH];
proxy_compute_two_stage_sha1_hash(password, strlen(password), hash_stage1, hash_stage2);
proxy_compute_sha1_hash_multi((uint8 *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH);
proxy_my_crypt(to, (const uchar *) to, hash_stage1, SCRAMBLE_LENGTH);
proxy_compute_sha1_hash_multi((uint8_t *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH);
proxy_my_crypt(to, (const uint8_t *) to, hash_stage1, SCRAMBLE_LENGTH);
return;
}
bool proxy_scramble_sha1(char *pass_reply, const char *message, const char *sha1_sha1_pass, char *sha1_pass) {
bool ret=false;
uint8 hash_stage1[SHA_DIGEST_LENGTH];
uint8 hash_stage2[SHA_DIGEST_LENGTH];
uint8 hash_stage3[SHA_DIGEST_LENGTH];
uint8 to[SHA_DIGEST_LENGTH];
uint8_t hash_stage1[SHA_DIGEST_LENGTH];
uint8_t hash_stage2[SHA_DIGEST_LENGTH];
uint8_t hash_stage3[SHA_DIGEST_LENGTH];
uint8_t to[SHA_DIGEST_LENGTH];
unhex_pass(hash_stage2,sha1_sha1_pass);
proxy_compute_sha1_hash_multi((uint8 *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH);
proxy_my_crypt((char *)hash_stage1,(const uchar *) pass_reply, to, SCRAMBLE_LENGTH);
proxy_compute_sha1_hash_multi((uint8_t *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH);
proxy_my_crypt((char *)hash_stage1,(const uint8_t *) pass_reply, to, SCRAMBLE_LENGTH);
proxy_compute_sha1_hash(hash_stage3, (const char *) hash_stage1, SHA_DIGEST_LENGTH);
if (memcmp(hash_stage2,hash_stage3,SHA_DIGEST_LENGTH)==0) {
memcpy(sha1_pass,hash_stage1,SHA_DIGEST_LENGTH);
@ -1912,8 +1907,8 @@ __do_auth:
unhex_pass(hash_stage2,sha1_2);
*/
proxy_debug(PROXY_DEBUG_MYSQL_AUTH, 5, "Session=%p , DS=%p , username='%s' , session_type=%d\n", (*myds), (*myds)->sess, user, session_type);
uint8 hash_stage1[SHA_DIGEST_LENGTH];
uint8 hash_stage2[SHA_DIGEST_LENGTH];
uint8_t hash_stage1[SHA_DIGEST_LENGTH];
uint8_t hash_stage2[SHA_DIGEST_LENGTH];
SHA_CTX sha1_context;
SHA1_Init(&sha1_context);
SHA1_Update(&sha1_context, pass, pass_len);

@ -3,11 +3,10 @@
#include <thread>
#include "btree_map.h"
#include "proxysql.h"
#if defined(__FreeBSD__) || defined(__APPLE__)
#include <fcntl.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
//#define PROXYSQL_EXTERN
#include "cpp.h"

Loading…
Cancel
Save