summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.(none)>2006-07-10 17:20:39 -0400
committerunknown <cmiller@zippy.(none)>2006-07-10 17:20:39 -0400
commita6edf110bcd6b393c801624181e5b20b6557b8c1 (patch)
tree6c80944794a080d0760a0fcb611aac380726616d /sql/sql_acl.cc
parent8154ca618b68784098dcb8b84ba2cf77707c80e4 (diff)
parent2f45384bf1eb48b9fab73bf413ceb2dc557f29b7 (diff)
downloadmariadb-git-a6edf110bcd6b393c801624181e5b20b6557b8c1.tar.gz
Merge zippy.(none):/home/cmiller/work/mysql/merge/tmp_merge
into zippy.(none):/home/cmiller/work/mysql/merge/mysql-5.1 libmysqld/lib_sql.cc: Auto merged libmysqld/libmysqld.c: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/information_schema.result: Auto merged mysql-test/r/sp-security.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/gis.test: Auto merged mysql-test/t/sp-security.test: Auto merged mysql-test/t/variables.test: Auto merged scripts/make_binary_distribution.sh: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/item_geofunc.h: Auto merged sql-common/client.c: Auto merged sql/set_var.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_parse.cc: Auto merged storage/ndb/include/kernel/GlobalSignalNumbers.h: Auto merged storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Auto merged mysql-test/t/mysqldump.test: Manual merge. (Seems to need null-merging.) sql/mysqld.cc: Manual merge + formatting change. sql/sql_show.cc: Manual merge
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r--sql/sql_acl.cc59
1 files changed, 44 insertions, 15 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index deb7fe2d2b8..e82ad611427 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -5749,25 +5749,30 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
TABLE_LIST tables[1];
List<LEX_USER> user_list;
bool result;
+ ACL_USER *au;
+ char passwd_buff[SCRAMBLED_PASSWORD_CHAR_LENGTH+1];
DBUG_ENTER("sp_grant_privileges");
if (!(combo=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
DBUG_RETURN(TRUE);
combo->user.str= sctx->user;
-
+
VOID(pthread_mutex_lock(&acl_cache->lock));
- if (!find_acl_user(combo->host.str=(char*)sctx->host_or_ip, combo->user.str,
- FALSE) &&
- !find_acl_user(combo->host.str=(char*)sctx->host, combo->user.str,
- FALSE) &&
- !find_acl_user(combo->host.str=(char*)sctx->ip, combo->user.str,
- FALSE) &&
- !find_acl_user(combo->host.str=(char*)"%", combo->user.str, FALSE))
- {
- VOID(pthread_mutex_unlock(&acl_cache->lock));
- DBUG_RETURN(TRUE);
- }
+
+ if ((au= find_acl_user(combo->host.str=(char*)sctx->host_or_ip,combo->user.str,FALSE)))
+ goto found_acl;
+ if ((au= find_acl_user(combo->host.str=(char*)sctx->host, combo->user.str,FALSE)))
+ goto found_acl;
+ if ((au= find_acl_user(combo->host.str=(char*)sctx->ip, combo->user.str,FALSE)))
+ goto found_acl;
+ if((au= find_acl_user(combo->host.str=(char*)"%", combo->user.str, FALSE)))
+ goto found_acl;
+
+ VOID(pthread_mutex_unlock(&acl_cache->lock));
+ DBUG_RETURN(TRUE);
+
+ found_acl:
VOID(pthread_mutex_unlock(&acl_cache->lock));
bzero((char*)tables, sizeof(TABLE_LIST));
@@ -5775,13 +5780,37 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
tables->db= (char*)sp_db;
tables->table_name= tables->alias= (char*)sp_name;
-
+
combo->host.length= strlen(combo->host.str);
combo->user.length= strlen(combo->user.str);
combo->host.str= thd->strmake(combo->host.str,combo->host.length);
combo->user.str= thd->strmake(combo->user.str,combo->user.length);
- combo->password.str= (char*)"";
- combo->password.length= 0;
+
+
+ if(au && au->salt_len)
+ {
+ if (au->salt_len == SCRAMBLE_LENGTH)
+ {
+ make_password_from_salt(passwd_buff, au->salt);
+ combo->password.length= SCRAMBLED_PASSWORD_CHAR_LENGTH;
+ }
+ else if (au->salt_len == SCRAMBLE_LENGTH_323)
+ {
+ make_password_from_salt_323(passwd_buff, (ulong *) au->salt);
+ combo->password.length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323;
+ }
+ else
+ {
+ my_error(ER_PASSWD_LENGTH, MYF(0), SCRAMBLED_PASSWORD_CHAR_LENGTH);
+ return -1;
+ }
+ combo->password.str= passwd_buff;
+ }
+ else
+ {
+ combo->password.str= (char*)"";
+ combo->password.length= 0;
+ }
if (user_list.push_back(combo))
DBUG_RETURN(TRUE);