summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-01-13 15:50:02 +0100
committerSergei Golubchik <sergii@pisem.net>2012-01-13 15:50:02 +0100
commit4f435bddfd44d40999f88685c61cc04e319d8d6c (patch)
treef9d0655a0d901b87f918a736741144b502cba3f6 /libmysql
parent8c2bcdf85ff753bceeb5b235f3605e348e6f9e1d (diff)
parent6ca4ca7d37fed3b3da18666768de6a2f8c34bc7b (diff)
downloadmariadb-git-4f435bddfd44d40999f88685c61cc04e319d8d6c.tar.gz
5.3 merge
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/CMakeLists.txt2
-rw-r--r--libmysql/get_password.c31
-rw-r--r--libmysql/libmysql.c2
3 files changed, 18 insertions, 17 deletions
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index 9826c2d62f9..a469f243f7a 100644
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2011, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/libmysql/get_password.c b/libmysql/get_password.c
index 55b7bf41cee..dc1a29f7935 100644
--- a/libmysql/get_password.c
+++ b/libmysql/get_password.c
@@ -64,12 +64,10 @@
#if defined(__WIN__)
/* were just going to fake it here and get input from the keyboard */
-char *get_tty_password(const char *opt_message)
+void get_tty_password_buff(const char *opt_message, char *to, size_t length)
{
- char to[80];
- char *pos=to,*end=to+sizeof(to)-1;
+ char *pos=to,*end=to+length-1;
int i=0;
- DBUG_ENTER("get_tty_password");
_cputs(opt_message ? opt_message : "Enter password: ");
for (;;)
{
@@ -95,7 +93,6 @@ char *get_tty_password(const char *opt_message)
pos--; /* Allow dummy space at end */
*pos=0;
_cputs("\n");
- DBUG_RETURN(my_strdup(to,MYF(MY_FAE)));
}
#else
@@ -148,22 +145,19 @@ static void get_password(char *to,uint length,int fd, my_bool echo)
#endif /* ! HAVE_GETPASS */
-char *get_tty_password(const char *opt_message)
+void get_tty_password_buff(const char *opt_message, char *buff, size_t buflen)
{
#ifdef HAVE_GETPASS
char *passbuff;
#else /* ! HAVE_GETPASS */
TERMIO org,tmp;
#endif /* HAVE_GETPASS */
- char buff[80];
-
- DBUG_ENTER("get_tty_password");
#ifdef HAVE_GETPASS
passbuff = getpass(opt_message ? opt_message : "Enter password: ");
/* copy the password to buff and clear original (static) buffer */
- strnmov(buff, passbuff, sizeof(buff) - 1);
+ strnmov(buff, passbuff, buflen - 1);
#ifdef _PASSWORD_LEN
memset(passbuff, 0, _PASSWORD_LEN);
#endif
@@ -180,7 +174,7 @@ char *get_tty_password(const char *opt_message)
tmp.c_cc[VMIN] = 1;
tmp.c_cc[VTIME] = 0;
tcsetattr(fileno(stdin), TCSADRAIN, &tmp);
- get_password(buff, sizeof(buff)-1, fileno(stdin), isatty(fileno(stdout)));
+ get_password(buff, buflen, fileno(stdin), isatty(fileno(stdout)));
tcsetattr(fileno(stdin), TCSADRAIN, &org);
#elif defined(HAVE_TERMIO_H)
ioctl(fileno(stdin), (int) TCGETA, &org);
@@ -189,7 +183,7 @@ char *get_tty_password(const char *opt_message)
tmp.c_cc[VMIN] = 1;
tmp.c_cc[VTIME]= 0;
ioctl(fileno(stdin),(int) TCSETA, &tmp);
- get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout)));
+ get_password(buff,buflen-1,fileno(stdin),isatty(fileno(stdout)));
ioctl(fileno(stdin),(int) TCSETA, &org);
#else
gtty(fileno(stdin), &org);
@@ -197,13 +191,20 @@ char *get_tty_password(const char *opt_message)
tmp.sg_flags &= ~ECHO;
tmp.sg_flags |= RAW;
stty(fileno(stdin), &tmp);
- get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout)));
+ get_password(buff,buflen-1,fileno(stdin),isatty(fileno(stdout)));
stty(fileno(stdin), &org);
#endif
if (isatty(fileno(stdout)))
fputc('\n',stdout);
#endif /* HAVE_GETPASS */
-
- DBUG_RETURN(my_strdup(buff,MYF(MY_FAE)));
}
#endif /*__WIN__*/
+
+#ifndef MYSQL_DYNAMIC_PLUGIN
+char *get_tty_password(const char *opt_message)
+{
+ char buff[80];
+ get_tty_password_buff(opt_message, buff, sizeof(buff));
+ return my_strdup(buff, MYF(MY_FAE));
+}
+#endif
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 1294bb0062b..230376bc3b0 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by