------------------------------------------------------------ committer: Sergei Golubchik timestamp: Fri 2010-04-02 11:20:09 +0200 message: fixes for windows builds diff: === modified file 'CMakeLists.txt' --- CMakeLists.txt 2010-04-01 14:34:51 +0000 +++ CMakeLists.txt 2010-04-02 09:20:09 +0000 @@ -38,6 +38,7 @@ ADD_DEFINITIONS(-DDEFAULT_CHARSET_HOME="c:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}/") ADD_DEFINITIONS(-DPACKAGE=mysql) ADD_DEFINITIONS(-DSHAREDIR="share") +ADD_DEFINITIONS(-DPLUGINDIR="lib/plugin") # Set debug options SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS") === modified file 'include/my_global.h' --- include/my_global.h 2010-03-29 15:13:53 +0000 +++ include/my_global.h 2010-04-02 09:20:09 +0000 @@ -1522,6 +1522,9 @@ #elif defined(HAVE_DLFCN_H) #include #endif +#ifndef HAVE_DLERROR +#define dlerror() "" +#endif #endif /* FreeBSD 2.2.2 does not define RTLD_NOW) */ @@ -1529,7 +1532,7 @@ #define RTLD_NOW 1 #endif -#ifndef HAVE_DLERROR +#ifndef HAVE_DLOPEN #define dlerror() "No support for dynamic loading (static build?)" #define dlopen(A,B) 0 #define dlsym(A,B) 0 === modified file 'server-tools/CMakeLists.txt' --- server-tools/CMakeLists.txt 2007-02-14 11:42:11 +0000 +++ server-tools/CMakeLists.txt 2010-04-02 09:20:09 +0000 @@ -27,7 +27,7 @@ user_management_commands.cc ../../sql/net_serv.cc ../../sql-common/pack.c ../../sql/password.c ../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c - ../../libmysql/errmsg.c) + ../../libmysql/errmsg.c ../../sql-common/client_plugin.c) ADD_DEPENDENCIES(mysqlmanager GenError) TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32) === modified file 'server-tools/instance-manager/CMakeLists.txt' --- server-tools/instance-manager/CMakeLists.txt 2007-12-27 17:16:02 +0000 +++ server-tools/instance-manager/CMakeLists.txt 2010-04-02 09:20:09 +0000 @@ -28,7 +28,7 @@ user_management_commands.cc ../../mysys/my_rnd.c ../../sql/net_serv.cc ../../sql-common/pack.c ../../sql/password.c ../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c - ../../libmysql/errmsg.c) + ../../libmysql/errmsg.c ../../sql-common/client_plugin.c) ADD_DEPENDENCIES(mysqlmanager GenError) TARGET_LINK_LIBRARIES(mysqlmanager debug dbug mysys strings taocrypt vio yassl zlib wsock32) === modified file 'sql-common/client.c' --- sql-common/client.c 2010-04-01 09:04:26 +0000 +++ sql-common/client.c 2010-04-02 09:20:09 +0000 @@ -2345,7 +2345,7 @@ case VIO_TYPE_SSL: { struct sockaddr addr; - socklen_t addrlen= sizeof(addr); + SOCKET_SIZE_TYPE addrlen= sizeof(addr); if (getsockname(vio->sd, &addr, &addrlen)) return; info->protocol= addr.sa_family == AF_UNIX ? @@ -2360,7 +2360,7 @@ return; case VIO_TYPE_SHARED_MEMORY: info->protocol= MYSQL_VIO_MEMORY; - info->handle= vio->handle_client_file_map; /* or what ? */ + info->handle= vio->handle_file_map; /* or what ? */ return; #endif default: DBUG_ASSERT(0); === modified file 'sql/client_settings.h' --- sql/client_settings.h 2010-03-29 15:13:53 +0000 +++ sql/client_settings.h 2010-04-02 09:20:09 +0000 @@ -29,7 +29,6 @@ #define mysql_master_send_query(A, B, C) 1 #define mysql_slave_send_query(A, B, C) 1 #define mysql_rpl_probe(mysql) 0 -#undef HAVE_SMEM #undef _CUSTOMCONFIG_ #define mysql_server_init(a,b,c) mysql_client_plugin_init() === modified file 'sql/mysqld.cc' --- sql/mysqld.cc 2010-04-01 09:04:26 +0000 +++ sql/mysqld.cc 2010-04-02 09:20:09 +0000 @@ -6645,8 +6645,6 @@ {"shared-memory", OPT_ENABLE_SHARED_MEMORY, "Enable the shared memory.",(uchar**) &opt_enable_shared_memory, (uchar**) &opt_enable_shared_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, -#endif -#ifdef HAVE_SMEM {"shared-memory-base-name",OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, ------------------------------------------------------------ committer: Sergei Golubchik timestamp: Fri 2010-04-02 22:08:40 +0200 message: embedded builds used to refer to undefined functions inside if(0) { } gcc optimized this dead code away, and does not notice that functions were undefined. Other compilers are more picky diff: === modified file 'sql/sql_acl.cc' --- sql/sql_acl.cc 2010-04-01 14:34:51 +0000 +++ sql/sql_acl.cc 2010-04-02 20:08:40 +0000 @@ -6849,6 +6849,7 @@ #define initialized 0 #define decrease_user_connections(X) /* nothing */ #define check_for_max_user_connections(X,Y) 0 +#define get_or_create_user_conn(A,B,C,D) 0 #endif #endif #ifndef HAVE_OPENSSL ------------------------------------------------------------ committer: Sergei Golubchik timestamp: Mon 2010-04-05 11:50:31 +0200 message: fixed a bug in handling mysql_native_password specified explicitly: CREATE USER mysqltest_up1 IDENTIFIED VIA mysql_native_password pointers were not always fixed, salt wasn't updated diff: === modified file 'mysql-test/r/connect.result' --- mysql-test/r/connect.result 2009-04-25 09:04:38 +0000 +++ mysql-test/r/connect.result 2010-04-05 09:50:31 +0000 @@ -225,3 +225,17 @@ # ------------------------------------------------------------------ # -- End of 5.1 tests # ------------------------------------------------------------------ +CREATE USER mysqltest_up1 IDENTIFIED VIA mysql_native_password using '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB'; +CREATE USER mysqltest_up2 IDENTIFIED VIA mysql_old_password using '09301740536db389'; +connect(localhost,mysqltest_up1,foo,test,13001,MASTER_SOCKET); +ERROR 28000: Access denied for user 'mysqltest_up1'@'localhost' (using password: YES) +select user(), current_user(); +user() current_user() +mysqltest_up1@localhost mysqltest_up1@% +connect(localhost,mysqltest_up2,newpw,test,13001,MASTER_SOCKET); +ERROR 28000: Access denied for user 'mysqltest_up2'@'localhost' (using password: YES) +select user(), current_user(); +user() current_user() +mysqltest_up2@localhost mysqltest_up2@% +DROP USER mysqltest_up1@'%'; +DROP USER mysqltest_up2@'%'; === modified file 'mysql-test/t/connect.test' --- mysql-test/t/connect.test 2009-09-07 20:50:10 +0000 +++ mysql-test/t/connect.test 2010-04-05 09:50:31 +0000 @@ -328,6 +328,34 @@ --disconnect extracon2 --connection default +# +# A couple of plugin tests - for builtin plugins only +# +CREATE USER mysqltest_up1 IDENTIFIED VIA mysql_native_password using '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB'; +CREATE USER mysqltest_up2 IDENTIFIED VIA mysql_old_password using '09301740536db389'; + +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_ACCESS_DENIED_ERROR +connect(pcon1,localhost,mysqltest_up1,foo,,$MASTER_EXTRA_PORT,); + +connect(pcon2,localhost,mysqltest_up1,bar,,$MASTER_EXTRA_PORT,); +connection pcon2; +select user(), current_user(); +disconnect pcon2; + +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_ACCESS_DENIED_ERROR +connect(pcon3,localhost,mysqltest_up2,newpw,,$MASTER_EXTRA_PORT,); + +connect(pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_EXTRA_PORT,); +connection pcon4; +select user(), current_user(); +disconnect pcon4; + +connection default; +DROP USER mysqltest_up1@'%'; +DROP USER mysqltest_up2@'%'; + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc === modified file 'sql/sql_acl.cc' --- sql/sql_acl.cc 2010-04-02 20:08:40 +0000 +++ sql/sql_acl.cc 2010-04-05 09:50:31 +0000 @@ -319,6 +319,35 @@ acl_user->salt_len= 0; } +/** + Fix ACL::plugin pointer to point to a hard-coded string, if appropriate + + Make sure that if ACL_USER's plugin is a built-in, then it points + to a hard coded string, not to an allocated copy. Run-time, for + authentication, we want to be able to detect built-ins by comparing + pointers, not strings. + + Additionally - update the salt if the plugin is built-in. + + @retval 0 the pointers were fixed + @retval 1 this ACL_USER uses a not built-in plugin +*/ +static bool fix_user_plugin_ptr(ACL_USER *user) +{ + if (my_strcasecmp(system_charset_info, user->plugin.str, + native_password_plugin_name.str) == 0) + user->plugin= native_password_plugin_name; + else + if (my_strcasecmp(system_charset_info, user->plugin.str, + old_password_plugin_name.str) == 0) + user->plugin= old_password_plugin_name; + else + return true; + + set_user_salt(user, user->auth_string.str, user->auth_string.length); + return false; +} + /* This after_update function is used when user.password is less than SCRAMBLE_LENGTH bytes. @@ -662,6 +691,8 @@ char *tmpstr= get_field(&mem, table->field[next_field++]); if (tmpstr) { + user.plugin.str= tmpstr; + user.plugin.length= strlen(user.plugin.str); if (user.auth_string.length) { sql_print_warning("'user' entry '%s@%s' has both a password " @@ -670,22 +701,12 @@ user.user ? user.user : "", user.host.hostname ? user.host.hostname : ""); } - if (my_strcasecmp(system_charset_info, tmpstr, - native_password_plugin_name.str) == 0) - user.plugin= native_password_plugin_name; - else - if (my_strcasecmp(system_charset_info, tmpstr, - old_password_plugin_name.str) == 0) - user.plugin= old_password_plugin_name; - else - { - user.plugin.str= tmpstr; - user.plugin.length= strlen(tmpstr); - } user.auth_string.str= get_field(&mem, table->field[next_field++]); if (!user.auth_string.str) user.auth_string.str= const_cast(""); user.auth_string.length= strlen(user.auth_string.str); + + fix_user_plugin_ptr(&user); } } } @@ -1132,12 +1153,15 @@ { if (plugin->str[0]) { - acl_user->plugin.str= strmake_root(&mem, plugin->str, plugin->length); - acl_user->plugin.length= plugin->length; + acl_user->plugin= *plugin; acl_user->auth_string.str= auth->str ? strmake_root(&mem, auth->str, auth->length) : const_cast(""); acl_user->auth_string.length= auth->length; + if (fix_user_plugin_ptr(acl_user)) + acl_user->plugin.str= strmake_root(&mem, plugin->str, plugin->length); } + else + set_user_salt(acl_user, password, password_len); acl_user->access=privileges; if (mqh->specified_limits & USER_RESOURCES::QUERIES_PER_HOUR) acl_user->user_resource.questions=mqh->questions; @@ -1157,8 +1181,6 @@ acl_user->x509_subject= (x509_subject ? strdup_root(&mem,x509_subject) : 0); } - if (password) - set_user_salt(acl_user, password, password_len); /* search complete: */ break; } @@ -1186,11 +1208,12 @@ update_hostname(&acl_user.host, *host ? strdup_root(&mem, host): 0); if (plugin->str[0]) { - acl_user.plugin.str= strmake_root(&mem, plugin->str, plugin->length); - acl_user.plugin.length= plugin->length; + acl_user.plugin= *plugin; acl_user.auth_string.str= auth->str ? strmake_root(&mem, auth->str, auth->length) : const_cast(""); acl_user.auth_string.length= auth->length; + if (fix_user_plugin_ptr(&acl_user)) + acl_user.plugin.str= strmake_root(&mem, plugin->str, plugin->length); } else { @@ -1198,6 +1221,7 @@ old_password_plugin_name : native_password_plugin_name; acl_user.auth_string.str= strmake_root(&mem, password, password_len); acl_user.auth_string.length= password_len; + set_user_salt(&acl_user, password, password_len); } acl_user.access=privileges; @@ -1210,8 +1234,6 @@ acl_user.x509_issuer= x509_issuer ? strdup_root(&mem,x509_issuer) : 0; acl_user.x509_subject=x509_subject ? strdup_root(&mem,x509_subject) : 0; - set_user_salt(&acl_user, password, password_len); - VOID(push_dynamic(&acl_users,(uchar*) &acl_user)); if (!acl_user.host.hostname || (acl_user.host.hostname[0] == wild_many && !acl_user.host.hostname[1])) ------------------------------------------------------------ committer: Sergei Golubchik timestamp: Tue 2010-04-06 13:04:56 +0200 message: keep acl_user->auth_string and acl_user->salt always in sync print authenticated via in show grants diff: === modified file 'sql/sql_acl.cc' --- sql/sql_acl.cc 2010-04-05 09:50:31 +0000 +++ sql/sql_acl.cc 2010-04-06 11:04:56 +0000 @@ -287,9 +287,8 @@ static void rebuild_check_host(void); static ACL_USER *find_acl_user(const char *host, const char *user, my_bool exact); -static bool update_user_table(THD *thd, TABLE *table, - const char *host, const char *user, - const char *new_password, uint new_password_len); +static bool update_user_table(THD *, TABLE *, const char *, const char *, + const char *, uint); static void update_hostname(acl_host_and_ip *host, const char *hostname); static bool compare_hostname(const acl_host_and_ip *host,const char *hostname, const char *ip); @@ -1161,7 +1160,12 @@ acl_user->plugin.str= strmake_root(&mem, plugin->str, plugin->length); } else - set_user_salt(acl_user, password, password_len); + if (password) + { + acl_user->auth_string.str= strmake_root(&mem, password, password_len); + acl_user->auth_string.length= password_len; + set_user_salt(acl_user, password, password_len); + } acl_user->access=privileges; if (mqh->specified_limits & USER_RESOURCES::QUERIES_PER_HOUR) acl_user->user_resource.questions=mqh->questions; @@ -1611,7 +1615,13 @@ goto end; } /* update loaded acl entry: */ - set_user_salt(acl_user, new_password, new_password_len); + if (acl_user->plugin.str == native_password_plugin_name.str || + acl_user->plugin.str == old_password_plugin_name.str) + { + acl_user->auth_string.str= strmake_root(&mem, new_password, new_password_len); + acl_user->auth_string.length= new_password_len; + set_user_salt(acl_user, new_password, new_password_len); + } if (update_user_table(thd, table, acl_user->host.hostname ? acl_user->host.hostname : "", @@ -4642,16 +4652,27 @@ global.append(lex_user->host.str,lex_user->host.length, system_charset_info); global.append ('\''); - if (acl_user->salt_len) - { - char passwd_buff[SCRAMBLED_PASSWORD_CHAR_LENGTH+1]; - if (acl_user->salt_len == SCRAMBLE_LENGTH) - make_password_from_salt(passwd_buff, acl_user->salt); - else - make_password_from_salt_323(passwd_buff, (ulong *) acl_user->salt); - global.append(STRING_WITH_LEN(" IDENTIFIED BY PASSWORD '")); - global.append(passwd_buff); - global.append('\''); + if (acl_user->plugin.str == native_password_plugin_name.str || + acl_user->plugin.str == old_password_plugin_name.str) + { + if (acl_user->auth_string.length) + { + DBUG_ASSERT(acl_user->salt_len); + global.append(STRING_WITH_LEN(" IDENTIFIED BY PASSWORD '")); + global.append(acl_user->auth_string.str, acl_user->auth_string.length); + global.append('\''); + } + } + else + { + global.append(STRING_WITH_LEN(" IDENTIFIED VIA ")); + global.append(acl_user->plugin.str, acl_user->plugin.length); + if (acl_user->auth_string.length) + { + global.append(STRING_WITH_LEN(" USING '")); + global.append(acl_user->auth_string.str, acl_user->auth_string.length); + global.append('\''); + } } /* "show grants" SSL related stuff */ if (acl_user->ssl_type == SSL_TYPE_ANY) ------------------------------------------------------------ committer: Michael Widenius timestamp: Thu 2010-04-08 16:02:49 +0300 message: Fixed compiler warnings Changed version string to beta diff: === modified file 'client/mysql.cc' --- client/mysql.cc 2010-03-29 15:13:53 +0000 +++ client/mysql.cc 2010-04-08 13:02:49 +0000 @@ -4288,8 +4288,9 @@ } else { - fgets(buf, buf_len-1, stdin); - if (buf[0] && (s= strend(buf))[-1] == '\n') + if (!fgets(buf, buf_len-1, stdin)) + buf[0]= 0; + else if (buf[0] && (s= strend(buf))[-1] == '\n') s[-1]= 0; } === modified file 'plugin/auth/dialog.c' --- plugin/auth/dialog.c 2010-04-01 14:34:51 +0000 +++ plugin/auth/dialog.c 2010-04-08 13:02:49 +0000 @@ -224,11 +224,11 @@ static char *builtin_ask(MYSQL *mysql __attribute__((unused)), int type __attribute__((unused)), const char *prompt, - char *buf, int buf_len __attribute__((unused))) + char *buf, int buf_len) { fputs(prompt, stdout); fputc(' ', stdout); - if (gets(buf) == 0) + if (fgets(buf, buf_len, stdin) == 0) return 0; return buf; ------------------------------------------------------------ revno: 2781 committer: Sergei Golubchik branch nick: 5.2 timestamp: Thu 2010-04-08 15:58:04 +0200 message: fix dialog plugin to work again (fgets, unlike gets, does not strip \n) diff: === modified file 'plugin/auth/dialog.c' --- plugin/auth/dialog.c 2010-04-08 13:02:49 +0000 +++ plugin/auth/dialog.c 2010-04-08 13:58:04 +0000 @@ -226,11 +226,17 @@ const char *prompt, char *buf, int buf_len) { + int len; + fputs(prompt, stdout); fputc(' ', stdout); if (fgets(buf, buf_len, stdin) == 0) return 0; + len= strlen(buf); + if (len && buf[len-1]=='\n') + buf[len-1]=0; + return buf; }