diff options
author | evgen@moonbone.local <> | 2007-03-22 22:05:19 +0300 |
---|---|---|
committer | evgen@moonbone.local <> | 2007-03-22 22:05:19 +0300 |
commit | 1ac5987ae2e97a4d899741a04096f1bf7153c934 (patch) | |
tree | 7ab9dc82dca2104243ca9c1a14bd6dc6e2941943 /sql/sql_view.cc | |
parent | e84584e2e34c9c32b132f785909c576cb233f9c3 (diff) | |
download | mariadb-git-1ac5987ae2e97a4d899741a04096f1bf7153c934.tar.gz |
Bug#26813: The SUPER privilege is wrongly required to alter a view created by
another user.
When the DEFINER clause isn't specified in the ALTER statement then it's loaded
from the view definition. If the definer differs from the current user then
the error is thrown because only a super-user can set other users as a definers.
Now if the DEFINER clause is omitted in the ALTER VIEW statement then the
definer from the original view is used without check.
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r-- | sql/sql_view.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 7143df8474a..714534707d1 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -224,6 +224,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, { LEX *lex= thd->lex; bool link_to_local; + bool definer_check_is_needed= mode != VIEW_ALTER || lex->definer; /* first table in list is target VIEW name => cut off it */ TABLE_LIST *view= lex->unlink_first_table(&link_to_local); TABLE_LIST *tables= lex->query_tables; @@ -256,8 +257,9 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, /* DEFINER-clause is missing; we have to create default definer in persistent arena to be PS/SP friendly. + If this is an ALTER VIEW then the current user should be set as + the definer. */ - Query_arena original_arena; Query_arena *ps_arena = thd->activate_stmt_arena_if_needed(&original_arena); @@ -277,11 +279,11 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, - same as current user - current user has SUPER_ACL */ - if (strcmp(lex->definer->user.str, - thd->security_ctx->priv_user) != 0 || - my_strcasecmp(system_charset_info, - lex->definer->host.str, - thd->security_ctx->priv_host) != 0) + if (definer_check_is_needed && + (strcmp(lex->definer->user.str, thd->security_ctx->priv_user) != 0 || + my_strcasecmp(system_charset_info, + lex->definer->host.str, + thd->security_ctx->priv_host) != 0)) { if (!(thd->security_ctx->master_access & SUPER_ACL)) { |