48
49
static uint32_t retry_count;
49
50
static uint32_t buffer_length;
50
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;
52
57
const char* ListenMySQLProtocol::getHost(void) const
657
665
/* We don't use scramble anymore. */
658
memset(end, 'X', SCRAMBLE_LENGTH_323);
666
memcpy(end, scramble, SCRAMBLE_LENGTH_323);
659
667
end+= SCRAMBLE_LENGTH_323;
660
668
*end++= 0; /* an empty byte for some reason */
669
677
/* Write scramble tail. */
670
memset(end, 'X', SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323);
678
memcpy(end, scramble + SCRAMBLE_LENGTH_323, SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323);
671
679
end+= (SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323);
672
680
*end++= 0; /* an empty byte for some reason */
729
737
passwd < (char *) net.read_pos + pkt_len)
731
739
passwd_len= (unsigned char)(*passwd++);
742
session->getSecurityContext().setPasswordType(SecurityContext::MYSQL_HASH);
743
session->getSecurityContext().setPasswordContext(scramble, SCRAMBLE_LENGTH);
860
void ClientMySQLProtocol::makeScramble(char *scramble)
862
/* This is the MySQL algorithm with minimal changes. */
863
random_seed1= (random_seed1 * 3 + random_seed2) % random_max;
864
random_seed2= (random_seed1 + random_seed2 + 33) % random_max;
865
uint32_t seed= static_cast<uint32_t>((static_cast<double>(random_seed1) / random_max_double) * 0xffffffff);
868
uint32_t pointer_seed;
869
memcpy(&pointer_seed, &pointer, 4);
870
uint32_t random1= (seed + pointer_seed) % random_max;
871
uint32_t random2= (seed + global_thread_id + net.vio->sd) % random_max;
873
for (char *end= scramble + SCRAMBLE_LENGTH; scramble != end; scramble++)
875
random1= (random1 * 3 + random2) % random_max;
876
random2= (random1 + random2 + 33) % random_max;
877
*scramble= static_cast<char>((static_cast<double>(random1) / random_max_double) * 94 + 33);
847
881
static ListenMySQLProtocol *listen_obj= NULL;
882
plugin::Create_function<MySQLPassword> *mysql_password= NULL;
849
884
static int init(drizzled::plugin::Context &context)
886
/* Initialize random seeds for the MySQL algorithm with minimal changes. */
887
time_t seed_time= time(NULL);
888
random_seed1= seed_time % random_max;
889
random_seed2= (seed_time / 2) % random_max;
891
mysql_password= new plugin::Create_function<MySQLPassword>(MySQLPasswordName);
892
context.add(mysql_password);
851
894
listen_obj= new ListenMySQLProtocol("mysql_protocol", true);
852
895
context.add(listen_obj);