diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-12-02 16:26:43 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-12-02 16:26:43 +0100 |
commit | d5fd757a4279f4fa8f032c6dd63d1d121d8e1fea (patch) | |
tree | ad5b63e8b1d154ab7b1753f9e156e7741b01899d /libmysql | |
parent | 791286ee1c3c705cb8853e242cdf718a7b5ce5b7 (diff) | |
download | mariadb-git-d5fd757a4279f4fa8f032c6dd63d1d121d8e1fea.tar.gz |
1. add --plugin-dir and --default-auth to mysqltest.
2. dialog plugin now always returns mysql->password if non-empty and the first question is of password type
3. split get_tty_password into get_tty_password_buff and strdup.
4. dialog plugin now uses get_tty_password by default
5. dialog.test
6. moved small tests of individual plugins into a dedicated suite
Diffstat (limited to 'libmysql')
-rwxr-xr-x | libmysql/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libmysql/get_password.c | 31 |
2 files changed, 16 insertions, 16 deletions
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 2e99b2a001d..aa6ea8dc851 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -120,7 +120,6 @@ IF(WIN32) ENDIF(WIN32) ADD_DEPENDENCIES(libmysql GenError) TARGET_LINK_LIBRARIES(libmysql mysqlclient ws2_32) -ADD_DEFINITIONS(-DHAVE_DLOPEN) MYSQL_INSTALL_TARGETS(mysqlclient DESTINATION lib COMPONENT Development) MYSQL_INSTALL_TARGETS(libmysql DESTINATION lib COMPONENT SharedLibraries) diff --git a/libmysql/get_password.c b/libmysql/get_password.c index cbe5fce6949..747d598d72a 100644 --- a/libmysql/get_password.c +++ b/libmysql/get_password.c @@ -75,12 +75,10 @@ #define _cputs(A) putstring(A) #endif -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 (;;) { @@ -106,7 +104,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 @@ -159,22 +156,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 @@ -191,7 +185,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); @@ -200,7 +194,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); @@ -208,13 +202,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 |