49
49
static uint32_t retry_count;
50
50
static uint32_t buffer_length;
51
51
static char* bind_address;
52
static uint32_t random_seed1;
53
static uint32_t random_seed2;
54
static const uint32_t random_max= 0x3FFFFFFF;
55
static const double random_max_double= (double)0x3FFFFFFF;
53
57
const char* ListenMySQLProtocol::getHost(void) const
658
665
/* We don't use scramble anymore. */
659
memset(end, 'X', SCRAMBLE_LENGTH_323);
666
memcpy(end, scramble, SCRAMBLE_LENGTH_323);
660
667
end+= SCRAMBLE_LENGTH_323;
661
668
*end++= 0; /* an empty byte for some reason */
670
677
/* Write scramble tail. */
671
memset(end, 'X', SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323);
678
memcpy(end, scramble + SCRAMBLE_LENGTH_323, SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323);
672
679
end+= (SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323);
673
680
*end++= 0; /* an empty byte for some reason */
728
735
uint32_t passwd_len= client_capabilities & CLIENT_SECURE_CONNECTION ?
729
736
(unsigned char)(*passwd++) : strlen(passwd);
739
session->getSecurityContext().setPasswordType(SecurityContext::MYSQL_HASH);
740
session->getSecurityContext().setPasswordContext(scramble, SCRAMBLE_LENGTH);
730
743
l_db= client_capabilities & CLIENT_CONNECT_WITH_DB ? l_db + passwd_len + 1 : 0;
732
745
/* strlen() can't be easily deleted without changing client */
848
void ClientMySQLProtocol::makeScramble(char *scramble)
850
/* This is the MySQL algorithm with minimal changes. */
851
random_seed1= (random_seed1 * 3 + random_seed2) % random_max;
852
random_seed2= (random_seed1 + random_seed2 + 33) % random_max;
853
uint32_t seed= static_cast<uint32_t>((static_cast<double>(random_seed1) / random_max_double) * 0xffffffff);
856
uint32_t pointer_seed;
857
memcpy(&pointer_seed, &pointer, 4);
858
uint32_t random1= (seed + pointer_seed) % random_max;
859
uint32_t random2= (seed + global_thread_id + net.vio->sd) % random_max;
861
for (char *end= scramble + SCRAMBLE_LENGTH; scramble != end; scramble++)
863
random1= (random1 * 3 + random2) % random_max;
864
random2= (random1 + random2 + 33) % random_max;
865
*scramble= static_cast<char>((static_cast<double>(random1) / random_max_double) * 94 + 33);
835
869
static ListenMySQLProtocol *listen_obj= NULL;
836
870
plugin::Create_function<MySQLPassword> *mysql_password= NULL;
838
872
static int init(drizzled::plugin::Registry ®istry)
874
/* Initialize random seeds for the MySQL algorithm with minimal changes. */
875
time_t seed_time= time(NULL);
876
random_seed1= seed_time % random_max;
877
random_seed2= (seed_time / 2) % random_max;
840
879
mysql_password= new plugin::Create_function<MySQLPassword>(MySQLPasswordName);
841
880
registry.add(mysql_password);