2842 Alexander Nozdrin 2009-08-05
Fix for Bug#43006 (main.skip_name_resolve fails on Windows in PB2).
The problem consisted of two parts:
- Windows resolves localhost to IPv6 '::1' address, instead of IPv4
'127.0.0.1', which is supposed by the server configuration.
To fix this issue a new grant to root@'::1' should be added into
mysql.user at database initialization
(mysql_system_tables_data.sql)
- ACL module didn't take IPv6 addresses into account.
When name resolving is off, the ACL module checks every hostname
from mysql.user whether it requires name resolving or not. The
code was written at IPv4 era, so it treated '::1' as a hostname.
In order to fix this issue, the ACL code was improved. The code
now supposes that:
- if a string contains any symbol from the {':', '%', '_', '/'}
set, it is an IPv6 address, or a patter, or a IPv4 network
address. Thus the string should not be resolved.
- if after that the string contains only digits and dots, it is
an IPv4 address. Thus the string should not be resolved.
Otherwise, it is a host name and should be resolved.
modified:
scripts/mysql_system_tables_data.sql
sql/sql_acl.cc
2841 Alexander Nozdrin 2009-08-04 [merge]
Merge from azalea
added:
mysql-test/collections/mysql-pe.push@
mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test
mysql-test/r/bug40113.result
mysql-test/r/bug46080.result
mysql-test/r/partition_not_embedded.result
mysql-test/r/partition_rename_longfilename.result
mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result
mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test
mysql-test/t/bug40113-master.opt
mysql-test/t/bug40113.test
mysql-test/t/bug46080-master.opt
mysql-test/t/bug46080.test
mysql-test/t/partition_not_embedded.test
mysql-test/t/partition_rename_longfilename.test
modified:
.bzr-mysql/default.conf
BUILD/check-cpu
CMakeLists.txt
Makefile.am
client/Makefile.am
client/mysql.cc
client/mysql_upgrade.c
client/mysqladmin.cc
client/mysqlbinlog.cc
client/mysqlcheck.c
client/mysqldump.c
client/mysqlimport.c
client/mysqlslap.c
cmd-line-utils/readline/Makefile.am
include/config-netware.h
include/config-win.h
include/my_base.h
include/my_global.h
include/myisammrg.h
include/violite.h
libmysql/Makefile.am
libmysql/Makefile.shared
libmysqld/Makefile.am
libmysqld/emb_qcache.h
libmysqld/lib_sql.cc
mysql-test/collections/default.experimental
mysql-test/collections/mysql-azalea.push
mysql-test/extra/binlog_tests/binlog.test
mysql-test/extra/scripts/monitor_disabled_tests/comments.txt
mysql-test/include/mix1.inc
mysql-test/r/create.result
mysql-test/r/debug_sync.result
mysql-test/r/derived.result
mysql-test/r/func_str.result
mysql-test/r/insert_select.result
mysql-test/r/locktrans_innodb.result
mysql-test/r/locktrans_myisam.result
mysql-test/r/merge.result
mysql-test/r/myisam.result
mysql-test/r/mysql.result
mysql-test/r/mysqlcheck.result
mysql-test/r/mysqldump.result
mysql-test/r/outfile_loaddata.result
mysql-test/r/parser_not_embedded.result
mysql-test/r/partition.result
mysql-test/r/partition_csv.result
mysql-test/r/signal.result
mysql-test/r/signal_demo3.result
mysql-test/r/sp_notembedded.result
mysql-test/r/subselect.result
mysql-test/r/subselect_no_mat.result
mysql-test/r/subselect_no_opts.result
mysql-test/r/subselect_no_semijoin.result
mysql-test/std_data/init_file.dat
mysql-test/suite/backup/r/backup_db_grants.result
mysql-test/suite/binlog/r/binlog_row_binlog.result
mysql-test/suite/binlog/r/binlog_stm_binlog.result
mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test
mysql-test/suite/parts/r/partition_syntax_innodb.result
mysql-test/suite/parts/r/partition_syntax_myisam.result
mysql-test/suite/rpl/r/rpl_concurrency_error.result
mysql-test/suite/rpl/r/rpl_locktrans_innodb.result
mysql-test/suite/rpl/r/rpl_locktrans_myisam.result
mysql-test/suite/rpl/r/rpl_sf.result
mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result
mysql-test/suite/rpl/t/disabled.def
mysql-test/suite/rpl/t/rpl_concurrency_error.test
mysql-test/suite/rpl/t/rpl_sf.test
mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test
mysql-test/t/create.test
mysql-test/t/derived.test
mysql-test/t/disabled.def
mysql-test/t/innodb_notembedded.test
mysql-test/t/insert_select.test
mysql-test/t/merge.test
mysql-test/t/myisam.test
mysql-test/t/mysql.test
mysql-test/t/mysql_upgrade.test
mysql-test/t/mysqlcheck.test
mysql-test/t/mysqldump.test
mysql-test/t/outfile_loaddata.test
mysql-test/t/partition.test
mysql-test/t/partition_csv.test
mysql-test/t/sp_notembedded.test
mysql-test/t/subselect.test
mysys/Makefile.am
mysys/array.c
mysys/my_handler_errors.h
sql-common/client.c
sql/Makefile.am
sql/backup/be_thread.cc
sql/event_data_objects.cc
sql/event_scheduler.cc
sql/events.cc
sql/field.cc
sql/ha_partition.cc
sql/handler.cc
sql/handler.h
sql/item.cc
sql/item_func.cc
sql/item_subselect.cc
sql/item_sum.cc
sql/lex.h
sql/log.cc
sql/log_event.cc
sql/mysql_priv.h
sql/mysqld.cc
sql/net_serv.cc
sql/protocol.cc
sql/protocol.h
sql/share/errmsg-utf8.txt
sql/share/errmsg.txt
sql/slave.cc
sql/sp.cc
sql/sp.h
sql/sp_head.cc
sql/sql_class.cc
sql/sql_class.h
sql/sql_delete.cc
sql/sql_handler.cc
sql/sql_insert.cc
sql/sql_load.cc
sql/sql_parse.cc
sql/sql_partition.cc
sql/sql_prepare.cc
sql/sql_repl.cc
sql/sql_select.cc
sql/sql_show.cc
sql/sql_string.cc
sql/sql_string.h
sql/sql_table.cc
sql/sql_update.cc
sql/sql_yacc.yy
sql/table.cc
sql/table.h
sql/unireg.h
storage/innobase/handler/ha_innodb.cc
storage/myisam/ha_myisam.cc
storage/myisam/myisam_backup_engine.cc
storage/myisammrg/ha_myisammrg.cc
storage/myisammrg/ha_myisammrg.h
storage/myisammrg/myrg_info.c
storage/myisammrg/myrg_open.c
storage/ndb/src/mgmsrv/Makefile.am
tests/Makefile.am
tests/mysql_client_test.c
vio/viosslfactories.c
=== modified file 'scripts/mysql_system_tables_data.sql'
--- a/scripts/mysql_system_tables_data.sql 2009-07-01 20:42:26 +0000
+++ b/scripts/mysql_system_tables_data.sql 2009-08-05 17:38:11 +0000
@@ -24,6 +24,7 @@ set @current_hostname= @@hostname;
INSERT INTO tmp_user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
REPLACE INTO tmp_user SELECT @current_hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0 FROM dual WHERE LOWER( @current_hostname) != 'localhost';
REPLACE INTO tmp_user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
+REPLACE INTO tmp_user VALUES (':1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
INSERT INTO tmp_user (host,user) VALUES ('localhost','');
INSERT INTO tmp_user (host,user) SELECT @current_hostname,'' FROM dual WHERE LOWER(@current_hostname ) != 'localhost';
INSERT INTO user SELECT * FROM tmp_user WHERE @had_user_table=0;
=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc 2009-07-16 12:51:04 +0000
+++ b/sql/sql_acl.cc 2009-08-05 17:38:11 +0000
@@ -1794,24 +1794,83 @@ static bool compare_hostname(const acl_h
(ip && !wild_compare(ip, host->hostname, 0)));
}
+/**
+ Check if the given host name needs to be resolved or not.
+ Host name has to be resolved if it actually contains *name*.
+
+ For example:
+ 192.168.1.1 --> FALSE
+ 192.168.1.0/255.255.255.0 --> FALSE
+ % --> FALSE
+ 192.168.1.% --> FALSE
+ AB% --> FALSE
+
+ AAAAFFFF --> TRUE (Hostname)
+ AAAA:FFFF:1234:5678 --> FALSE
+ ::1 --> FALSE
+
+ This function does not check if the given string is a valid host name or
+ not. It assumes that the argument is a valid host name.
+
+ @param hostname the string to check.
+
+ @return a flag telling if the argument needs to be resolved or not.
+ @retval TRUE the argument is a host name and needs to be resolved.
+ @retval FALSE the argument is either an IP address, or a patter and
+ should not be resolved.
+*/
+
bool hostname_requires_resolving(const char *hostname)
{
- char cur;
if (!hostname)
return FALSE;
- size_t namelen= strlen(hostname);
- size_t lhlen= strlen(my_localhost);
- if ((namelen == lhlen) &&
- !my_strnncoll(system_charset_info, (const uchar *)hostname, namelen,
- (const uchar *)my_localhost, strlen(my_localhost)))
+
+ /* Check if hostname is the localhost. */
+
+ size_t hostname_len= strlen(hostname);
+ size_t localhost_len= strlen(my_localhost);
+
+ if (hostname == my_localhost ||
+ hostname_len == localhost_len &&
+ !my_strnncoll(system_charset_info,
+ (const uchar *) hostname, hostname_len,
+ (const uchar *) my_localhost, strlen(my_localhost)))
+ {
return FALSE;
- for (; (cur=*hostname); hostname++)
+ }
+
+ /*
+ If the string contains any of {':', '%', '_', '/'}, it is definitely
+ not a host name:
+ - ':' means that the string is an IPv6 address;
+ - '%' or '_' means that the string is a pattern;
+ - '/' means that the string is an IPv4 network address;
+ */
+
+ for (const char *p= hostname; *p; ++p)
{
- if ((cur != '%') && (cur != '_') && (cur != '.') && (cur != '/') &&
- ((cur < '0') || (cur > '9')))
- return TRUE;
+ switch (*p) {
+ case ':':
+ case '%':
+ case '_':
+ case '/':
+ return FALSE;
+ }
}
- return FALSE;
+
+ /*
+ Now we have to tell a host name (ab.cd, 12.ab) from an IPv4 address
+ (12.34.56.78). The assumption is that if the string contains only
+ digits and dots, it is an IPv4 address. Otherwise -- a host name.
+ */
+
+ for (const char *p= hostname; *p; ++p)
+ {
+ if (*p != '.' && !my_isdigit(&my_charset_latin1, *p))
+ return TRUE; /* a "letter" has been found. */
+ }
+
+ return FALSE; /* all characters are either dots or digits. */
}
Attachment: [text/bzr-bundle] bzr/alik@sun.com-20090805173811-9fzt0ymcp9tsvn7k.bundle
| Thread |
|---|
| • bzr push into mysql branch (alik:2841 to 2842) Bug#43006 | Alexander Nozdrin | 5 Aug |