Commit 4d025523 authored by jimw@mysql.com's avatar jimw@mysql.com

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)
parent a3f184f5
......@@ -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);
......
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