summaryrefslogtreecommitdiff
path: root/client/mysqladmin.cc
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-01-05 21:56:18 +0100
committerunknown <jimw@mysql.com>2005-01-05 21:56:18 +0100
commit190f7a6f451f01b4b336b8825178ec3e38d24a9c (patch)
tree3c77fe3e5de7d9545312888f4d71abdf85f2752f /client/mysqladmin.cc
parentd9adebfa2420e2c093ec198c80def43cae8b3902 (diff)
downloadmariadb-git-190f7a6f451f01b4b336b8825178ec3e38d24a9c.tar.gz
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).
Diffstat (limited to 'client/mysqladmin.cc')
-rw-r--r--client/mysqladmin.cc28
1 files changed, 27 insertions, 1 deletions
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 2e8b3cd588a..6916b4ea808 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -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);