mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-24312 master_host has 60 character limit, increase to 255 bytes
Also increase user name up to 128. The work was started by Rucha Deodhar <rucha.deodhar@mariadb.com>, contains audit plugin fixes by Alexey Botchkov <holyfoot@askmonty.org>.
This commit is contained in:
@@ -142,6 +142,13 @@ static int loc_file_errno;
|
||||
#define logger_init_mutexts loc_logger_init_mutexts
|
||||
#define logger_time_to_rotate loc_logger_time_to_rotate
|
||||
|
||||
#ifndef HOSTNAME_LENGTH
|
||||
#define HOSTNAME_LENGTH 255
|
||||
#endif
|
||||
#ifndef USERNAME_CHAR_LENGTH
|
||||
#define USERNAME_CHAR_LENGTH 128
|
||||
#endif
|
||||
|
||||
|
||||
static size_t loc_write(File Filedes, const uchar *Buffer, size_t Count)
|
||||
{
|
||||
@@ -279,6 +286,7 @@ static my_off_t loc_tell(File fd)
|
||||
|
||||
extern MYSQL_PLUGIN_IMPORT char server_version[];
|
||||
static const char *serv_ver= NULL;
|
||||
const char *(*thd_priv_host_ptr)(MYSQL_THD thd, size_t *length);
|
||||
static int started_mysql= 0;
|
||||
static int mysql_57_started= 0;
|
||||
static int debug_server_started= 0;
|
||||
@@ -305,7 +313,7 @@ static char *big_buffer= NULL;
|
||||
static size_t big_buffer_alloced= 0;
|
||||
static unsigned int query_log_limit= 0;
|
||||
|
||||
static char servhost[256];
|
||||
static char servhost[HOSTNAME_LENGTH+1];
|
||||
static uint servhost_len;
|
||||
static char *syslog_ident;
|
||||
static char syslog_ident_buffer[128]= "mysql-server_auditing";
|
||||
@@ -317,9 +325,9 @@ struct connection_info
|
||||
unsigned long long query_id;
|
||||
char db[256];
|
||||
int db_length;
|
||||
char user[64];
|
||||
char user[USERNAME_CHAR_LENGTH+1];
|
||||
int user_length;
|
||||
char host[64];
|
||||
char host[HOSTNAME_LENGTH+1];
|
||||
int host_length;
|
||||
char ip[64];
|
||||
int ip_length;
|
||||
@@ -328,9 +336,9 @@ struct connection_info
|
||||
char query_buffer[1024];
|
||||
time_t query_time;
|
||||
int log_always;
|
||||
char proxy[64];
|
||||
char proxy[USERNAME_CHAR_LENGTH+1];
|
||||
int proxy_length;
|
||||
char proxy_host[64];
|
||||
char proxy_host[HOSTNAME_LENGTH+1];
|
||||
int proxy_host_length;
|
||||
};
|
||||
|
||||
@@ -1142,10 +1150,10 @@ static void setup_connection_simple(struct connection_info *ci)
|
||||
}
|
||||
|
||||
|
||||
#define MAX_HOSTNAME 61
|
||||
#define MAX_HOSTNAME (HOSTNAME_LENGTH + 1) /* len+1 in mysql.user */
|
||||
#define USERNAME_LENGTH 384
|
||||
|
||||
static void setup_connection_connect(struct connection_info *cn,
|
||||
static void setup_connection_connect(MYSQL_THD thd,struct connection_info *cn,
|
||||
const struct mysql_event_connection *event)
|
||||
{
|
||||
cn->query_id= 0;
|
||||
@@ -1163,17 +1171,26 @@ static void setup_connection_connect(struct connection_info *cn,
|
||||
cn->header= 0;
|
||||
if (event->proxy_user && event->proxy_user[0])
|
||||
{
|
||||
const char *priv_host= event->proxy_user +
|
||||
sizeof(char[MAX_HOSTNAME+USERNAME_LENGTH+5]);
|
||||
const char *priv_host;
|
||||
size_t priv_host_length;
|
||||
|
||||
if (mysql_57_started)
|
||||
if (thd_priv_host_ptr)
|
||||
{
|
||||
priv_host+= sizeof(size_t);
|
||||
priv_host_length= *(size_t *) (priv_host + MAX_HOSTNAME);
|
||||
priv_host= (*thd_priv_host_ptr)(thd, &priv_host_length);
|
||||
}
|
||||
else
|
||||
priv_host_length= strlen(priv_host);
|
||||
{
|
||||
// 5 is "'" around host and user and "@"
|
||||
priv_host= event->proxy_user +
|
||||
sizeof(char[MAX_HOSTNAME + USERNAME_LENGTH + 5]);
|
||||
if (mysql_57_started)
|
||||
{
|
||||
priv_host+= sizeof(size_t);
|
||||
priv_host_length= *(size_t *) (priv_host + MAX_HOSTNAME);
|
||||
}
|
||||
else
|
||||
priv_host_length= strlen(priv_host);
|
||||
}
|
||||
|
||||
|
||||
get_str_n(cn->proxy, &cn->proxy_length, sizeof(cn->proxy),
|
||||
@@ -1974,7 +1991,7 @@ static struct connection_info ci_disconnect_buffer;
|
||||
#define AA_FREE_CONNECTION 1
|
||||
#define AA_CHANGE_USER 2
|
||||
|
||||
static void update_connection_info(struct connection_info *cn,
|
||||
static void update_connection_info(MYSQL_THD thd, struct connection_info *cn,
|
||||
unsigned int event_class, const void *ev, int *after_action)
|
||||
{
|
||||
*after_action= 0;
|
||||
@@ -2095,7 +2112,7 @@ static void update_connection_info(struct connection_info *cn,
|
||||
switch (event->event_subclass)
|
||||
{
|
||||
case MYSQL_AUDIT_CONNECTION_CONNECT:
|
||||
setup_connection_connect(cn, event);
|
||||
setup_connection_connect(thd, cn, event);
|
||||
break;
|
||||
case MYSQL_AUDIT_CONNECTION_CHANGE_USER:
|
||||
*after_action= AA_CHANGE_USER;
|
||||
@@ -2153,7 +2170,7 @@ void auditing(MYSQL_THD thd, unsigned int event_class, const void *ev)
|
||||
cn= get_loc_info(thd);
|
||||
}
|
||||
|
||||
update_connection_info(cn, event_class, ev, &after_action);
|
||||
update_connection_info(thd, cn, event_class, ev, &after_action);
|
||||
|
||||
if (!logging)
|
||||
{
|
||||
@@ -2497,6 +2514,8 @@ static int server_audit_init(void *p __attribute__((unused)))
|
||||
}
|
||||
if (!my_hash_init_ptr)
|
||||
return 1;
|
||||
|
||||
thd_priv_host_ptr= dlsym(RTLD_DEFAULT, "thd_priv_host");
|
||||
}
|
||||
|
||||
if(!(int_mysql_data_home= find_sym("mysql_data_home")))
|
||||
|
Reference in New Issue
Block a user