summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
diff options
context:
space:
mode:
authorunknown <bar@gw.udmsearch.izhnet.ru>2002-03-12 21:37:58 +0400
committerunknown <bar@gw.udmsearch.izhnet.ru>2002-03-12 21:37:58 +0400
commit68375e0f008d109f574491bd3b0eb2184e6f3ad2 (patch)
treeaa6dbf1781d8122e350474b0cac9e5ee443426bc /sql/sql_acl.cc
parent003b294967317b4710714d8d2ab4880b8e5682e3 (diff)
downloadmariadb-git-68375e0f008d109f574491bd3b0eb2184e6f3ad2.tar.gz
New ctype functions/macros to support many charsets at a time
client/mysql.cc: new ctypes client/mysqldump.c: new ctypes client/mysqltest.c: new ctypes client/sql_string.cc: new ctypes client/sql_string.h: new ctypes extra/mysql_install.c: new ctypes extra/replace.c: new ctypes extra/resolve_stack_dump.c: new ctypes extra/resolveip.c: new ctypes heap/hp_hash.c: new ctypes include/m_ctype.h: new ctypes include/my_sys.h: new ctypes isam/_key.c: new ctypes isam/_search.c: new ctypes libmysql/Makefile.shared: new ctypes libmysql/libmysql.c: new ctypes myisam/ft_dump.c: new ctypes myisam/ft_parser.c: new ctypes myisam/mi_test1.c: new ctypes mysys/charset.c: new ctypes mysys/default.c: new ctypes mysys/getvar.c: new ctypes mysys/hash.c: new ctypes mysys/mf_casecnv.c: new ctypes mysys/mf_dirname.c: new ctypes mysys/mf_format.c: new ctypes mysys/mf_iocache2.c: new ctypes mysys/mf_soundex.c: new ctypes mysys/mf_wfile.c: new ctypes mysys/my_error.c: new ctypes mysys/my_getwd.c: new ctypes mysys/my_init.c: new ctypes mysys/my_vsnprintf.c: new ctypes mysys/typelib.c: new ctypes sql/convert.cc: new ctypes sql/des_key_file.cc: new ctypes sql/field.cc: new ctypes sql/field.h: new ctypes sql/field_conv.cc: new ctypes sql/filesort.cc: new ctypes sql/ha_innodb.cc: new ctypes sql/hostname.cc: new ctypes sql/init.cc: new ctypes sql/item.cc: new ctypes sql/item_func.cc: new ctypes sql/item_strfunc.cc: new ctypes sql/item_sum.cc: new ctypes sql/item_timefunc.cc: new ctypes sql/key.cc: new ctypes sql/log.cc: new ctypes sql/mysql_priv.h: new ctypes sql/mysqld.cc: new ctypes sql/opt_range.cc: new ctypes sql/procedure.cc: new ctypes sql/slave.cc: new ctypes sql/sql_acl.cc: new ctypes sql/sql_analyse.cc: new ctypes sql/sql_base.cc: new ctypes sql/sql_cache.cc: new ctypes sql/sql_db.cc: new ctypes sql/sql_handler.cc: new ctypes sql/sql_lex.cc: new ctypes sql/sql_parse.cc: new ctypes sql/sql_show.cc: new ctypes sql/sql_string.cc: new ctypes sql/sql_string.h: new ctypes sql/sql_table.cc: new ctypes sql/sql_yacc.yy: new ctypes sql/table.cc: new ctypes sql/time.cc: new ctypes strings/Makefile.am: new ctypes strings/ctype-big5.c: new ctypes strings/ctype-czech.c: new ctypes strings/ctype-gbk.c: new ctypes strings/ctype-latin1_de.c: new ctypes strings/ctype-sjis.c: new ctypes strings/ctype-tis620.c: new ctypes strings/ctype.c: new ctypes strings/str2int.c: new ctypes strings/strto.c: new ctypes tools/mysqlmanager.c: new ctypes
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r--sql/sql_acl.cc46
1 files changed, 27 insertions, 19 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index c5782f65798..198569cec3c 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -381,7 +381,7 @@ static uint get_access(TABLE *form,uint fieldnr)
for (pos=form->field+fieldnr,bit=1 ; *pos ; pos++ , bit<<=1)
{
(*pos)->val_str(&res,&res);
- if (toupper(res[0]) == 'Y')
+ if (my_toupper(system_charset_info, res[0]) == 'Y')
access_bits|=bit;
}
return access_bits;
@@ -729,7 +729,7 @@ uint acl_get(const char *host, const char *ip, const char *bin_ip,
end=strmov((tmp_db=strmov(key+sizeof(struct in_addr),user)+1),db);
if (lower_case_table_names)
{
- casedn_str(tmp_db);
+ my_casedn_str(system_charset_info, tmp_db);
db=tmp_db;
}
key_length=(uint) (end-key);
@@ -793,7 +793,7 @@ exit:
}
-int wild_case_compare(const char *str,const char *wildstr)
+int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr)
{
reg3 int flag;
DBUG_ENTER("wild_case_compare");
@@ -804,7 +804,8 @@ int wild_case_compare(const char *str,const char *wildstr)
{
if (*wildstr == wild_prefix && wildstr[1])
wildstr++;
- if (toupper(*wildstr++) != toupper(*str++)) DBUG_RETURN(1);
+ if (my_toupper(cs, *wildstr++) !=
+ my_toupper(cs, *str++)) DBUG_RETURN(1);
}
if (! *wildstr ) DBUG_RETURN (*str != 0);
if (*wildstr++ == wild_one)
@@ -822,12 +823,12 @@ int wild_case_compare(const char *str,const char *wildstr)
char cmp;
if ((cmp= *wildstr) == wild_prefix && wildstr[1])
cmp=wildstr[1];
- cmp=toupper(cmp);
- while (*str && toupper(*str) != cmp)
+ cmp=my_toupper(cs, cmp);
+ while (*str && my_toupper(cs, *str) != cmp)
str++;
if (!*str) DBUG_RETURN (1);
}
- if (wild_case_compare(str,wildstr) == 0) DBUG_RETURN (0);
+ if (wild_case_compare(cs, str,wildstr) == 0) DBUG_RETURN (0);
} while (*str++);
DBUG_RETURN(1);
}
@@ -862,7 +863,8 @@ static void init_check_host(void)
{ // Check if host already exists
acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,j,
acl_host_and_ip *);
- if (!my_strcasecmp(acl_user->host.hostname,acl->hostname))
+ if (!my_strcasecmp(system_charset_info,
+ acl_user->host.hostname, acl->hostname))
break; // already stored
}
if (j == acl_wild_hosts.elements) // If new
@@ -940,7 +942,8 @@ bool change_password(THD *thd, const char *host, const char *user,
new_password[length & 16]=0;
if (!thd || (!thd->slave_thread && ( strcmp(thd->user,user) ||
- my_strcasecmp(host,thd->host ? thd->host : thd->ip))))
+ my_strcasecmp(system_charset_info,
+ host, (thd->host ? thd->host : thd->ip)))))
{
if (check_access(thd, UPDATE_ACL, "mysql",0,1))
DBUG_RETURN(1);
@@ -1061,7 +1064,8 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
return (tmp & host->ip_mask) == host->ip;
}
return (!host->hostname ||
- (hostname && !wild_case_compare(hostname,host->hostname)) ||
+ (hostname && !wild_case_compare(system_charset_info,
+ hostname,host->hostname)) ||
(ip && !wild_compare(ip,host->hostname)));
}
@@ -1414,8 +1418,8 @@ public:
tname= strdup_root(&memex,t);
if (lower_case_table_names)
{
- casedn_str(db);
- casedn_str(tname);
+ my_casedn_str(system_charset_info, db);
+ my_casedn_str(system_charset_info, tname);
}
key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3;
hash_key = (char*) alloc_root(&memex,key_length);
@@ -1440,8 +1444,8 @@ public:
}
if (lower_case_table_names)
{
- casedn_str(db);
- casedn_str(tname);
+ my_casedn_str(system_charset_info, db);
+ my_casedn_str(system_charset_info, tname);
}
key_length = ((uint) strlen(db) + (uint) strlen(user) +
(uint) strlen(tname) + 3);
@@ -1534,8 +1538,10 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip,
}
else
{
- if ((host && !wild_case_compare(host,grant_table->host)) ||
- (ip && !wild_case_compare(ip,grant_table->host)))
+ if ((host && !wild_case_compare(system_charset_info,
+ host,grant_table->host)) ||
+ (ip && !wild_case_compare(system_charset_info,
+ ip,grant_table->host)))
found=grant_table; // Host ok
}
}
@@ -2051,7 +2057,7 @@ int mysql_grant (THD *thd, const char *db, List <LEX_USER> &list, uint rights,
if (lower_case_table_names && db)
{
strmov(tmp_db,db);
- casedn_str(tmp_db);
+ my_casedn_str(system_charset_info, tmp_db);
db=tmp_db;
}
@@ -2476,8 +2482,10 @@ bool check_grant_db(THD *thd,const char *db)
GRANT_TABLE *grant_table = (GRANT_TABLE*) hash_element(&hash_tables,idx);
if (len < grant_table->key_length &&
!memcmp(grant_table->hash_key,helping,len) &&
- (thd->host && !wild_case_compare(thd->host,grant_table->host) ||
- (thd->ip && !wild_case_compare(thd->ip,grant_table->host))))
+ (thd->host && !wild_case_compare(system_charset_info,
+ thd->host,grant_table->host) ||
+ (thd->ip && !wild_case_compare(system_charset_info,
+ thd->ip,grant_table->host))))
{
error=0; // Found match
break;