summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authormonty@mysql.com <>2005-03-15 16:21:08 +0200
committermonty@mysql.com <>2005-03-15 16:21:08 +0200
commit05acaf060ce7fbedf278a14e9b0ad0d48baac90c (patch)
tree3d2e057bf465d061f972496746999bfd481f33b7 /sql/sp_head.cc
parent021f8d217052d791111a9c8e639f485f3f213e6b (diff)
parentdd4db08438df2a0c0ead5dd1d5864053ab552ba2 (diff)
downloadmariadb-git-05acaf060ce7fbedf278a14e9b0ad0d48baac90c.tar.gz
Merge with global tree
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc36
1 files changed, 22 insertions, 14 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 2097e55d4e3..89c4b2dbaac 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1016,23 +1016,31 @@ sp_head::restore_thd_mem_root(THD *thd)
}
-bool check_show_routine_acceess(THD *thd, sp_head *sp, bool *full_access)
+/*
+ Check if a user has access right to a routine
+
+ SYNOPSIS
+ check_show_routine_access()
+ thd Thread handler
+ sp SP
+ full_access Set to 1 if the user has SELECT right to the
+ 'mysql.proc' able or is the owner of the routine
+ RETURN
+ 0 ok
+ 1 error
+*/
+
+bool check_show_routine_access(THD *thd, sp_head *sp, bool *full_access)
{
TABLE_LIST tables;
bzero((char*) &tables,sizeof(tables));
tables.db= (char*) "mysql";
tables.table_name= tables.alias= (char*) "proc";
- *full_access= !check_table_access(thd, SELECT_ACL, &tables, 1);
- if (!(*full_access))
- *full_access= (!strcmp(sp->m_definer_user.str, thd->priv_user) &&
- !strcmp(sp->m_definer_host.str, thd->priv_host));
- if (!(*full_access))
- {
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- return check_some_routine_access(thd, (char * )sp->m_db.str,
- (char * ) sp->m_name.str);
-#endif
- }
+ *full_access= (!check_table_access(thd, SELECT_ACL, &tables, 1) ||
+ (!strcmp(sp->m_definer_user.str, thd->priv_user) &&
+ !strcmp(sp->m_definer_host.str, thd->priv_host)));
+ if (!*full_access)
+ return check_some_routine_access(thd, sp->m_db.str, sp->m_name.str);
return 0;
}
@@ -1056,7 +1064,7 @@ sp_head::show_create_procedure(THD *thd)
LINT_INIT(sql_mode_str);
LINT_INIT(sql_mode_len);
- if (check_show_routine_acceess(thd, this, &full_access))
+ if (check_show_routine_access(thd, this, &full_access))
return 1;
old_sql_mode= thd->variables.sql_mode;
@@ -1129,7 +1137,7 @@ sp_head::show_create_function(THD *thd)
LINT_INIT(sql_mode_str);
LINT_INIT(sql_mode_len);
- if (check_show_routine_acceess(thd, this, &full_access))
+ if (check_show_routine_access(thd, this, &full_access))
return 1;
old_sql_mode= thd->variables.sql_mode;