summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
diff options
context:
space:
mode:
authorunknown <dlenev@mysql.com>2004-12-23 21:59:36 +0300
committerunknown <dlenev@mysql.com>2004-12-23 21:59:36 +0300
commit4a5ca0bc638b2e09bca1fc0b9b8bee02590c6e08 (patch)
treef380646ec05c8f3f6c4dd9fa9d2d126b06aa429a /sql/sql_acl.cc
parente6dfed9f4cb88406dec37ffb5ca1fa0b0f2b3e75 (diff)
downloadmariadb-git-4a5ca0bc638b2e09bca1fc0b9b8bee02590c6e08.tar.gz
Make GRANTs, which change SSL attributes and/or user limits,
to behave well on 5.0 tables (well now you can't use tables from 4.1 and 5.0 with 4.0 because former use utf8, but still it is nice to have similar code in acl_init() and replace_user_table()). This also will make such GRANTs working in 5.0 (they are broken now). mysql-test/r/grant.result: Added test for GRANT which manipulates user limits. mysql-test/t/grant.test: Added test for GRANT which manipulates user limits.
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r--sql/sql_acl.cc56
1 files changed, 30 insertions, 26 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 67ca62357ec..1b55168695b 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1403,6 +1403,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 ;
@@ -1411,56 +1412,59 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
if (priv & rights) // set requested privileges
(*tmp_field)->store(&what,1);
}
- rights=get_access(table,3,0);
+ 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 (thd->lex.ssl_type) {
case SSL_TYPE_ANY:
- table->field[24]->store("ANY",3);
- table->field[25]->store("",0);
- table->field[26]->store("",0);
- table->field[27]->store("",0);
+ table->field[next_field]->store("ANY", 3);
+ table->field[next_field+1]->store("", 0);
+ table->field[next_field+2]->store("", 0);
+ table->field[next_field+3]->store("", 0);
break;
case SSL_TYPE_X509:
- table->field[24]->store("X509",4);
- table->field[25]->store("",0);
- table->field[26]->store("",0);
- table->field[27]->store("",0);
+ table->field[next_field]->store("X509", 4);
+ table->field[next_field+1]->store("", 0);
+ table->field[next_field+2]->store("", 0);
+ table->field[next_field+3]->store("", 0);
break;
case SSL_TYPE_SPECIFIED:
- table->field[24]->store("SPECIFIED",9);
- table->field[25]->store("",0);
- table->field[26]->store("",0);
- table->field[27]->store("",0);
+ table->field[next_field]->store("SPECIFIED", 9);
+ table->field[next_field+1]->store("", 0);
+ table->field[next_field+2]->store("", 0);
+ table->field[next_field+3]->store("", 0);
if (thd->lex.ssl_cipher)
- table->field[25]->store(thd->lex.ssl_cipher,
- strlen(thd->lex.ssl_cipher));
+ table->field[next_field+1]->store(thd->lex.ssl_cipher,
+ strlen(thd->lex.ssl_cipher));
if (thd->lex.x509_issuer)
- table->field[26]->store(thd->lex.x509_issuer,
- strlen(thd->lex.x509_issuer));
+ table->field[next_field+2]->store(thd->lex.x509_issuer,
+ strlen(thd->lex.x509_issuer));
if (thd->lex.x509_subject)
- table->field[27]->store(thd->lex.x509_subject,
- strlen(thd->lex.x509_subject));
+ table->field[next_field+3]->store(thd->lex.x509_subject,
+ strlen(thd->lex.x509_subject));
break;
case SSL_TYPE_NOT_SPECIFIED:
break;
case SSL_TYPE_NONE:
- table->field[24]->store("",0);
- table->field[25]->store("",0);
- table->field[26]->store("",0);
- table->field[27]->store("",0);
+ table->field[next_field]->store("", 0);
+ table->field[next_field+1]->store("", 0);
+ table->field[next_field+2]->store("", 0);
+ table->field[next_field+3]->store("", 0);
break;
}
+ /* Skip over SSL related fields to first user limits related field */
+ next_field+= 4;
+
USER_RESOURCES mqh = thd->lex.mqh;
if (mqh.bits & 1)
- table->field[28]->store((longlong) mqh.questions);
+ table->field[next_field]->store((longlong) mqh.questions);
if (mqh.bits & 2)
- table->field[29]->store((longlong) mqh.updates);
+ table->field[next_field+1]->store((longlong) mqh.updates);
if (mqh.bits & 4)
- table->field[30]->store((longlong) mqh.connections);
+ table->field[next_field+2]->store((longlong) mqh.connections);
mqh_used = mqh_used || mqh.questions || mqh.updates || mqh.connections;
}
if (old_row_exists)