summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-02-15 13:36:46 -0800
committerunknown <jimw@mysql.com>2005-02-15 13:36:46 -0800
commit2d2d4df7d28bc1826858b69d93a60cad76fe80d3 (patch)
tree522b4390d68f40906ba20d0532eda62e2f52cf68 /sql/sql_acl.cc
parent1b46843c10d1e5d2d6589acbb61cc1a3d8d9a4e1 (diff)
downloadmariadb-git-2d2d4df7d28bc1826858b69d93a60cad76fe80d3.tar.gz
Always lowercase database names from 'host' and 'db' grant tables when they
are loaded and lower_case_table_names is set, but issue a warning when it is done. (Bug #7989) sql/sql_acl.cc: Lowercase database names in 'host' and 'db' grant tables when loading, but issue a warning to the log about them.
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r--sql/sql_acl.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 7c17a4ef275..92d6f471a1e 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -139,6 +139,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
MYSQL_LOCK *lock;
my_bool return_val=1;
bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
+ char tmp_name[NAME_LEN+1];
DBUG_ENTER("acl_init");
@@ -197,6 +198,24 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
ACL_HOST host;
update_hostname(&host.host,get_field(&mem, table->field[0]));
host.db= get_field(&mem, table->field[1]);
+ if (lower_case_table_names)
+ {
+ /*
+ We make a temporary copy of the database, force it to lower case,
+ and then copy it back over the original name. We can't just update
+ the host.db pointer, because tmp_name is allocated on the stack.
+ */
+ (void)strmov(tmp_name, host.db);
+ my_casedn_str(files_charset_info, tmp_name);
+ if (strcmp(host.db, tmp_name) != 0)
+ {
+ sql_print_warning("'host' entry '%s|%s' had database in mixed "
+ "case that has been forced to lowercase because "
+ "lower_case_table_names is set.",
+ host.host.hostname, host.db);
+ (void)strmov(host.db, tmp_name);
+ }
+ }
host.access= get_access(table,2);
host.access= fix_rights_for_db(host.access);
host.sort= get_sort(2,host.host.hostname,host.db);
@@ -380,6 +399,24 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
}
db.access=get_access(table,3);
db.access=fix_rights_for_db(db.access);
+ if (lower_case_table_names)
+ {
+ /*
+ We make a temporary copy of the database, force it to lower case,
+ and then copy it back over the original name. We can't just update
+ the db.db pointer, because tmp_name is allocated on the stack.
+ */
+ (void)strmov(tmp_name, db.db);
+ my_casedn_str(files_charset_info, tmp_name);
+ if (strcmp(db.db, tmp_name) != 0)
+ {
+ sql_print_warning("'db' entry '%s %s@%s' had database in mixed "
+ "case that has been forced to lowercase because "
+ "lower_case_table_names is set.",
+ db.db, db.user, db.host.hostname, db.host.hostname);
+ (void)strmov(db.db, tmp_name);
+ }
+ }
db.sort=get_sort(3,db.host.hostname,db.db,db.user);
#ifndef TO_BE_REMOVED
if (table->fields <= 9)