Skip to content

Commit 44cf4d6

Browse files
author
Sergei Golubchik
committed
fix a case where automatic procedure grant was changing user's password
phase out make_password_from_salt() to be removed in 10.1
1 parent 865b83e commit 44cf4d6

File tree

4 files changed

+44
-26
lines changed

4 files changed

+44
-26
lines changed

include/mysql_com.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,17 @@ void scramble_323(char *to, const char *message, const char *password);
618618
my_bool check_scramble_323(const unsigned char *reply, const char *message,
619619
unsigned long *salt);
620620
void get_salt_from_password_323(unsigned long *res, const char *password);
621+
#if MYSQL_VERSION_ID < 100100
621622
void make_password_from_salt_323(char *to, const unsigned long *salt);
622-
623+
#endif
623624
void make_scrambled_password(char *to, const char *password);
624625
void scramble(char *to, const char *message, const char *password);
625626
my_bool check_scramble(const unsigned char *reply, const char *message,
626627
const unsigned char *hash_stage2);
627628
void get_salt_from_password(unsigned char *res, const char *password);
629+
#if MYSQL_VERSION_ID < 100100
628630
void make_password_from_salt(char *to, const unsigned char *hash_stage2);
631+
#endif
629632
char *octet2hex(char *to, const char *str, unsigned int len);
630633

631634
/* end of password.c */

mysql-test/r/sp_notembedded.result

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,23 @@ DROP EVENT teste_bug11763507;
284284
# ------------------------------------------------------------------
285285
# -- End of 5.1 tests
286286
# ------------------------------------------------------------------
287+
grant create routine on test.* to foo1@localhost identified by 'foo';
288+
update mysql.user set password = replace(password, '*', '-') where user='foo1';
289+
show grants;
290+
Grants for foo1@localhost
291+
GRANT USAGE ON *.* TO 'foo1'@'localhost' IDENTIFIED BY PASSWORD '*F3A2A51A9B0F2BE2468926B4132313728C250DBF'
292+
GRANT CREATE ROUTINE ON `test`.* TO 'foo1'@'localhost'
293+
flush privileges;
294+
show grants;
295+
Grants for foo1@localhost
296+
GRANT USAGE ON *.* TO 'foo1'@'localhost' IDENTIFIED BY PASSWORD '-F3A2A51A9B0F2BE2468926B4132313728C250DBF'
297+
GRANT CREATE ROUTINE ON `test`.* TO 'foo1'@'localhost'
298+
create procedure spfoo() select 1;
299+
show grants;
300+
Grants for foo1@localhost
301+
GRANT USAGE ON *.* TO 'foo1'@'localhost' IDENTIFIED BY PASSWORD '-F3A2A51A9B0F2BE2468926B4132313728C250DBF'
302+
GRANT CREATE ROUTINE ON `test`.* TO 'foo1'@'localhost'
303+
GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`spfoo` TO 'foo1'@'localhost'
304+
drop procedure spfoo;
305+
drop user foo1@localhost;
287306
set @@global.concurrent_insert= @old_concurrent_insert;

mysql-test/t/sp_notembedded.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,26 @@ DROP EVENT teste_bug11763507;
461461
--echo # -- End of 5.1 tests
462462
--echo # ------------------------------------------------------------------
463463

464+
#
465+
# A case of SHOW GRANTS
466+
# (creating a new procedure changes the password)
467+
#
468+
grant create routine on test.* to foo1@localhost identified by 'foo';
469+
update mysql.user set password = replace(password, '*', '-') where user='foo1';
470+
--connect (foo,localhost,foo1,foo)
471+
show grants;
472+
--connection default
473+
flush privileges;
474+
--connection foo
475+
show grants;
476+
create procedure spfoo() select 1;
477+
show grants;
478+
479+
--connection default
480+
--disconnect foo
481+
drop procedure spfoo;
482+
drop user foo1@localhost;
483+
464484
#
465485
# Restore global concurrent_insert value. Keep in the end of the test file.
466486
#

sql/sql_acl.cc

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9840,7 +9840,6 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
98409840
List<LEX_USER> user_list;
98419841
bool result;
98429842
ACL_USER *au;
9843-
char passwd_buff[SCRAMBLED_PASSWORD_CHAR_LENGTH+1];
98449843
Dummy_error_handler error_handler;
98459844
DBUG_ENTER("sp_grant_privileges");
98469845

@@ -9881,33 +9880,10 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
98819880

98829881
if(au)
98839882
{
9884-
if (au->salt_len)
9885-
{
9886-
if (au->salt_len == SCRAMBLE_LENGTH)
9887-
{
9888-
make_password_from_salt(passwd_buff, au->salt);
9889-
combo->password.length= SCRAMBLED_PASSWORD_CHAR_LENGTH;
9890-
}
9891-
else if (au->salt_len == SCRAMBLE_LENGTH_323)
9892-
{
9893-
make_password_from_salt_323(passwd_buff, (ulong *) au->salt);
9894-
combo->password.length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323;
9895-
}
9896-
else
9897-
{
9898-
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_PASSWD_LENGTH,
9899-
ER(ER_PASSWD_LENGTH), SCRAMBLED_PASSWORD_CHAR_LENGTH);
9900-
return TRUE;
9901-
}
9902-
combo->password.str= passwd_buff;
9903-
}
9904-
99059883
if (au->plugin.str != native_password_plugin_name.str &&
99069884
au->plugin.str != old_password_plugin_name.str)
9907-
{
99089885
combo->plugin= au->plugin;
9909-
combo->auth= au->auth_string;
9910-
}
9886+
combo->auth= au->auth_string;
99119887
}
99129888

99139889
if (user_list.push_back(combo))

0 commit comments

Comments
 (0)