mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-33506 Show original IP in the "aborted" message.
Add "real ip:<ip_or_localhost>" part to the aborted message Only for proxy-protocoled connection, so it does not not to cause confusion to normal users.
This commit is contained in:
@ -478,6 +478,7 @@ typedef struct st_net {
|
|||||||
my_bool thread_specific_malloc;
|
my_bool thread_specific_malloc;
|
||||||
unsigned char compress;
|
unsigned char compress;
|
||||||
my_bool pkt_nr_can_be_reset;
|
my_bool pkt_nr_can_be_reset;
|
||||||
|
my_bool using_proxy_protocol;
|
||||||
/*
|
/*
|
||||||
Pointer to query object in query cache, do not equal NULL (0) for
|
Pointer to query object in query cache, do not equal NULL (0) for
|
||||||
queries in cache that have not stored its results yet
|
queries in cache that have not stored its results yet
|
||||||
|
@ -261,3 +261,4 @@ SET @@global.character_set_server= @save_character_set_server;
|
|||||||
SET @@global.collation_server= @save_collation_server;
|
SET @@global.collation_server= @save_collation_server;
|
||||||
SET @@global.character_set_client= @save_character_set_client;
|
SET @@global.character_set_client= @save_character_set_client;
|
||||||
SET @@global.collation_connection= @save_collation_connection;
|
SET @@global.collation_connection= @save_collation_connection;
|
||||||
|
FOUND 1 /Aborted connection.*'u' host: '192.0.2.1' real ip: '(localhost|::1)'/ in mysqld.1.err
|
||||||
|
@ -57,3 +57,9 @@ SET @@global.character_set_server= @save_character_set_server;
|
|||||||
SET @@global.collation_server= @save_collation_server;
|
SET @@global.collation_server= @save_collation_server;
|
||||||
SET @@global.character_set_client= @save_character_set_client;
|
SET @@global.character_set_client= @save_character_set_client;
|
||||||
SET @@global.collation_connection= @save_collation_connection;
|
SET @@global.collation_connection= @save_collation_connection;
|
||||||
|
|
||||||
|
# Search for "real ip" in Aborted message
|
||||||
|
# This is indicator for abort of the proxied connections.
|
||||||
|
let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err;
|
||||||
|
let SEARCH_PATTERN= Aborted connection.*'u' host: '192.0.2.1' real ip: '(localhost|::1)';
|
||||||
|
source include/search_pattern_in_file.inc;
|
||||||
|
@ -163,6 +163,7 @@ my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags)
|
|||||||
net->net_skip_rest_factor= 0;
|
net->net_skip_rest_factor= 0;
|
||||||
net->last_errno=0;
|
net->last_errno=0;
|
||||||
net->pkt_nr_can_be_reset= 0;
|
net->pkt_nr_can_be_reset= 0;
|
||||||
|
net->using_proxy_protocol= 0;
|
||||||
net->thread_specific_malloc= MY_TEST(my_flags & MY_THREAD_SPECIFIC);
|
net->thread_specific_malloc= MY_TEST(my_flags & MY_THREAD_SPECIFIC);
|
||||||
net->thd= 0;
|
net->thd= 0;
|
||||||
#ifdef MYSQL_SERVER
|
#ifdef MYSQL_SERVER
|
||||||
@ -217,6 +218,7 @@ void net_end(NET *net)
|
|||||||
DBUG_ENTER("net_end");
|
DBUG_ENTER("net_end");
|
||||||
my_free(net->buff);
|
my_free(net->buff);
|
||||||
net->buff=0;
|
net->buff=0;
|
||||||
|
net->using_proxy_protocol= 0;
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -955,6 +957,7 @@ static handle_proxy_header_result handle_proxy_header(NET *net)
|
|||||||
return RETRY;
|
return RETRY;
|
||||||
/* Change peer address in THD and ACL structures.*/
|
/* Change peer address in THD and ACL structures.*/
|
||||||
uint host_errors;
|
uint host_errors;
|
||||||
|
net->using_proxy_protocol= 1;
|
||||||
return (handle_proxy_header_result)thd_set_peer_addr(thd,
|
return (handle_proxy_header_result)thd_set_peer_addr(thd,
|
||||||
&(peer_info.peer_addr), NULL, peer_info.port,
|
&(peer_info.peer_addr), NULL, peer_info.port,
|
||||||
false, &host_errors);
|
false, &host_errors);
|
||||||
|
@ -4258,22 +4258,22 @@ ER_ERROR_DURING_CHECKPOINT
|
|||||||
swe "Fick fel %M vid CHECKPOINT"
|
swe "Fick fel %M vid CHECKPOINT"
|
||||||
ukr "Отримано помилку %M під час CHECKPOINT"
|
ukr "Отримано помилку %M під час CHECKPOINT"
|
||||||
ER_NEW_ABORTING_CONNECTION 08S01
|
ER_NEW_ABORTING_CONNECTION 08S01
|
||||||
chi "终止的连接 %lld 到数据库: '%-.192s' 用户: '%-.48s' 主机: '%-.64s' (%-.64s)"
|
chi "终止的连接 %lld 到数据库: '%-.192s' 用户: '%-.48s' 主机: '%-.64s'%-.64s (%-.64s)"
|
||||||
cze "Spojení %lld do databáze: '%-.192s' uživatel: '%-.48s' stroj: '%-.64s' (%-.64s) bylo přerušeno"
|
cze "Spojení %lld do databáze: '%-.192s' uživatel: '%-.48s' stroj: '%-.64s'%-.64s (%-.64s) bylo přerušeno"
|
||||||
dan "Afbrød forbindelsen %lld til databasen '%-.192s' bruger: '%-.48s' vært: '%-.64s' (%-.64s)"
|
dan "Afbrød forbindelsen %lld til databasen '%-.192s' bruger: '%-.48s' vært: '%-.64s'%-.64s (%-.64s)"
|
||||||
eng "Aborted connection %lld to db: '%-.192s' user: '%-.48s' host: '%-.64s' (%-.64s)"
|
eng "Aborted connection %lld to db: '%-.192s' user: '%-.48s' host: '%-.64s'%-.64s (%-.64s)"
|
||||||
est "Ühendus katkestatud %lld andmebaas: '%-.192s' kasutaja: '%-.48s' masin: '%-.64s' (%-.64s)"
|
est "Ühendus katkestatud %lld andmebaas: '%-.192s' kasutaja: '%-.48s' masin: '%-.64s'%-.64s (%-.64s)"
|
||||||
fre "Connection %lld avortée vers la bd: '%-.192s' utilisateur: '%-.48s' hôte: '%-.64s' (%-.64s)"
|
fre "Connection %lld avortée vers la bd: '%-.192s' utilisateur: '%-.48s' hôte: '%-.64s'%-.64s (%-.64s)"
|
||||||
ger "Abbruch der Verbindung %lld zur Datenbank '%-.192s'. Benutzer: '%-.48s', Host: '%-.64s' (%-.64s)"
|
ger "Abbruch der Verbindung %lld zur Datenbank '%-.192s'. Benutzer: '%-.48s', Host: '%-.64s'%-.64s (%-.64s)"
|
||||||
ita "Interrotta la connessione %lld al db: ''%-.192s' utente: '%-.48s' host: '%-.64s' (%-.64s)"
|
ita "Interrotta la connessione %lld al db: ''%-.192s' utente: '%-.48s' host: '%-.64s'%-.64s (%-.64s)"
|
||||||
jpn "接続 %lld が中断されました。データベース: '%-.192s' ユーザー: '%-.48s' ホスト: '%-.64s' (%-.64s)"
|
jpn "接続 %lld が中断されました。データベース: '%-.192s' ユーザー: '%-.48s' ホスト: '%-.64s'%-.64s (%-.64s)"
|
||||||
nla "Afgebroken verbinding %lld naar db: '%-.192s' gebruiker: '%-.48s' host: '%-.64s' (%-.64s)"
|
nla "Afgebroken verbinding %lld naar db: '%-.192s' gebruiker: '%-.48s' host: '%-.64s'%-.64s (%-.64s)"
|
||||||
por "Conexão %lld abortada para banco de dados '%-.192s' - usuário '%-.48s' - 'host' '%-.64s' ('%-.64s')"
|
por "Conexão %lld abortada para banco de dados '%-.192s' - usuário '%-.48s' - 'host' '%-.64s'%-.64s ('%-.64s')"
|
||||||
rus "Прервано соединение %lld к базе данных '%-.192s' пользователя '%-.48s' с хоста '%-.64s' (%-.64s)"
|
rus "Прервано соединение %lld к базе данных '%-.192s' пользователя '%-.48s' с хоста '%-.64s'%-.64s (%-.64s)"
|
||||||
serbian "Prekinuta konekcija broj %lld ka bazi: '%-.192s' korisnik je bio: '%-.48s' a host: '%-.64s' (%-.64s)"
|
serbian "Prekinuta konekcija broj %lld ka bazi: '%-.192s' korisnik je bio: '%-.48s' a host: '%-.64s'%-.64s (%-.64s)"
|
||||||
spa "Abortada conexión %lld a la base de datos: '%-.192s' usuario: '%-.48s' equipo: '%-.64s' (%-.64s)"
|
spa "Abortada conexión %lld a la base de datos: '%-.192s' usuario: '%-.48s' equipo: '%-.64s'%-.64s (%-.64s)"
|
||||||
swe "Avbröt länken för tråd %lld till db '%-.192s', användare '%-.48s', host '%-.64s' (%-.64s)"
|
swe "Avbröt länken för tråd %lld till db '%-.192s', användare '%-.48s', host '%-.64s'%-.64s (%-.64s)"
|
||||||
ukr "Перервано з'єднання %lld до бази данних: '%-.192s' користувач: '%-.48s' хост: '%-.64s' (%-.64s)"
|
ukr "Перервано з'єднання %lld до бази данних: '%-.192s' користувач: '%-.48s' хост: '%-.64s'%-.64s (%-.64s)"
|
||||||
ER_UNUSED_10
|
ER_UNUSED_10
|
||||||
eng "You should never see it"
|
eng "You should never see it"
|
||||||
spa "Nunca lo debería vd de ver"
|
spa "Nunca lo debería vd de ver"
|
||||||
|
@ -5218,11 +5218,29 @@ public:
|
|||||||
{
|
{
|
||||||
if (global_system_variables.log_warnings > threshold)
|
if (global_system_variables.log_warnings > threshold)
|
||||||
{
|
{
|
||||||
|
char real_ip_str[64];
|
||||||
|
real_ip_str[0]= 0;
|
||||||
|
|
||||||
|
/* For proxied connections, add the real IP to the warning message */
|
||||||
|
if (net.using_proxy_protocol && net.vio)
|
||||||
|
{
|
||||||
|
if(net.vio->localhost)
|
||||||
|
snprintf(real_ip_str, sizeof(real_ip_str), " real ip: 'localhost'");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char buf[INET6_ADDRSTRLEN];
|
||||||
|
if (!vio_getnameinfo((sockaddr *)&(net.vio->remote), buf,
|
||||||
|
sizeof(buf),NULL, 0, NI_NUMERICHOST))
|
||||||
|
{
|
||||||
|
snprintf(real_ip_str, sizeof(real_ip_str), " real ip: '%s'",buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Security_context *sctx= &main_security_ctx;
|
Security_context *sctx= &main_security_ctx;
|
||||||
sql_print_warning(ER_THD(this, ER_NEW_ABORTING_CONNECTION),
|
sql_print_warning(ER_THD(this, ER_NEW_ABORTING_CONNECTION),
|
||||||
thread_id, (db.str ? db.str : "unconnected"),
|
thread_id, (db.str ? db.str : "unconnected"),
|
||||||
sctx->user ? sctx->user : "unauthenticated",
|
sctx->user ? sctx->user : "unauthenticated",
|
||||||
sctx->host_or_ip, reason);
|
sctx->host_or_ip, real_ip_str, reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1274,7 +1274,7 @@ void prepare_new_connection_state(THD* thd)
|
|||||||
thd->thread_id,
|
thd->thread_id,
|
||||||
thd->db.str ? thd->db.str : "unconnected",
|
thd->db.str ? thd->db.str : "unconnected",
|
||||||
sctx->user ? sctx->user : "unauthenticated",
|
sctx->user ? sctx->user : "unauthenticated",
|
||||||
sctx->host_or_ip, "init_connect command failed");
|
sctx->host_or_ip, "", "init_connect command failed");
|
||||||
thd->server_status&= ~SERVER_STATUS_CLEAR_SET;
|
thd->server_status&= ~SERVER_STATUS_CLEAR_SET;
|
||||||
thd->protocol->end_statement();
|
thd->protocol->end_statement();
|
||||||
thd->killed = KILL_CONNECTION;
|
thd->killed = KILL_CONNECTION;
|
||||||
|
@ -20564,7 +20564,6 @@ typedef struct {
|
|||||||
#ifndef EMBEDDED_LIBRARY
|
#ifndef EMBEDDED_LIBRARY
|
||||||
static void test_proxy_header_tcp(const char *ipaddr, int port)
|
static void test_proxy_header_tcp(const char *ipaddr, int port)
|
||||||
{
|
{
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
int family = (strchr(ipaddr,':') == NULL)?AF_INET:AF_INET6;
|
int family = (strchr(ipaddr,':') == NULL)?AF_INET:AF_INET6;
|
||||||
@ -20639,6 +20638,11 @@ static void test_proxy_header_tcp(const char *ipaddr, int port)
|
|||||||
DIE_UNLESS(strncmp(row[0], normalized_addr, addrlen) == 0);
|
DIE_UNLESS(strncmp(row[0], normalized_addr, addrlen) == 0);
|
||||||
DIE_UNLESS(atoi(row[0] + addrlen+1) == port);
|
DIE_UNLESS(atoi(row[0] + addrlen+1) == port);
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
|
if (i == 0 && !strcmp(ipaddr,"192.0.2.1"))
|
||||||
|
{
|
||||||
|
/* do "dirty" close, to get aborted message in error log.*/
|
||||||
|
mariadb_cancel(m);
|
||||||
|
}
|
||||||
mysql_close(m);
|
mysql_close(m);
|
||||||
}
|
}
|
||||||
sprintf(query,"DROP USER 'u'@'%s'",normalized_addr);
|
sprintf(query,"DROP USER 'u'@'%s'",normalized_addr);
|
||||||
|
Reference in New Issue
Block a user