diff options
author | unknown <petr@mysql.com> | 2005-02-18 15:23:55 +0300 |
---|---|---|
committer | unknown <petr@mysql.com> | 2005-02-18 15:23:55 +0300 |
commit | 97f26ff5f686a1ca2e97009b66ab40a4d29528e6 (patch) | |
tree | 0c778a526ffd4b71bdcefbf91e96b33265ec1305 /server-tools | |
parent | e2d78b85bf004c8c0ec25165d0c9980a3253914a (diff) | |
download | mariadb-git-97f26ff5f686a1ca2e97009b66ab40a4d29528e6.tar.gz |
new variant of passwd() by S. Vojtovich
server-tools/instance-manager/Makefile.am:
link get_password() to the IM
server-tools/instance-manager/options.cc:
make passwd() function to read password in mysqladmin way
Diffstat (limited to 'server-tools')
-rw-r--r-- | server-tools/instance-manager/Makefile.am | 1 | ||||
-rw-r--r-- | server-tools/instance-manager/options.cc | 18 |
2 files changed, 12 insertions, 7 deletions
diff --git a/server-tools/instance-manager/Makefile.am b/server-tools/instance-manager/Makefile.am index aab7db968fd..86effe3b9f0 100644 --- a/server-tools/instance-manager/Makefile.am +++ b/server-tools/instance-manager/Makefile.am @@ -36,6 +36,7 @@ liboptions_a_CPPFLAGS= $(CPPFLAGS) \ -DPROTOCOL_VERSION=@PROTOCOL_VERSION@ liboptions_a_SOURCES= options.h options.cc priv.h priv.cc +liboptions_a_LIBADD= $(top_builddir)/libmysql/get_password.$(OBJEXT) # MySQL sometimes uses symlinks to reuse code # All symlinked files are grouped in libnet.a diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc index 4a9745451a1..9e4205b1407 100644 --- a/server-tools/instance-manager/options.cc +++ b/server-tools/instance-manager/options.cc @@ -151,27 +151,31 @@ static void usage() static void passwd() { - char user[1024], pw[1024], *p; + char user[1024], *p; + const char *pw1, *pw2; + char pw1msg[]= "Enter password: "; + char pw2msg[]= "Re-type password: "; char crypted_pw[SCRAMBLED_PASSWORD_CHAR_LENGTH + 1]; fprintf(stderr, "Creating record for new user.\n"); fprintf(stderr, "Enter user name: "); - if (!fgets(user, sizeof(user), stdin)) + if (! fgets(user, sizeof(user), stdin)) { fprintf(stderr, "Unable to read user.\n"); return; } if ((p= strchr(user, '\n'))) *p= 0; - fprintf(stderr, "Enter password: "); - if (! fgets(pw, sizeof(pw), stdin)) + pw1= get_tty_password(pw1msg); + pw2= get_tty_password(pw2msg); + + if (strcmp(pw1, pw2)) { - fprintf(stderr, "Unable to read password.\n"); + fprintf(stderr, "Sorry, passwords do not match.\n"); return; } - if ((p= strchr(pw, '\n'))) *p= 0; - make_scrambled_password(crypted_pw, pw); + make_scrambled_password(crypted_pw, pw1); printf("%s:%s\n", user, crypted_pw); } |