diff --git a/include/mysqld_error.h b/include/mysqld_error.h index a6e23fbff3af67b37504ccf531298887876e1c3f..6b37b95cc450841462a3c4ee58030429d5a10867 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -300,4 +300,5 @@ #define ER_WARN_QC_RESIZE 1281 #define ER_BAD_FT_COLUMN 1282 #define ER_UNKNOWN_KEY_CACHE 1283 -#define ER_ERROR_MESSAGES 284 +#define ER_WARN_HOSTNAME_WONT_WORK 1284 +#define ER_ERROR_MESSAGES 285 diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index c40765ebf941adf3293c02f19b96915958352f26..02dd0b18940a4b14807ce1d749d36c72cdfdc339 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -296,3 +296,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 98540e1bd0a4dc552d60c46e44c3e338a73db379..f4dc64282e6fc5a726031f718f8bde7570f04e34 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -290,3 +290,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 44c9399b8216596a3c6708f1b665624c59c5075d..c034e18e05595019013ad76bd4cb056cb3d11cd6 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -298,3 +298,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index e4f7c27610b74af48abc899fe1b0ff1dd8d2df56..5e2c684450721c919bfed899bed897b01024c4fd 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -287,3 +287,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index dec488567fffe76e83b0b32f8ae43ca1d204e876..43204a3979b3fd8dbf499862695baa656c3c5f86 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -292,3 +292,4 @@ character-set=latin7 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index c41c927d539e4f755e61d189004f7cd0e73f2a48..b7b03250341d62d61ff124d2a9398ece2436b27b 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -287,3 +287,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 0425a709950fe3d0edcbf4442f1049abd37670d9..bb8aa296d5830d708f57b29f7cef50a1f4125ca7 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -299,3 +299,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 3cf5bbf592dd5ba5a3181a521de05b6dc330ec61..70913d58ff771ae8cf6f44c1324c8bef755d1cad 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -287,3 +287,4 @@ character-set=greek "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index f1b719ba7166d0783f355692cfc42fdce3380301..a79bf7b184c3ea92fb55ad3267640552811168be 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -289,3 +289,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index ed39950e9f11e651003aea69673c384d7857e984..c8fc5079c7550b315d1a971ce0e8aafe5fd4f202 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -287,3 +287,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 9760cd3f9e8cc6079b7e3c317b937519dd928e73..b8ece1ecf4ca244bf58c3843cc91f8f01be268f3 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -289,3 +289,4 @@ character-set=ujis "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 10eed3bb2deef83e3f4b4b705dc3c4f711ff02e2..d57c3e13efe48eab1869b88d1e0e3f85d8d1317b 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -287,3 +287,4 @@ character-set=euckr "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 7149eea8b100a40cfa552000f4130e137d12c77c..01f5078944928c0a0ad371b8a358351b572cedc2 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -289,3 +289,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index dc96d39f8dcbcb3dfe51eeedef235992ffb98d70..806729ccced587c2f9af8b37f62ccacbb50bb7a6 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -289,3 +289,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index b2b2e52ad7546e3d2e8f252e3a6da270000ec958..30c77b41ed0e7d80ebb79604f7e88c8324ad21cd 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -291,3 +291,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index c4a150d79bfa218238fb12d98b1ff60db5c66395..d4232007aedab0b68513e8f8bf8224af60f766bb 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -288,3 +288,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index dce141da20abbc138be63c1662f78bf639f57142..f4712f751801ef12bcafd9b7236778033eb26180 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -291,3 +291,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 27c1b49f4f044bb754fea05f92698e5b7f2abc44..30b0b8b4931ad58296c5ac8497feab7f202ce6bf 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -289,3 +289,4 @@ character-set=koi8r "Кеш запросов не может установить размер %lu, новый размер кеша зпросов - %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index 5311fa016dc3bad742bc3ae888ba3a958b2fb43a..4d2ce07e36947bc068c8c98388c203dad59fa703 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -282,3 +282,4 @@ character-set=cp1250 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 9355e8fc0c4c7c31057ee0cb2ef7185a8f6cb73a..fb062bc29e8f7efc5711a4fa56a80ddd1f9b1f54 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -295,3 +295,4 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 3cdcc3967d7f097582d70f7d0ffc887b45cfcf23..c4d4e1c9e93b3b80a628a22d329d78fd2bdeb30c 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -289,3 +289,4 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 17dcdb89ae6dbb327899fb288a4ca5a3e2eb47f7..143aa6af9eb3ad5f9695e2ecba661cb6756c49dc 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -287,3 +287,4 @@ character-set=latin1 "Storleken av "Query cache" kunde inte sДttas till %lu, ny storlek Дr %lu", "Kolumn '%-.64s' kan inte vara del av ett FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 99a09afde6c98e25e3eb5a91360273796ec7155c..416d6fac57250d6657542e9e397f580ccca2606f 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -292,3 +292,4 @@ character-set=koi8u "Кеш запитів неспроможен встановити розмір %lu, новий розмір кеша запитів - %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"Can't resolve '%s' if --skip-name-resolve active", diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b54e6a95bc5206e1954873a50302b11a105d7689..0ce544edda518dffb2878e018c98403df6d1e4a7 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -139,6 +139,8 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) READ_RECORD read_record_info; MYSQL_LOCK *lock; my_bool return_val=1; + bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; + DBUG_ENTER("acl_init"); if (!acl_cache) @@ -198,6 +200,13 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) host.access= get_access(table,2); host.access= fix_rights_for_db(host.access); host.sort= get_sort(2,host.host.hostname,host.db); + if (check_no_resolve && hostname_requires_resolving(host.host.hostname)) + { + sql_print_error("Error in table 'host' entry '%s|%s'. " + "Can't resolve '%s' if --skip-name-resolve active. Skipped", + host.host.hostname, host.db, host.host.hostname); + continue; + } #ifndef TO_BE_REMOVED if (table->fields == 8) { // Without grant @@ -259,6 +268,14 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) ACL_USER user; update_hostname(&user.host, get_field(&mem, table->field[0])); user.user= get_field(&mem, table->field[1]); + if (check_no_resolve && hostname_requires_resolving(user.host.hostname)) + { + sql_print_error("Error in table 'user' entry '%s@%s'. " + "Can't resolve '%s' if --skip-name-resolve active. Skipped", + user.user, user.host.hostname, user.host.hostname); + continue; + } + const char *password= get_field(&mem, table->field[2]); uint password_len= password ? strlen(password) : 0; set_user_salt(&user, password, password_len); @@ -353,6 +370,13 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) continue; } db.user=get_field(&mem, table->field[2]); + if (check_no_resolve && hostname_requires_resolving(db.host.hostname)) + { + sql_print_error("Error in table 'db' entry '%s %s@%s'. " + "Can't resolve '%s' if --skip-name-resolve active. Skipped", + db.db, db.user, db.host.hostname, db.host.hostname); + continue; + } db.access=get_access(table,3); db.access=fix_rights_for_db(db.access); db.sort=get_sort(3,db.host.hostname,db.db,db.user); @@ -1257,6 +1281,25 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname, (ip && !wild_compare(ip,host->hostname,0))); } +bool hostname_requires_resolving(const char *hostname) +{ + char cur; + if (!hostname) + return false; + int namelen= strlen(hostname); + int lhlen= strlen(my_localhost); + if ((namelen == lhlen) && + !my_strnncoll(&my_charset_latin1, (const uchar *)hostname, namelen, + (const uchar *)my_localhost, strlen(my_localhost))) + return false; + for (; (cur=*hostname); hostname++) + { + if ((cur != '%') && (cur != '_') && (cur != '.') && + ((cur < '0') || (cur > '9'))) + return true; + } + return false; +} /* Update grants in the user and database privilege tables @@ -2444,6 +2487,7 @@ my_bool grant_init(THD *org_thd) MYSQL_LOCK *lock; my_bool return_val= 1; TABLE *t_table, *c_table; + bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; DBUG_ENTER("grant_init"); grant_option = FALSE; @@ -2493,13 +2537,31 @@ my_bool grant_init(THD *org_thd) do { GRANT_TABLE *mem_check; - if (!(mem_check=new GRANT_TABLE(t_table,c_table)) || - mem_check->ok() && my_hash_insert(&column_priv_hash,(byte*) mem_check)) + if (!(mem_check=new GRANT_TABLE(t_table,c_table)) || mem_check->ok()) { /* This could only happen if we are out memory */ grant_option= FALSE; /* purecov: deadcode */ goto end_unlock; } + + if (check_no_resolve) + { + if (hostname_requires_resolving(mem_check->host)) + { + char buff[MAX_FIELD_WIDTH]; + sql_print_error("Error in table 'tables_priv' entry '%s %s@%s'. " + "Can't resolve '%s' if --skip-name-resolve active. Skipped", + mem_check->tname, mem_check->user, + mem_check->host, mem_check->host); + continue; + } + } + + if (my_hash_insert(&column_priv_hash,(byte*) mem_check)) + { + grant_option= FALSE; + goto end_unlock; + } } while (!t_table->file->index_next(t_table->record[0])); diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 7e96f2eaff185c0b72a9066eb8208bcd990bed36..8b8115b10db49b1af6bd81a4b78cc1990636f13b 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -131,6 +131,7 @@ class ACL_DB :public ACL_ACCESS /* prototypes */ +bool hostname_requires_resolving(const char *hostname); my_bool acl_init(THD *thd, bool dont_read_acl_tables); void acl_reload(THD *thd); void acl_free(bool end=0); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 017ef065012e4f3001b0ba2666593e7b9f21a73d..a73b27679957e55e2d01ef487288a2648507f15f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3183,6 +3183,19 @@ mysql_execute_command(THD *thd) } } } + if (specialflag & SPECIAL_NO_RESOLVE) + { + LEX_USER *user; + List_iterator <LEX_USER> user_list(lex->users_list); + while ((user=user_list++)) + { + if (hostname_requires_resolving(user->host.str)) + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_HOSTNAME_WONT_WORK, + ER(ER_WARN_HOSTNAME_WONT_WORK), + user->host.str); + } + } if (tables) { if (grant_option && check_grant(thd,