===== mysqladmin.c 1.89 vs edited ===== --- 1.89/client/mysqladmin.c Tue Aug 31 20:23:25 2004 +++ edited/mysqladmin.c Thu Sep 23 18:04:26 2004 @@ -768,21 +768,36 @@ { char buff[128],crypted_pw[64]; time_t start_time; + char *typed_password = NULL, *verified = NULL; + /* Do initialization the same way as we do in mysqld */ start_time=time((time_t*) 0); randominit(&rand_st,(ulong) start_time,(ulong) start_time/2); - if (argc < 2) + if (argc < 1) { my_printf_error(0,"Too few arguments to change password",MYF(ME_BELL)); return 1; } - if (argv[1][0]) + else if (argc == 1) + { + /* prompt for password */ + typed_password = get_tty_password("New password: "); + verified = get_tty_password("Confirm new password: "); + if (strcmp(typed_password, verified) != 0) + { + my_printf_error(0,"Passwords don't match",MYF(ME_BELL)); + return -1; + } + } + else + typed_password = argv[1]; + if (typed_password[0]) { if (find_type(argv[0], &command_typelib, 2) == ADMIN_OLD_PASSWORD) - make_scrambled_password_323(crypted_pw, argv[1]); + make_scrambled_password_323(crypted_pw, typed_password); else - make_scrambled_password(crypted_pw, argv[1]); + make_scrambled_password(crypted_pw, typed_password); } else crypted_pw[0]=0; /* No password */ @@ -816,6 +831,12 @@ " instead", MYF(ME_BELL)); return -1; } + } + /* free up memory from prompted password */ + if (typed_password != argv[1]) + { + my_free(typed_password,MYF(MY_ALLOW_ZERO_PTR)); + my_free(verified,MYF(MY_ALLOW_ZERO_PTR)); } argc--; argv++; break;