Commit c1403e17 authored by unknown's avatar unknown

Correct bug which exposed itself in rpl000017

Commit for merge 


client/connect_test.c:
  Roll back wrong change
include/mysql_com.h:
  Correct prototypes not to have need to include my_global.h
sql/mysql_priv.h:
  Add expected hash lenght for old paswords.
sql/password.c:
  Change prototypes
sql/sql_acl.cc:
  Minor bug correction
parent 5f80c353
No related merge requests found
......@@ -16,6 +16,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "my_global.h"
#include "mysql.h"
static void change_user(MYSQL *sock,const char *user, const char *password,
......
......@@ -281,8 +281,8 @@ void randominit(struct rand_struct *,unsigned long seed1,
unsigned long seed2);
double rnd(struct rand_struct *);
void make_scrambled_password(char *to,const char *password,my_bool force_old_scramble,struct rand_struct *rand_st);
uint get_password_length(my_bool force_old_scramble);
uint8 get_password_version(const char* password);
int get_password_length(my_bool force_old_scramble);
char get_password_version(const char* password);
void create_random_string(int length,struct rand_struct *rand_st,char* target);
my_bool validate_password(const char* password, const char* message, ulong* salt);
void password_hash_stage1(char *to, const char *password);
......
......@@ -70,6 +70,7 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
#define ACL_CACHE_SIZE 256
/* Password lengh for 4.1 version previous versions had 16 bytes password hash */
#define HASH_PASSWORD_LENGTH 45
#define HASH_OLD_PASSWORD_LENGTH 16
#define HOST_CACHE_SIZE 128
#define MAX_ACCEPT_RETRY 10 // Test accept this many times
#define MAX_FIELDS_BEFORE_HASH 32
......
......@@ -232,7 +232,7 @@ void hash_password(ulong *result, const char *password)
none
*/
inline void password_hash_stage1(char *to, const char *password)
void password_hash_stage1(char *to, const char *password)
{
SHA1_CONTEXT context;
sha1_reset(&context);
......@@ -259,7 +259,7 @@ inline void password_hash_stage1(char *to, const char *password)
none
*/
inline void password_hash_stage2(char *to,const char *salt)
void password_hash_stage2(char *to,const char *salt)
{
SHA1_CONTEXT context;
sha1_reset(&context);
......@@ -398,7 +398,7 @@ my_bool validate_password(const char* password, const char* message, ulong* salt
password length >0
*/
inline uint get_password_length(my_bool force_old_scramble)
inline int get_password_length(my_bool force_old_scramble)
{
if (force_old_scramble)
return 16;
......@@ -418,7 +418,7 @@ inline uint get_password_length(my_bool force_old_scramble)
!0 password version char for newer passwords
*/
inline uint8 get_password_version(const char* password)
inline char get_password_version(const char* password)
{
if (password==NULL) return 0;
if (password[0]==PVERSION41_CHAR) return PVERSION41_CHAR;
......
......@@ -732,8 +732,11 @@ static void acl_update_user(const char *user, const char *host,
}
if (password)
{
if (!password[0])
if (!password[0]) /* If password is empty set it to null */
{
acl_user->password=0;
acl_user->pversion=0; // just initialize
}
else
{
acl_user->password=(char*) ""; // Just point at something
......@@ -774,7 +777,7 @@ static void acl_insert_user(const char *user, const char *host,
{
acl_user.password=(char*) ""; // Just point at something
get_salt_from_password(acl_user.salt,password);
acl_user.pversion=get_password_version(acl_user.password);
acl_user.pversion=get_password_version(password);
}
VOID(push_dynamic(&acl_users,(gptr) &acl_user));
......@@ -1337,7 +1340,8 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
if (combo.password.str && combo.password.str[0])
{
if (combo.password.length != HASH_PASSWORD_LENGTH)
if ((combo.password.length != HASH_PASSWORD_LENGTH)
&& combo.password.length != HASH_OLD_PASSWORD_LENGTH)
{
my_error(ER_PASSWORD_NO_MATCH,MYF(0));
DBUG_RETURN(-1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment