mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-4379 expand MariaDB dual-stack support
when binding to wildcard addresses (no --bind is specified or --bind=*), bind to both ipv6 and ipv4 as mysql-5.6 is doing.
This commit is contained in:
87
mysql-test/r/ipv4_and_ipv6.result
Normal file
87
mysql-test/r/ipv4_and_ipv6.result
Normal file
@ -0,0 +1,87 @@
|
||||
=============Test of '::1' ========================================
|
||||
mysqld is alive
|
||||
CREATE USER testuser@'::1' identified by '1234';
|
||||
GRANT ALL ON test.* TO testuser@'::1';
|
||||
SHOW GRANTS FOR testuser@'::1';
|
||||
Grants for testuser@::1
|
||||
GRANT USAGE ON *.* TO 'testuser'@'::1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
|
||||
GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'::1'
|
||||
SET @nip= inet_aton('::1');
|
||||
SELECT @nip;
|
||||
@nip
|
||||
NULL
|
||||
SELECT inet_ntoa(@nip);
|
||||
inet_ntoa(@nip)
|
||||
NULL
|
||||
SELECT USER();
|
||||
USER()
|
||||
root@localhost
|
||||
SELECT current_user();
|
||||
current_user()
|
||||
root@localhost
|
||||
SHOW PROCESSLIST;
|
||||
REVOKE ALL ON test.* FROM testuser@'::1';
|
||||
RENAME USER testuser@'::1' to testuser1@'::1';
|
||||
SET PASSWORD FOR testuser1@'::1' = PASSWORD ('9876');
|
||||
SELECT USER();
|
||||
USER()
|
||||
root@localhost
|
||||
DROP USER testuser1@'::1';
|
||||
=============Test of '127.0.0.1' (IPv4) ===========================
|
||||
mysqld is alive
|
||||
CREATE USER testuser@'127.0.0.1' identified by '1234';
|
||||
GRANT ALL ON test.* TO testuser@'127.0.0.1';
|
||||
SHOW GRANTS FOR testuser@'127.0.0.1';
|
||||
Grants for testuser@127.0.0.1
|
||||
GRANT USAGE ON *.* TO 'testuser'@'127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
|
||||
GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'127.0.0.1'
|
||||
SET @nip= inet_aton('127.0.0.1');
|
||||
SELECT @nip;
|
||||
@nip
|
||||
2130706433
|
||||
SELECT inet_ntoa(@nip);
|
||||
inet_ntoa(@nip)
|
||||
127.0.0.1
|
||||
SELECT USER();
|
||||
USER()
|
||||
root@localhost
|
||||
SELECT current_user();
|
||||
current_user()
|
||||
root@localhost
|
||||
SHOW PROCESSLIST;
|
||||
REVOKE ALL ON test.* FROM testuser@'127.0.0.1';
|
||||
RENAME USER testuser@'127.0.0.1' to testuser1@'127.0.0.1';
|
||||
SET PASSWORD FOR testuser1@'127.0.0.1' = PASSWORD ('9876');
|
||||
SELECT USER();
|
||||
USER()
|
||||
root@localhost
|
||||
DROP USER testuser1@'127.0.0.1';
|
||||
=============Test of '0:0:0:0:0:FFFF:127.0.0.1' ===================
|
||||
mysqld is alive
|
||||
CREATE USER testuser@'0:0:0:0:0:FFFF:127.0.0.1' identified by '1234';
|
||||
GRANT ALL ON test.* TO testuser@'0:0:0:0:0:FFFF:127.0.0.1';
|
||||
SHOW GRANTS FOR testuser@'0:0:0:0:0:FFFF:127.0.0.1';
|
||||
Grants for testuser@0:0:0:0:0:ffff:127.0.0.1
|
||||
GRANT USAGE ON *.* TO 'testuser'@'0:0:0:0:0:ffff:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
|
||||
GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0:0:0:0:0:ffff:127.0.0.1'
|
||||
SET @nip= inet_aton('0:0:0:0:0:FFFF:127.0.0.1');
|
||||
SELECT @nip;
|
||||
@nip
|
||||
NULL
|
||||
SELECT inet_ntoa(@nip);
|
||||
inet_ntoa(@nip)
|
||||
NULL
|
||||
SELECT USER();
|
||||
USER()
|
||||
root@localhost
|
||||
SELECT current_user();
|
||||
current_user()
|
||||
root@localhost
|
||||
SHOW PROCESSLIST;
|
||||
REVOKE ALL ON test.* FROM testuser@'0:0:0:0:0:FFFF:127.0.0.1';
|
||||
RENAME USER testuser@'0:0:0:0:0:FFFF:127.0.0.1' to testuser1@'0:0:0:0:0:FFFF:127.0.0.1';
|
||||
SET PASSWORD FOR testuser1@'0:0:0:0:0:FFFF:127.0.0.1' = PASSWORD ('9876');
|
||||
SELECT USER();
|
||||
USER()
|
||||
root@localhost
|
||||
DROP USER testuser1@'0:0:0:0:0:FFFF:127.0.0.1';
|
1
mysql-test/t/ipv4_and_ipv6.opt
Normal file
1
mysql-test/t/ipv4_and_ipv6.opt
Normal file
@ -0,0 +1 @@
|
||||
--skip-name-resolve --bind-address=*
|
18
mysql-test/t/ipv4_and_ipv6.test
Normal file
18
mysql-test/t/ipv4_and_ipv6.test
Normal file
@ -0,0 +1,18 @@
|
||||
--source include/check_ipv6.inc
|
||||
--source include/not_embedded.inc
|
||||
|
||||
echo =============Test of '::1' ========================================;
|
||||
let $IPv6= ::1;
|
||||
--source include/ipv6_clients.inc
|
||||
--source include/ipv6.inc
|
||||
|
||||
echo =============Test of '127.0.0.1' (IPv4) ===========================;
|
||||
let $IPv6= 127.0.0.1;
|
||||
--source include/ipv6_clients.inc
|
||||
--source include/ipv6.inc
|
||||
|
||||
echo =============Test of '0:0:0:0:0:FFFF:127.0.0.1' ===================;
|
||||
let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1;
|
||||
--source include/ipv6_clients.inc
|
||||
--source include/ipv6.inc
|
||||
|
@ -2384,6 +2384,21 @@ static MYSQL_SOCKET activate_tcp_port(uint port)
|
||||
unireg_abort(1); /* purecov: tested */
|
||||
}
|
||||
|
||||
/*
|
||||
special case: for wildcard addresses prefer ipv6 over ipv4,
|
||||
because we later switch off IPV6_V6ONLY, so ipv6 wildcard
|
||||
addresses will work for ipv4 too
|
||||
*/
|
||||
if ((my_bind_addr_str == NULL || strcmp(my_bind_addr_str, "*") == 0)
|
||||
&& ai->ai_family == AF_INET && ai->ai_next
|
||||
&& ai->ai_next->ai_family == AF_INET6)
|
||||
{
|
||||
a= ai;
|
||||
ai= ai->ai_next;
|
||||
a->ai_next= ai->ai_next;
|
||||
ai->ai_next= a;
|
||||
}
|
||||
|
||||
for (a= ai; a != NULL; a= a->ai_next)
|
||||
{
|
||||
ip_sock= mysql_socket_socket(key_socket_tcpip, a->ai_family,
|
||||
|
Reference in New Issue
Block a user