1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

WL#2818 (Add creator to the trigger definition for privilege

checks on trigger activation)


mysql-test/r/information_schema.result:
  Update result file: a new column DEFINER has been added to
  INFORMATION_SCHEMA.TRIGGERS.
mysql-test/r/mysqldump.result:
  Update result file: a new column DEFINER has been added to
  INFORMATION_SCHEMA.TRIGGERS.
mysql-test/r/rpl_ddl.result:
  Update result file: a new column DEFINER has been added to
  INFORMATION_SCHEMA.TRIGGERS.
mysql-test/r/rpl_sp.result:
  Update result file: a new clause DEFINER has been added to
  CREATE TRIGGER statement.
mysql-test/r/rpl_trigger.result:
  Results for new test cases were added.
mysql-test/r/skip_grants.result:
  Error message has been changed.
mysql-test/r/trigger.result:
  Added DEFINER column.
mysql-test/r/view.result:
  Error messages have been changed.
mysql-test/r/view_grant.result:
  Error messages have been changed.
mysql-test/t/mysqldump.test:
  Drop created procedure to not affect further tests.
mysql-test/t/rpl_trigger.test:
  Add tests for new column in information schema.
mysql-test/t/skip_grants.test:
  Error tag has been renamed.
mysql-test/t/view.test:
  Error tag has been renamed.
mysql-test/t/view_grant.test:
  Error tag has been changed.
sql/item_func.cc:
  Fix typo in comments.
sql/mysql_priv.h:
  A try to minimize copy&paste:
    - introduce operations to be used from sql_yacc.yy;
    - introduce an operation to be used from trigger and
      view processing code.
sql/share/errmsg.txt:
  - Rename ER_NO_VIEW_USER to ER_MALFORMED_DEFINER in order to
    be shared for view and trigger implementations;
  - Fix a typo;
  - Add a new error code for trigger warning.
sql/sp.cc:
  set_info() was split into set_info() and set_definer().
sql/sp_head.cc:
  set_info() was split into set_info() and set_definer().
sql/sp_head.h:
  set_info() was split into set_info() and set_definer().
sql/sql_acl.cc:
  Add a new check: exit from the cycle if the table is NULL.
sql/sql_lex.h:
  - Rename create_view_definer to definer, since it is used for views
    and triggers;
  - Change st_lex_user to LEX_USER, since st_lex_user is a structure.
    So, formally, it should be "struct st_lex_user", which is longer
    than just LEX_USER;
  - Add trigger_definition_begin.
sql/sql_parse.cc:
  - Add a new check: exit from the cycle if the table is NULL;
  - Implement definer-related functions.
sql/sql_show.cc:
  Add DEFINER column.
sql/sql_trigger.cc:
  Add DEFINER support for triggers.
sql/sql_trigger.h:
  Add DEFINER support for triggers.
sql/sql_view.cc:
  Rename create_view_definer to definer.
sql/sql_yacc.yy:
  Add support for DEFINER-clause in CREATE TRIGGER statement.
  
  Since CREATE TRIGGER and CREATE VIEW can be similar at the start,
  yacc is unable to distinguish between them. So, had to modify both
  statements in order to make it parsable by yacc.
mysql-test/r/trigger-compat.result:
  Result file for triggers backward compatibility test.
mysql-test/r/trigger-grant.result:
  Result file of the test for WL#2818.
mysql-test/t/trigger-compat.test:
  Triggers backward compatibility test: check that the server
  still can load triggers w/o definer attribute and modify
  tables with such triggers (add a new trigger, etc).
mysql-test/t/trigger-grant.test:
  Test for WL#2818 -- check that DEFINER support in triggers
  works properly
This commit is contained in:
unknown
2005-11-10 22:25:03 +03:00
parent 96ae0b92b2
commit 7dbea7df27
32 changed files with 1601 additions and 293 deletions

View File

@@ -5062,7 +5062,7 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables,
the given table list refers to the list for prelocking (contains tables
of other queries). For simple queries first_not_own_table is 0.
*/
for (; tables != first_not_own_table; tables= tables->next_global)
for (; tables && tables != first_not_own_table; tables= tables->next_global)
{
if (tables->schema_table &&
(want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
@@ -7466,32 +7466,81 @@ Item *negate_expression(THD *thd, Item *expr)
return new Item_func_not(expr);
}
/*
Assign as view definer current user
Set the specified definer to the default value, which is the current user in
the thread. Also check that the current user satisfies to the definers
requirements.
SYNOPSIS
default_view_definer()
sctx current security context
definer structure where it should be assigned
get_default_definer()
thd [in] thread handler
definer [out] definer
RETURN
FALSE OK
TRUE Error
error status, that is:
- FALSE -- on success;
- TRUE -- on error (current user can not be a definer).
*/
bool default_view_definer(Security_context *sctx, st_lex_user *definer)
bool get_default_definer(THD *thd, LEX_USER *definer)
{
definer->user.str= sctx->priv_user;
definer->user.length= strlen(sctx->priv_user);
/* Check that current user has non-empty host name. */
if (!*sctx->priv_host)
const Security_context *sctx= thd->security_ctx;
if (sctx->priv_host[0] == 0)
{
my_error(ER_NO_VIEW_USER, MYF(0));
my_error(ER_MALFORMED_DEFINER, MYF(0));
return TRUE;
}
definer->host.str= sctx->priv_host;
definer->host.length= strlen(sctx->priv_host);
/* Fill in. */
definer->user.str= (char *) sctx->priv_user;
definer->user.length= strlen(definer->user.str);
definer->host.str= (char *) sctx->priv_host;
definer->host.length= strlen(definer->host.str);
return FALSE;
}
/*
Create definer with the given user and host names. Also check that the user
and host names satisfy definers requirements.
SYNOPSIS
create_definer()
thd [in] thread handler
user_name [in] user name
host_name [in] host name
RETURN
On success, return a valid pointer to the created and initialized
LEX_STRING, which contains definer information.
On error, return 0.
*/
LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name)
{
LEX_USER *definer;
/* Check that specified host name is valid. */
if (host_name->length == 0)
{
my_error(ER_MALFORMED_DEFINER, MYF(0));
return 0;
}
/* Create and initialize. */
if (! (definer= (LEX_USER*) thd->alloc(sizeof (LEX_USER))))
return 0;
definer->user= *user_name;
definer->host= *host_name;
return definer;
}