summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
diff options
context:
space:
mode:
authorunknown <Li-Bing.Song@sun.com>2010-07-04 12:36:09 +0800
committerunknown <Li-Bing.Song@sun.com>2010-07-04 12:36:09 +0800
commit43ef6da6ef00d9b3a5da218df1629115c1f47b9f (patch)
tree4c324a2eff6dec16929d5e86816393b3080c54ca /sql/sql_acl.cc
parent878bf8d1b0850fc84d8ba3832569ee934adce299 (diff)
parent1a17d7e8079b4cbda51c311eceaea38b407556f3 (diff)
downloadmariadb-git-43ef6da6ef00d9b3a5da218df1629115c1f47b9f.tar.gz
Manul merge
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r--sql/sql_acl.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index ec25e4cb68b..8c241d8d7ba 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -210,6 +210,7 @@ static bool compare_hostname(const acl_host_and_ip *host,const char *hostname,
const char *ip);
static my_bool acl_load(THD *thd, TABLE_LIST *tables);
static my_bool grant_load(THD *thd, TABLE_LIST *tables);
+static inline void get_grantor(THD *thd, char* grantor);
/*
Convert scrambled password to binary form, according to scramble type,
@@ -2755,6 +2756,20 @@ end:
DBUG_RETURN(result);
}
+static inline void get_grantor(THD *thd, char *grantor)
+{
+ const char *user= thd->security_ctx->user;
+ const char *host= thd->security_ctx->host_or_ip;
+
+#if defined(HAVE_REPLICATION)
+ if (thd->slave_thread && thd->has_invoker())
+ {
+ user= thd->get_invoker_user().str;
+ host= thd->get_invoker_host().str;
+ }
+#endif
+ strxmov(grantor, user, "@", host, NullS);
+}
static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
TABLE *table, const LEX_USER &combo,
@@ -2769,9 +2784,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
uchar user_key[MAX_KEY_LENGTH];
DBUG_ENTER("replace_table_table");
- strxmov(grantor, thd->security_ctx->user, "@",
- thd->security_ctx->host_or_ip, NullS);
-
+ get_grantor(thd, grantor);
/*
The following should always succeed as new users are created before
this function is called!
@@ -2901,9 +2914,7 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name,
DBUG_RETURN(-1);
}
- strxmov(grantor, thd->security_ctx->user, "@",
- thd->security_ctx->host_or_ip, NullS);
-
+ get_grantor(thd, grantor);
/*
New users are created before this function is called.