mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
manually merged
This commit is contained in:
160
sql/sql_acl.cc
160
sql/sql_acl.cc
@ -1644,6 +1644,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
|
||||
|
||||
Field **tmp_field;
|
||||
ulong priv;
|
||||
uint next_field;
|
||||
for (tmp_field= table->field+3, priv = SELECT_ACL;
|
||||
*tmp_field && (*tmp_field)->real_type() == FIELD_TYPE_ENUM &&
|
||||
((Field_enum*) (*tmp_field))->typelib->count == 2 ;
|
||||
@ -1652,59 +1653,60 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
|
||||
if (priv & rights) // set requested privileges
|
||||
(*tmp_field)->store(&what, 1, &my_charset_latin1);
|
||||
}
|
||||
rights=get_access(table,3);
|
||||
rights= get_access(table, 3, &next_field);
|
||||
DBUG_PRINT("info",("table->fields: %d",table->fields));
|
||||
if (table->fields >= 31) /* From 4.0.0 we have more fields */
|
||||
{
|
||||
/* We write down SSL related ACL stuff */
|
||||
switch (lex->ssl_type) {
|
||||
case SSL_TYPE_ANY:
|
||||
table->field[24]->store("ANY",3, &my_charset_latin1);
|
||||
table->field[25]->store("", 0, &my_charset_latin1);
|
||||
table->field[26]->store("", 0, &my_charset_latin1);
|
||||
table->field[27]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field]->store("ANY", 3, &my_charset_latin1);
|
||||
table->field[next_field+1]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field+2]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field+3]->store("", 0, &my_charset_latin1);
|
||||
break;
|
||||
case SSL_TYPE_X509:
|
||||
table->field[24]->store("X509",4, &my_charset_latin1);
|
||||
table->field[25]->store("", 0, &my_charset_latin1);
|
||||
table->field[26]->store("", 0, &my_charset_latin1);
|
||||
table->field[27]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field]->store("X509", 4, &my_charset_latin1);
|
||||
table->field[next_field+1]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field+2]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field+3]->store("", 0, &my_charset_latin1);
|
||||
break;
|
||||
case SSL_TYPE_SPECIFIED:
|
||||
table->field[24]->store("SPECIFIED",9, &my_charset_latin1);
|
||||
table->field[25]->store("", 0, &my_charset_latin1);
|
||||
table->field[26]->store("", 0, &my_charset_latin1);
|
||||
table->field[27]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field]->store("SPECIFIED", 9, &my_charset_latin1);
|
||||
table->field[next_field+1]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field+2]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field+3]->store("", 0, &my_charset_latin1);
|
||||
if (lex->ssl_cipher)
|
||||
table->field[25]->store(lex->ssl_cipher,
|
||||
strlen(lex->ssl_cipher), system_charset_info);
|
||||
table->field[next_field+1]->store(lex->ssl_cipher,
|
||||
strlen(lex->ssl_cipher), system_charset_info);
|
||||
if (lex->x509_issuer)
|
||||
table->field[26]->store(lex->x509_issuer,
|
||||
strlen(lex->x509_issuer), system_charset_info);
|
||||
table->field[next_field+2]->store(lex->x509_issuer,
|
||||
strlen(lex->x509_issuer), system_charset_info);
|
||||
if (lex->x509_subject)
|
||||
table->field[27]->store(lex->x509_subject,
|
||||
strlen(lex->x509_subject), system_charset_info);
|
||||
table->field[next_field+3]->store(lex->x509_subject,
|
||||
strlen(lex->x509_subject), system_charset_info);
|
||||
break;
|
||||
case SSL_TYPE_NOT_SPECIFIED:
|
||||
break;
|
||||
case SSL_TYPE_NONE:
|
||||
table->field[24]->store("", 0, &my_charset_latin1);
|
||||
table->field[25]->store("", 0, &my_charset_latin1);
|
||||
table->field[26]->store("", 0, &my_charset_latin1);
|
||||
table->field[27]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field+1]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field+2]->store("", 0, &my_charset_latin1);
|
||||
table->field[next_field+3]->store("", 0, &my_charset_latin1);
|
||||
break;
|
||||
}
|
||||
next_field+=4;
|
||||
|
||||
USER_RESOURCES mqh= lex->mqh;
|
||||
if (mqh.specified_limits & USER_RESOURCES::QUERIES_PER_HOUR)
|
||||
table->field[28]->store((longlong) mqh.questions);
|
||||
table->field[next_field]->store((longlong) mqh.questions);
|
||||
if (mqh.specified_limits & USER_RESOURCES::UPDATES_PER_HOUR)
|
||||
table->field[29]->store((longlong) mqh.updates);
|
||||
table->field[next_field+1]->store((longlong) mqh.updates);
|
||||
if (mqh.specified_limits & USER_RESOURCES::CONNECTIONS_PER_HOUR)
|
||||
table->field[30]->store((longlong) mqh.conn_per_hour);
|
||||
table->field[next_field+2]->store((longlong) mqh.conn_per_hour);
|
||||
if (table->fields >= 36 &&
|
||||
(mqh.specified_limits & USER_RESOURCES::USER_CONNECTIONS))
|
||||
table->field[33]->store((longlong) mqh.user_conn);
|
||||
table->field[next_field+3]->store((longlong) mqh.user_conn);
|
||||
mqh_used= mqh_used || mqh.questions || mqh.updates || mqh.conn_per_hour;
|
||||
}
|
||||
if (old_row_exists)
|
||||
@ -2587,41 +2589,59 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
if (columns.elements && !revoke_grant)
|
||||
if (!revoke_grant)
|
||||
{
|
||||
class LEX_COLUMN *column;
|
||||
List_iterator <LEX_COLUMN> column_iter(columns);
|
||||
int res;
|
||||
if (columns.elements)
|
||||
{
|
||||
class LEX_COLUMN *column;
|
||||
List_iterator <LEX_COLUMN> column_iter(columns);
|
||||
int res;
|
||||
|
||||
if (open_and_lock_tables(thd, table_list))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
while ((column = column_iter++))
|
||||
{
|
||||
uint unused_field_idx= NO_CACHED_FIELD_INDEX;
|
||||
if (!find_field_in_table(thd, table_list, column->column.ptr(),
|
||||
column->column.ptr(),
|
||||
column->column.length(), 0, 0, 0, 0,
|
||||
&unused_field_idx, FALSE))
|
||||
if (open_and_lock_tables(thd, table_list))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
while ((column = column_iter++))
|
||||
{
|
||||
my_error(ER_BAD_FIELD_ERROR, MYF(0),
|
||||
column->column.c_ptr(), table_list->alias);
|
||||
DBUG_RETURN(TRUE);
|
||||
uint unused_field_idx= NO_CACHED_FIELD_INDEX;
|
||||
Field *f=find_field_in_table(thd, table_list, column->column.ptr(),
|
||||
column->column.ptr(),
|
||||
column->column.length(), 0, 0, 0, 0,
|
||||
&unused_field_idx, FALSE);
|
||||
if (f == (Field*)0)
|
||||
{
|
||||
my_error(ER_BAD_FIELD_ERROR, MYF(0),
|
||||
column->column.c_ptr(), table_list->alias);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (f == (Field *)-1)
|
||||
DBUG_RETURN(TRUE);
|
||||
column_priv|= column->rights;
|
||||
}
|
||||
column_priv|= column->rights;
|
||||
close_thread_tables(thd);
|
||||
}
|
||||
close_thread_tables(thd);
|
||||
}
|
||||
else if (!(rights & CREATE_ACL) && !revoke_grant)
|
||||
{
|
||||
char buf[FN_REFLEN];
|
||||
sprintf(buf,"%s/%s/%s.frm",mysql_data_home, table_list->db,
|
||||
table_list->real_name);
|
||||
fn_format(buf,buf,"","",4+16+32);
|
||||
if (access(buf,F_OK))
|
||||
else
|
||||
{
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias);
|
||||
DBUG_RETURN(TRUE);
|
||||
if (!(rights & CREATE_ACL))
|
||||
{
|
||||
char buf[FN_REFLEN];
|
||||
sprintf(buf,"%s/%s/%s.frm",mysql_data_home, table_list->db,
|
||||
table_list->real_name);
|
||||
fn_format(buf,buf,"","",4+16+32);
|
||||
if (access(buf,F_OK))
|
||||
{
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
if (table_list->grant.want_privilege)
|
||||
{
|
||||
char command[128];
|
||||
get_privilege_desc(command, sizeof(command),
|
||||
table_list->grant.want_privilege);
|
||||
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
|
||||
command, thd->priv_user, thd->host_or_ip, table_list->alias);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3337,25 +3357,8 @@ err:
|
||||
rw_unlock(&LOCK_grant);
|
||||
if (!no_errors) // Not a silent skip of table
|
||||
{
|
||||
const char *command="";
|
||||
if (want_access & SELECT_ACL)
|
||||
command= "select";
|
||||
else if (want_access & INSERT_ACL)
|
||||
command= "insert";
|
||||
else if (want_access & UPDATE_ACL)
|
||||
command= "update";
|
||||
else if (want_access & DELETE_ACL)
|
||||
command= "delete";
|
||||
else if (want_access & DROP_ACL)
|
||||
command= "drop";
|
||||
else if (want_access & CREATE_ACL)
|
||||
command= "create";
|
||||
else if (want_access & ALTER_ACL)
|
||||
command= "alter";
|
||||
else if (want_access & INDEX_ACL)
|
||||
command= "index";
|
||||
else if (want_access & GRANT_ACL)
|
||||
command= "grant";
|
||||
char command[128];
|
||||
get_privilege_desc(command, sizeof(command), want_access);
|
||||
else if (want_access & CREATE_VIEW_ACL)
|
||||
command= "create view";
|
||||
else if (want_access & SHOW_VIEW_ACL)
|
||||
@ -3473,11 +3476,8 @@ bool check_grant_all_columns(THD *thd, ulong want_access, GRANT_INFO *grant,
|
||||
err:
|
||||
rw_unlock(&LOCK_grant);
|
||||
err2:
|
||||
const char *command= "";
|
||||
if (want_access & SELECT_ACL)
|
||||
command= "select";
|
||||
else if (want_access & INSERT_ACL)
|
||||
command= "insert";
|
||||
char command[128];
|
||||
get_privilege_desc(command, sizeof(command), want_access);
|
||||
my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
|
||||
command,
|
||||
thd->priv_user,
|
||||
|
Reference in New Issue
Block a user