summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r--sql/sql_acl.cc40
1 files changed, 27 insertions, 13 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 55a364bdb2b..a5fb24b0796 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -121,6 +121,7 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
SYNOPSIS
acl_init()
+ thd Thread handler
dont_read_acl_tables Set to 1 if run with --skip-grant
RETURN VALUES
@@ -129,9 +130,9 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
*/
-my_bool acl_init(bool dont_read_acl_tables)
+my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
{
- THD *thd, *org_thd;
+ THD *thd;
TABLE_LIST tables[3];
TABLE *table;
READ_RECORD read_record_info;
@@ -142,7 +143,7 @@ my_bool acl_init(bool dont_read_acl_tables)
if (!acl_cache)
acl_cache=new hash_filo(ACL_CACHE_SIZE,0,0,
(hash_get_key) acl_entry_get_key,
- (void (*)(void*)) free);
+ (hash_free_key) free);
if (dont_read_acl_tables)
{
DBUG_RETURN(0); /* purecov: tested */
@@ -151,7 +152,6 @@ my_bool acl_init(bool dont_read_acl_tables)
/*
To be able to run this from boot, we allocate a temporary THD
*/
- org_thd=current_thd; // Save for restore
if (!(thd=new THD))
DBUG_RETURN(1); /* purecov: inspected */
thd->store_globals();
@@ -348,6 +348,11 @@ end:
delete thd;
if (org_thd)
org_thd->store_globals(); /* purecov: inspected */
+ else
+ {
+ /* Remember that we don't have a THD */
+ my_pthread_setspecific_ptr(THR_THD, 0);
+ }
DBUG_RETURN(return_val);
}
@@ -394,7 +399,7 @@ void acl_reload(THD *thd)
delete_dynamic(&acl_wild_hosts);
hash_free(&acl_check_hosts);
- if (acl_init(0))
+ if (acl_init(thd, 0))
{ // Error. Revert to old list
acl_free(); /* purecov: inspected */
acl_hosts=old_acl_hosts;
@@ -1157,7 +1162,7 @@ bool change_password(THD *thd, const char *host, const char *user,
acl_user->host.hostname ? acl_user->host.hostname : "",
new_password));
mysql_update_log.write(thd, buff, query_length);
- Query_log_event qinfo(thd, buff, query_length);
+ Query_log_event qinfo(thd, buff, query_length, 0);
mysql_bin_log.write(&qinfo);
DBUG_RETURN(0);
}
@@ -1420,8 +1425,13 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
strlen(thd->lex.x509_subject), system_charset_info);
break;
case SSL_TYPE_NOT_SPECIFIED:
- case SSL_TYPE_NONE: // Impossible
- break; // Nothing to do
+ break;
+ case SSL_TYPE_NONE:
+ table->field[24]->store("", 0, system_charset_info);
+ table->field[25]->store("", 0, system_charset_info);
+ table->field[26]->store("", 0, system_charset_info);
+ table->field[27]->store("", 0, system_charset_info);
+ break;
}
USER_RESOURCES mqh = thd->lex.mqh;
@@ -2342,9 +2352,9 @@ void grant_free(void)
/* Init grant array if possible */
-my_bool grant_init(void)
+my_bool grant_init(THD *org_thd)
{
- THD *thd, *org_thd;
+ THD *thd;
TABLE_LIST tables[2];
MYSQL_LOCK *lock;
my_bool return_val= 1;
@@ -2361,7 +2371,6 @@ my_bool grant_init(void)
if (!initialized)
DBUG_RETURN(0); /* purecov: tested */
- org_thd=current_thd;
if (!(thd=new THD))
DBUG_RETURN(1); /* purecov: deadcode */
thd->store_globals();
@@ -2419,13 +2428,18 @@ end:
delete thd;
if (org_thd)
org_thd->store_globals();
+ else
+ {
+ /* Remember that we don't have a THD */
+ my_pthread_setspecific_ptr(THR_THD, 0);
+ }
DBUG_RETURN(return_val);
}
/* Reload grant array if possible */
-void grant_reload(void)
+void grant_reload(THD *thd)
{
HASH old_hash_tables;bool old_grant_option;
MEM_ROOT old_mem;
@@ -2439,7 +2453,7 @@ void grant_reload(void)
old_grant_option = grant_option;
old_mem = memex;
- if (grant_init())
+ if (grant_init(thd))
{ // Error. Revert to old hash
grant_free(); /* purecov: deadcode */
hash_tables=old_hash_tables; /* purecov: deadcode */