1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

WL#7076: Backporting wl6715 to support both formats in 5.5, 5.6, 5.7

Backporting wl6715 to mysql-5.5
This commit is contained in:
Ashish Agarwal
2013-07-02 11:58:39 +05:30
parent 8723f47391
commit e879caf845
16 changed files with 288 additions and 118 deletions

View File

@ -675,7 +675,7 @@ char *thd_security_context(THD *thd, char *buffer, unsigned int length,
unsigned int max_query_len)
{
String str(buffer, length, &my_charset_latin1);
const Security_context *sctx= &thd->main_security_ctx;
Security_context *sctx= &thd->main_security_ctx;
char header[256];
int len;
/*
@ -695,16 +695,16 @@ char *thd_security_context(THD *thd, char *buffer, unsigned int length,
str.length(0);
str.append(header, len);
if (sctx->host)
if (sctx->get_host()->length())
{
str.append(' ');
str.append(sctx->host);
str.append(sctx->get_host()->ptr());
}
if (sctx->ip)
if (sctx->get_ip()->length())
{
str.append(' ');
str.append(sctx->ip);
str.append(sctx->get_ip()->ptr());
}
if (sctx->user)
@ -3341,7 +3341,10 @@ void THD::set_status_var_init()
void Security_context::init()
{
host= user= ip= external_user= 0;
user= 0;
ip.set("", 0, system_charset_info);
host.set("", 0, system_charset_info);
external_user.set("", 0, system_charset_info);
host_or_ip= "connecting host";
priv_user[0]= priv_host[0]= proxy_user[0]= '\0';
master_access= 0;
@ -3350,29 +3353,35 @@ void Security_context::init()
#endif
}
void Security_context::destroy()
{
// If not pointer to constant
if (host != my_localhost)
if (host.ptr() != my_localhost && host.length())
{
my_free(host);
host= NULL;
char *c= (char *) host.ptr();
host.set("", 0, system_charset_info);
my_free(c);
}
if (user != delayed_user)
if (user)
{
my_free(user);
user= NULL;
}
if (external_user)
if (external_user.length())
{
my_free(external_user);
user= NULL;
char *c= (char *) external_user.ptr();
external_user.set("", 0, system_charset_info);
my_free(c);
}
if (ip.length())
{
char *c= (char *) ip.ptr();
ip.set("", 0, system_charset_info);
my_free(c);
}
my_free(ip);
ip= NULL;
}
@ -3392,6 +3401,45 @@ bool Security_context::set_user(char *user_arg)
return user == 0;
}
String *Security_context::get_host()
{
return (&host);
}
String *Security_context::get_ip()
{
return (&ip);
}
String *Security_context::get_external_user()
{
return (&external_user);
}
void Security_context::set_host(const char *str)
{
uint len= str ? strlen(str) : 0;
host.set(str, len, system_charset_info);
}
void Security_context::set_ip(const char *str)
{
uint len= str ? strlen(str) : 0;
ip.set(str, len, system_charset_info);
}
void Security_context::set_external_user(const char *str)
{
uint len= str ? strlen(str) : 0;
external_user.set(str, len, system_charset_info);
}
void Security_context::set_host(const char * str, size_t len)
{
host.set(str, len, system_charset_info);
host.c_ptr_quick();
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/**
Initialize this security context from the passed in credentials