diff options
author | unknown <bell@sanja.is.com.ua> | 2005-09-21 08:29:47 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2005-09-21 08:29:47 +0300 |
commit | 21a62eb1c6a281b72c24bb9a7d5af702a5b3d8d5 (patch) | |
tree | 3fd9549289ca85690f0fe0b1fc7427e8c2394642 | |
parent | aa95f0d447ed43cb20f1ce3221334b8f75e82377 (diff) | |
download | mariadb-git-21a62eb1c6a281b72c24bb9a7d5af702a5b3d8d5.tar.gz |
postmerge fixes
libmysqld/lib_sql.cc:
struct st_security_context nad to class Security_context
sql/item_func.cc:
fixed method call, name and contence to be compatible with new code
sql/item_func.h:
fixed method to be compatible wit new code
sql/sql_parse.cc:
fixed typo
removed compiler warnings
-rw-r--r-- | libmysqld/lib_sql.cc | 2 | ||||
-rw-r--r-- | sql/item_func.cc | 70 | ||||
-rw-r--r-- | sql/item_func.h | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 10 |
4 files changed, 36 insertions, 49 deletions
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index d6f41fda5f6..99761ceb8c7 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -532,7 +532,7 @@ err: int check_embedded_connection(MYSQL *mysql) { THD *thd= (THD*)mysql->thd; - st_security_context *sctx= thd->security_ctx; + Security_context *sctx= thd->security_ctx; sctx->host_or_ip= sctx->host= (char*)my_localhost; sctx->priv_user= sctx->user= my_strdup(mysql->user, MYF(0)); return check_user(thd, COM_CONNECT, NULL, 0, thd->db, true); diff --git a/sql/item_func.cc b/sql/item_func.cc index 4fbc60014f3..265eb28bba8 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4711,21 +4711,11 @@ Item_func_sp::execute(Item **itp) THD *thd= current_thd; int res= -1; Sub_statement_state statement_state; - -#ifndef NO_EMBEDDED_ACCESS_CHECKS Security_context *save_ctx; -#endif - if (! m_sp && ! (m_sp= sp_find_function(thd, m_name, TRUE))) - { - my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str); + if (find_and_check_access(thd, EXECUTE_ACL, &save_ctx)) goto error; - } -#ifndef NO_EMBEDDED_ACCESS_CHECKS - if (check_access(EXECUTE_ACL, 0, &save_ctx)) - goto error; -#endif /* Disable the binlogging if this is not a SELECT statement. If this is a SELECT, leave binlogging on, so execute_function() code writes the @@ -4734,7 +4724,7 @@ Item_func_sp::execute(Item **itp) thd->reset_sub_statement_state(&statement_state, SUB_STMT_FUNCTION); res= m_sp->execute_function(thd, args, arg_count, itp); thd->restore_sub_statement_state(&statement_state); - + if (res && mysql_bin_log.is_open() && (m_sp->m_chistics->daccess == SP_CONTAINS_SQL || m_sp->m_chistics->daccess == SP_MODIFIES_SQL_DATA)) @@ -4851,71 +4841,67 @@ Item_func_sp::tmp_table_field(TABLE *t_arg) DBUG_RETURN(res); } + /* - Check access rigths to function + Find the function and chack access rigths to the function SYNOPSIS - check_access() + find_and_check_access() + thd thread handler want_access requested access - report_error whether to set error to thd->net.report_error - sp_ctx sp security context for switching + backup backup of security context or 0 RETURN - 0 Access granted - 1 Requested access can't be granted or function doesn't exists + FALSE Access granted + TRUE Requested access can't be granted or function doesn't exists NOTES Checks if requested access to function can be granted to user. If function isn't found yet, it searches function first. If function can't be found or user don't have requested access - and report_error is true error is raised. + error is raised. If security context sp_ctx is provided and access can be granted then switch back to previous context isn't performed. - In case of access error or if context is not provided then check_access() - switches back to previous security context. + In case of access error or if context is not provided then + find_and_check_access() switches back to previous security context. */ + bool -Item_func_sp::check_access(ulong want_access, bool report_error, st_sp_security_context *sp_ctx) +Item_func_sp::find_and_check_access(THD *thd, ulong want_access, + Security_context **backup) { bool res; -#ifndef NO_EMBEDDED_ACCESS_CHECKS - THD *thd= current_thd; - st_sp_security_context save_ctx, *curr_ctx= sp_ctx?sp_ctx:&save_ctx; - bool ctx_switched= 0; - res= 1; + Security_context *local_save, + **save= (backup ? backup : &local_save); + res= TRUE; if (! m_sp && ! (m_sp= sp_find_function(thd, m_name, TRUE))) { my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str); - if (report_error) - thd->net.report_error= 1; goto error; } +#ifndef NO_EMBEDDED_ACCESS_CHECKS if (check_routine_access(thd, want_access, - m_sp->m_db.str, m_sp->m_name.str, 0, 0)) + m_sp->m_db.str, m_sp->m_name.str, 0, FALSE)) { - if (report_error) - thd->net.report_error= 1; goto error; } - sp_change_security_context(thd, m_sp, curr_ctx); - ctx_switched= curr_ctx->changed; - if (curr_ctx->changed && + sp_change_security_context(thd, m_sp, save); + if (*save && check_routine_access(thd, want_access, - m_sp->m_db.str, m_sp->m_name.str, 0, 0)) + m_sp->m_db.str, m_sp->m_name.str, 0, FALSE)) { - if (report_error) - thd->net.report_error= 1; goto error_check_ctx; } - res= 0; + res= FALSE; error_check_ctx: - if (ctx_switched && (res || !sp_ctx)) - sp_restore_security_context(thd, m_sp, curr_ctx); + if (*save && (res || !backup)) + sp_restore_security_context(thd, local_save); error: #else res= 0; +error: #endif return res; }; @@ -4926,7 +4912,7 @@ Item_func_sp::fix_fields(THD *thd, Item **ref) bool res; DBUG_ASSERT(fixed == 0); res= Item_func::fix_fields(thd, ref); - if (!res && check_access(EXECUTE_ACL, 1, NULL)) + if (!res && find_and_check_access(thd, EXECUTE_ACL, NULL)) res= 1; return res; } diff --git a/sql/item_func.h b/sql/item_func.h index adc1dd1b1be..de4d60e9cbb 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1435,7 +1435,8 @@ public: { context= (Name_resolution_context *)cntx; return FALSE; } void fix_length_and_dec(); - bool check_access(ulong want_access, bool report_error, st_sp_security_context *sp_ctx); + bool find_and_check_access(THD * thd, ulong want_access, + Security_context **backup); virtual enum Functype functype() const { return FUNC_SP; } bool fix_fields(THD *thd, Item **ref); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8f259b21919..d361b9343f1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -273,7 +273,7 @@ int check_user(THD *thd, enum enum_server_command command, DBUG_ENTER("check_user"); #ifdef NO_EMBEDDED_ACCESS_CHECKS - thd->ain_security_ctx.master_access= GLOBAL_ACLS; // Full rights + thd->main_security_ctx.master_access= GLOBAL_ACLS; // Full rights /* Change database if necessary */ if (db && db[0]) { @@ -4490,10 +4490,10 @@ end_with_restore_list: mysql_bin_log.is_open()) { String buff; - LEX_STRING command[3]= - {{STRING_WITH_LEN("CREATE ")}, - {STRING_WITH_LEN("ALTER ")}, - {STRING_WITH_LEN("CREATE OR REPLACE ")}}; + const LEX_STRING command[3]= + {{(char *)STRING_WITH_LEN("CREATE ")}, + {(char *)STRING_WITH_LEN("ALTER ")}, + {(char *)STRING_WITH_LEN("CREATE OR REPLACE ")}}; thd->clear_error(); buff.append(command[thd->lex->create_view_mode].str, |