mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fix "mysqladmin password" to use correct password scrambling function when
talking to pre-4.1 servers or 4.1 and later servers where the old_passwords option is enabled. "mysqladmin old-password" is unchanged. (Bug #7451) client/mysqladmin.cc: Check old_passwords from server, and use that to determine which scramble function to use (except in the case of the old-password command, which always use the old scramble function).
This commit is contained in:
@ -826,13 +826,39 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
|
||||
if (argv[1][0])
|
||||
{
|
||||
char *pw= argv[1];
|
||||
bool old= find_type(argv[0], &command_typelib, 2) == ADMIN_OLD_PASSWORD;
|
||||
#ifdef __WIN__
|
||||
uint pw_len= strlen(pw);
|
||||
if (pw_len > 1 && pw[0] == '\'' && pw[pw_len-1] == '\'')
|
||||
printf("Warning: single quotes were not trimmed from the password by"
|
||||
" your command\nline client, as you might have expected.\n");
|
||||
#endif
|
||||
if (find_type(argv[0], &command_typelib, 2) == ADMIN_OLD_PASSWORD)
|
||||
/*
|
||||
If we don't already know to use an old-style password, see what
|
||||
the server is using
|
||||
*/
|
||||
if (!old) {
|
||||
if (mysql_query(mysql, "SHOW VARIABLES LIKE 'old_passwords'")) {
|
||||
my_printf_error(0, "Could not determine old_passwords setting from server; error: '%s'",
|
||||
MYF(ME_BELL),mysql_error(mysql));
|
||||
return -1;
|
||||
} else {
|
||||
MYSQL_RES *res= mysql_store_result(mysql);
|
||||
if (!res) {
|
||||
my_printf_error(0, "Could not get old_passwords setting from server; error: '%s'",
|
||||
MYF(ME_BELL),mysql_error(mysql));
|
||||
return -1;
|
||||
}
|
||||
if (!mysql_num_rows(res)) {
|
||||
old= 1;
|
||||
} else {
|
||||
MYSQL_ROW row= mysql_fetch_row(res);
|
||||
old= !strncmp(row[1], "ON", 2);
|
||||
}
|
||||
mysql_free_result(res);
|
||||
}
|
||||
}
|
||||
if (old)
|
||||
make_scrambled_password_323(crypted_pw, pw);
|
||||
else
|
||||
make_scrambled_password(crypted_pw, pw);
|
||||
|
Reference in New Issue
Block a user