Commit 3731f6bf authored by unknown's avatar unknown

Debugging added where needed.


sql/sql_acl.cc:
  Debugging added where needed
sql/sql_string.cc:
  Debugging added where needed
parent 01f7289d
...@@ -769,7 +769,7 @@ int wild_case_compare(const char *str,const char *wildstr) ...@@ -769,7 +769,7 @@ int wild_case_compare(const char *str,const char *wildstr)
{ {
reg3 int flag; reg3 int flag;
DBUG_ENTER("wild_case_compare"); DBUG_ENTER("wild_case_compare");
DBUG_PRINT("enter",("str='%s', wildstr='%s'",str,wildstr));
while (*wildstr) while (*wildstr)
{ {
while (*wildstr && *wildstr != wild_many && *wildstr != wild_one) while (*wildstr && *wildstr != wild_many && *wildstr != wild_one)
...@@ -892,16 +892,18 @@ bool acl_check_host(const char *host, const char *ip) ...@@ -892,16 +892,18 @@ bool acl_check_host(const char *host, const char *ip)
bool change_password(THD *thd, const char *host, const char *user, bool change_password(THD *thd, const char *host, const char *user,
char *new_password) char *new_password)
{ {
DBUG_ENTER("change_password");
DBUG_PRINT("enter",("thd=%x, host='%s', user='%s', new_password='%s'",thd,host,user,new_password));
uint length=0; uint length=0;
if (!user[0]) if (!user[0])
{ {
send_error(&thd->net, ER_PASSWORD_ANONYMOUS_USER); send_error(&thd->net, ER_PASSWORD_ANONYMOUS_USER);
return 1; DBUG_RETURN(1);
} }
if (!initialized) if (!initialized)
{ {
send_error(&thd->net, ER_PASSWORD_NOT_ALLOWED); /* purecov: inspected */ send_error(&thd->net, ER_PASSWORD_NOT_ALLOWED); /* purecov: inspected */
return 1; /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */
} }
if (!host) if (!host)
host=thd->ip; /* purecov: tested */ host=thd->ip; /* purecov: tested */
...@@ -913,15 +915,16 @@ bool change_password(THD *thd, const char *host, const char *user, ...@@ -913,15 +915,16 @@ bool change_password(THD *thd, const char *host, const char *user,
my_strcasecmp(host,thd->host ? thd->host : thd->ip)))) my_strcasecmp(host,thd->host ? thd->host : thd->ip))))
{ {
if (check_access(thd, UPDATE_ACL, "mysql",0,1)) if (check_access(thd, UPDATE_ACL, "mysql",0,1))
return 1; DBUG_RETURN(1);
} }
VOID(pthread_mutex_lock(&acl_cache->lock)); VOID(pthread_mutex_lock(&acl_cache->lock));
ACL_USER *acl_user; ACL_USER *acl_user;
DBUG_PRINT("info",("host=%s, user=%s",host,user));
if (!(acl_user= find_acl_user(host,user)) || !acl_user->user) if (!(acl_user= find_acl_user(host,user)) || !acl_user->user)
{ {
send_error(&thd->net, ER_PASSWORD_NO_MATCH); send_error(&thd->net, ER_PASSWORD_NO_MATCH);
VOID(pthread_mutex_unlock(&acl_cache->lock)); VOID(pthread_mutex_unlock(&acl_cache->lock));
return 1; DBUG_RETURN(1);
} }
if (update_user_table(thd, if (update_user_table(thd,
acl_user->host.hostname ? acl_user->host.hostname : "", acl_user->host.hostname ? acl_user->host.hostname : "",
...@@ -929,7 +932,7 @@ bool change_password(THD *thd, const char *host, const char *user, ...@@ -929,7 +932,7 @@ bool change_password(THD *thd, const char *host, const char *user,
{ {
VOID(pthread_mutex_unlock(&acl_cache->lock)); /* purecov: deadcode */ VOID(pthread_mutex_unlock(&acl_cache->lock)); /* purecov: deadcode */
send_error(&thd->net,0); /* purecov: deadcode */ send_error(&thd->net,0); /* purecov: deadcode */
return 1; /* purecov: deadcode */ DBUG_RETURN(1); /* purecov: deadcode */
} }
get_salt_from_password(acl_user->salt,new_password); get_salt_from_password(acl_user->salt,new_password);
if (!new_password[0]) if (!new_password[0])
...@@ -950,7 +953,7 @@ bool change_password(THD *thd, const char *host, const char *user, ...@@ -950,7 +953,7 @@ bool change_password(THD *thd, const char *host, const char *user,
new_password)); new_password));
mysql_update_log.write(thd,buff,qinfo.q_len); mysql_update_log.write(thd,buff,qinfo.q_len);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
return 0; DBUG_RETURN(0);
} }
...@@ -961,17 +964,23 @@ bool change_password(THD *thd, const char *host, const char *user, ...@@ -961,17 +964,23 @@ bool change_password(THD *thd, const char *host, const char *user,
static ACL_USER * static ACL_USER *
find_acl_user(const char *host, const char *user) find_acl_user(const char *host, const char *user)
{ {
DBUG_ENTER("find_acl_user");
DBUG_PRINT("enter",("host='%s', user='%s'",host,user));
for (uint i=0 ; i < acl_users.elements ; i++) for (uint i=0 ; i < acl_users.elements ; i++)
{ {
ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*); ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*);
DBUG_PRINT("info",("strcmp('%s','%s'), compare_hostname('%s','%s'),",
user,acl_user->user,(host),(acl_user->host)));
if (!acl_user->user && !user[0] || if (!acl_user->user && !user[0] ||
acl_user->user && !strcmp(user,acl_user->user)) acl_user->user && !strcmp(user,acl_user->user))
{ {
if (compare_hostname(&acl_user->host,host,host)) if (compare_hostname(&(acl_user->host),host,host))
return acl_user; {
DBUG_RETURN(acl_user);
} }
} }
return 0; }
DBUG_RETURN(0);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -699,8 +699,11 @@ int wild_case_compare(const char *str,const char *str_end, ...@@ -699,8 +699,11 @@ int wild_case_compare(const char *str,const char *str_end,
int wild_case_compare(String &match,String &wild, char escape) int wild_case_compare(String &match,String &wild, char escape)
{ {
return wild_case_compare(match.ptr(),match.ptr()+match.length(), DBUG_ENTER("wild_case_compare");
wild.ptr(), wild.ptr()+wild.length(),escape); DBUG_PRINT("enter",("match='%s', wild='%s', escape='%c'"
,match.ptr(),wild.ptr(),escape));
DBUG_RETURN(wild_case_compare(match.ptr(),match.ptr()+match.length(),
wild.ptr(), wild.ptr()+wild.length(),escape));
} }
/* /*
...@@ -710,6 +713,9 @@ int wild_case_compare(String &match,String &wild, char escape) ...@@ -710,6 +713,9 @@ int wild_case_compare(String &match,String &wild, char escape)
int wild_compare(const char *str,const char *str_end, int wild_compare(const char *str,const char *str_end,
const char *wildstr,const char *wildend,char escape) const char *wildstr,const char *wildend,char escape)
{ {
DBUG_ENTER("wild_compare");
DBUG_PRINT("enter",("str='%s', str_end='%s', wildstr='%s', wildend='%s', escape='%c'"
,str,str_end,wildstr,wildend,escape));
int result= -1; // Not found, using wildcards int result= -1; // Not found, using wildcards
while (wildstr != wildend) while (wildstr != wildend)
{ {
...@@ -718,9 +724,13 @@ int wild_compare(const char *str,const char *str_end, ...@@ -718,9 +724,13 @@ int wild_compare(const char *str,const char *str_end,
if (*wildstr == escape && wildstr+1 != wildend) if (*wildstr == escape && wildstr+1 != wildend)
wildstr++; wildstr++;
if (str == str_end || *wildstr++ != *str++) if (str == str_end || *wildstr++ != *str++)
return(1); {
DBUG_RETURN(1);
}
if (wildstr == wildend) if (wildstr == wildend)
return (str != str_end); // Match if both are at end {
DBUG_RETURN(str != str_end); // Match if both are at end
}
result=1; // Found an anchor char result=1; // Found an anchor char
} }
if (*wildstr == wild_one) if (*wildstr == wild_one)
...@@ -728,7 +738,7 @@ int wild_compare(const char *str,const char *str_end, ...@@ -728,7 +738,7 @@ int wild_compare(const char *str,const char *str_end,
do do
{ {
if (str == str_end) // Skip one char if possible if (str == str_end) // Skip one char if possible
return (result); DBUG_RETURN(result);
str++; str++;
} while (*++wildstr == wild_one && wildstr != wildend); } while (*++wildstr == wild_one && wildstr != wildend);
if (wildstr == wildend) if (wildstr == wildend)
...@@ -745,17 +755,22 @@ int wild_compare(const char *str,const char *str_end, ...@@ -745,17 +755,22 @@ int wild_compare(const char *str,const char *str_end,
if (*wildstr == wild_one) if (*wildstr == wild_one)
{ {
if (str == str_end) if (str == str_end)
return (-1); {
DBUG_RETURN(-1);
}
str++; str++;
continue; continue;
} }
break; // Not a wild character break; // Not a wild character
} }
if (wildstr == wildend) if (wildstr == wildend)
return(0); // Ok if wild_many is last {
DBUG_RETURN(0); // Ok if wild_many is last
}
if (str == str_end) if (str == str_end)
return -1; {
DBUG_RETURN(-1);
}
char cmp; char cmp;
if ((cmp= *wildstr) == escape && wildstr+1 != wildend) if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
cmp= *++wildstr; cmp= *++wildstr;
...@@ -764,22 +779,30 @@ int wild_compare(const char *str,const char *str_end, ...@@ -764,22 +779,30 @@ int wild_compare(const char *str,const char *str_end,
{ {
while (str != str_end && *str != cmp) while (str != str_end && *str != cmp)
str++; str++;
if (str++ == str_end) return (-1); if (str++ == str_end)
{
DBUG_RETURN(-1)
};
{ {
int tmp=wild_compare(str,str_end,wildstr,wildend,escape); int tmp=wild_compare(str,str_end,wildstr,wildend,escape);
if (tmp <= 0) if (tmp <= 0)
return (tmp); {
DBUG_RETURN(tmp);
}
} }
} while (str != str_end && wildstr[0] != wild_many); } while (str != str_end && wildstr[0] != wild_many);
return(-1); DBUG_RETURN(-1);
} }
} }
return (str != str_end ? 1 : 0); DBUG_RETURN(str != str_end ? 1 : 0);
} }
int wild_compare(String &match,String &wild, char escape) int wild_compare(String &match,String &wild, char escape)
{ {
return wild_compare(match.ptr(),match.ptr()+match.length(), DBUG_ENTER("wild_compare");
wild.ptr(), wild.ptr()+wild.length(),escape); DBUG_PRINT("enter",("match='%s', wild='%s', escape='%c'"
,match.ptr(),wild.ptr(),escape));
DBUG_RETURN(wild_compare(match.ptr(),match.ptr()+match.length(),
wild.ptr(), wild.ptr()+wild.length(),escape));
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment