mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
5.0 to 5.1 merge
mysql-test/r/grant.result: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged sql/Makefile.am: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_parse.cc: Auto merged configure.in: merge of 5.0 to 5.1, version info and NDB_VERSION_() conflicts libmysqld/Makefile.am: merge of Makefile sql_sources list sql/sql_acl.h: merge, no need to hand resolve BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
This commit is contained in:
@ -28,7 +28,6 @@
|
||||
|
||||
#include "sp_head.h"
|
||||
#include "sp.h"
|
||||
#include "sp_cache.h"
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
/*
|
||||
@ -3049,7 +3048,6 @@ unsent_create_error:
|
||||
goto error; /* purecov: inspected */
|
||||
thd->slow_command=TRUE;
|
||||
res = mysql_check_table(thd, first_table, &lex->check_opt);
|
||||
sp_cache_invalidate();
|
||||
break;
|
||||
}
|
||||
case SQLCOM_ANALYZE:
|
||||
@ -3564,7 +3562,8 @@ unsent_create_error:
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
case SQLCOM_CREATE_USER:
|
||||
{
|
||||
if (check_access(thd, GRANT_ACL,"mysql",0,1,0))
|
||||
if (check_access(thd, INSERT_ACL, "mysql", 0, 1, 1) &&
|
||||
check_global_access(thd,CREATE_USER_ACL))
|
||||
break;
|
||||
if (!(res= mysql_create_user(thd, lex->users_list)))
|
||||
{
|
||||
@ -3579,7 +3578,8 @@ unsent_create_error:
|
||||
}
|
||||
case SQLCOM_DROP_USER:
|
||||
{
|
||||
if (check_access(thd, GRANT_ACL,"mysql",0,1,0))
|
||||
if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 1) &&
|
||||
check_global_access(thd,CREATE_USER_ACL))
|
||||
break;
|
||||
if (!(res= mysql_drop_user(thd, lex->users_list)))
|
||||
{
|
||||
@ -3594,7 +3594,8 @@ unsent_create_error:
|
||||
}
|
||||
case SQLCOM_RENAME_USER:
|
||||
{
|
||||
if (check_access(thd, GRANT_ACL,"mysql",0,1,0))
|
||||
if (check_access(thd, UPDATE_ACL, "mysql", 0, 1, 1) &&
|
||||
check_global_access(thd,CREATE_USER_ACL))
|
||||
break;
|
||||
if (!(res= mysql_rename_user(thd, lex->users_list)))
|
||||
{
|
||||
@ -3609,7 +3610,8 @@ unsent_create_error:
|
||||
}
|
||||
case SQLCOM_REVOKE_ALL:
|
||||
{
|
||||
if (check_access(thd, GRANT_ACL ,"mysql",0,1,0))
|
||||
if (check_access(thd, UPDATE_ACL, "mysql", 0, 1, 1) &&
|
||||
check_global_access(thd,CREATE_USER_ACL))
|
||||
break;
|
||||
if (!(res = mysql_revoke_all(thd, lex->users_list)))
|
||||
{
|
||||
@ -3637,47 +3639,29 @@ unsent_create_error:
|
||||
uint counter;
|
||||
|
||||
List_iterator <LEX_USER> user_list(lex->users_list);
|
||||
while ((user=user_list++))
|
||||
while ((user= user_list++))
|
||||
{
|
||||
if (strcmp(thd->user, user->user.str) ||
|
||||
user->host.str &&
|
||||
my_strcasecmp(system_charset_info,
|
||||
user->host.str, thd->host_or_ip))
|
||||
{
|
||||
// We are trying to update another user, or create a new user
|
||||
|
||||
if (!check_access(thd, GRANT_ACL, "mysql", 0, 1, 1))
|
||||
break; // We can update any existing, or add new users
|
||||
|
||||
if (!check_acl_user(user, &counter) &&
|
||||
check_access(thd, INSERT_ACL, "mysql", 0, 1, 1))
|
||||
{
|
||||
my_error(ER_NO_PERMISSION_TO_CREATE_USER, MYF(0),
|
||||
thd->user, thd->host_or_ip);
|
||||
goto error; // Can't create new user, user does not exists
|
||||
}
|
||||
if (check_acl_user(user, &counter) &&
|
||||
user->password.str &&
|
||||
check_access(thd, UPDATE_ACL, "mysql", 0, 1, 1))
|
||||
{
|
||||
my_message(ER_PASSWORD_NOT_ALLOWED,
|
||||
ER(ER_PASSWORD_NOT_ALLOWED), MYF(0));
|
||||
goto error; // Can't update password, user already exists
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (specialflag & SPECIAL_NO_RESOLVE)
|
||||
{
|
||||
LEX_USER *user;
|
||||
List_iterator <LEX_USER> user_list(lex->users_list);
|
||||
while ((user=user_list++))
|
||||
{
|
||||
if (hostname_requires_resolving(user->host.str))
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_HOSTNAME_WONT_WORK,
|
||||
ER(ER_WARN_HOSTNAME_WONT_WORK),
|
||||
user->host.str);
|
||||
if (specialflag & SPECIAL_NO_RESOLVE &&
|
||||
hostname_requires_resolving(user->host.str))
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_HOSTNAME_WONT_WORK,
|
||||
ER(ER_WARN_HOSTNAME_WONT_WORK),
|
||||
user->host.str);
|
||||
// Are we trying to change a password of another user
|
||||
DBUG_ASSERT(user->host.str != 0);
|
||||
if (strcmp(thd->user, user->user.str) ||
|
||||
my_strcasecmp(system_charset_info,
|
||||
user->host.str, thd->host_or_ip))
|
||||
{
|
||||
// TODO: use check_change_password()
|
||||
if (check_acl_user(user, &counter) && user->password.str &&
|
||||
check_access(thd, UPDATE_ACL,"mysql",0,1,1))
|
||||
{
|
||||
my_message(ER_PASSWORD_NOT_ALLOWED,
|
||||
ER(ER_PASSWORD_NOT_ALLOWED), MYF(0));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (first_table)
|
||||
@ -4596,6 +4580,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
||||
{
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
ulong db_access;
|
||||
bool db_is_pattern= test(want_access & GRANT_ACL);
|
||||
#endif
|
||||
ulong dummy;
|
||||
DBUG_ENTER("check_access");
|
||||
@ -4627,9 +4612,8 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
||||
*/
|
||||
db_access= thd->db_access;
|
||||
if (!(thd->master_access & SELECT_ACL) &&
|
||||
(db && (!thd->db || strcmp(db,thd->db))))
|
||||
db_access=acl_get(thd->host, thd->ip,
|
||||
thd->priv_user, db, test(want_access & GRANT_ACL));
|
||||
(db && (!thd->db || db_is_pattern || strcmp(db,thd->db))))
|
||||
db_access=acl_get(thd->host, thd->ip, thd->priv_user, db, db_is_pattern);
|
||||
*save_priv=thd->master_access | db_access;
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
@ -4650,9 +4634,8 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
||||
if (db == any_db)
|
||||
DBUG_RETURN(FALSE); // Allow select on anything
|
||||
|
||||
if (db && (!thd->db || strcmp(db,thd->db)))
|
||||
db_access=acl_get(thd->host, thd->ip,
|
||||
thd->priv_user, db, test(want_access & GRANT_ACL));
|
||||
if (db && (!thd->db || db_is_pattern || strcmp(db,thd->db)))
|
||||
db_access=acl_get(thd->host, thd->ip, thd->priv_user, db, db_is_pattern);
|
||||
else
|
||||
db_access=thd->db_access;
|
||||
DBUG_PRINT("info",("db_access: %lu", db_access));
|
||||
@ -5547,9 +5530,7 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
|
||||
my_error(ER_TOO_BIG_SET, MYF(0), field_name); /* purecov: inspected */
|
||||
DBUG_RETURN(NULL);
|
||||
}
|
||||
new_field->pack_length= (interval_list->elements + 7) / 8;
|
||||
if (new_field->pack_length > 4)
|
||||
new_field->pack_length=8;
|
||||
new_field->pack_length= get_set_pack_length(interval_list->elements);
|
||||
|
||||
List_iterator<String> it(*interval_list);
|
||||
String *tmp;
|
||||
@ -5566,7 +5547,7 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
|
||||
case FIELD_TYPE_ENUM:
|
||||
{
|
||||
// Should be safe
|
||||
new_field->pack_length= interval_list->elements < 256 ? 1 : 2;
|
||||
new_field->pack_length= get_enum_pack_length(interval_list->elements);
|
||||
|
||||
List_iterator<String> it(*interval_list);
|
||||
String *tmp;
|
||||
|
Reference in New Issue
Block a user