snprintf(str, sizeof(str),
"SELECT ttl, rdtype, rdata FROM %s WHERE "
"UPPER(name) = UPPER('%s') ", dbi->table, name);
//isc_mem_put(ns_g_mctx, canonname, strlen(name) *
2 + 1);
result = maybe_reconnect(dbi);
if (result != ISC_R_SUCCESS)
return (result);
if( mysql_query(&dbi->conn, str) != 0 )
{
return (ISC_R_FAILURE);
}
res = mysql_store_result(&dbi->conn);
if (mysql_num_rows(res) == 0)
{
mysql_free_result(res);
snprintf(str, sizeof(str),
"SELECT ttl, rdtype, rdata FROM %s WHERE "
"UPPER(name) =
UPPER(CONCAT('*',SUBSTRING('%s',INSTR('%s','.')))) ",
dbi->table, name, name);
result = maybe_reconnect(dbi);
if (result != ISC_R_SUCCESS)
return (result);
if( mysql_query(&dbi->conn, str) != 0 )
{
return (ISC_R_FAILURE);
}
res = mysql_store_result(&dbi->conn);
if (mysql_num_rows(res) == 0)
{
mysql_free_result(res);
return (ISC_R_NOTFOUND);
}
}
Logged In: NO
AlwaysHC
I have modified your patch so now it can use unlimited subdomain depth. e.g.
Unlimited.a.b.c.d.e.f.doamin.com.
new function that extract the domain name
// NEW FUNC BEGIN
/*
Extract the domain name
*/
static int d_ex(char *search, char *domain)
{
char mdot[]=".";
char *array[142];
int loop;
array[0]=strtok(search,mdot);
if(array[0]==NULL)
{
return 1;
}
for(loop=1;loop<142;loop++)
{
array[loop]=strtok(NULL,mdot);
if(array[loop]==NULL)
break;
}
if(loop<2) {
return 1;
}
snprintf(domain,255,"%s.%s",array[loop-2],array[loop-1]);
return 0;
}
// NEW FUNC END
AND YOUR PATCH MODIFIED HERE
// BEGIN PATCH
snprintf(str, sizeof(str),
"SELECT ttl, rdtype, rdata FROM %s WHERE "
"UPPER(name) = UPPER('%s') ", dbi->table, name);
//isc_mem_put(ns_g_mctx, canonname, strlen(name) *
2 + 1);
result = maybe_reconnect(dbi);
if (result != ISC_R_SUCCESS)
return (result);
if( mysql_query(&dbi->conn, str) != 0 )
{
return (ISC_R_FAILURE);
}
res = mysql_store_result(&dbi->conn);
if (mysql_num_rows(res) == 0)
{
char domain[255];
char non_cons_name[255];
strcpy(non_cons_name,name);
if(d_ex(non_cons_name,domain) != 0) {
return (ISC_R_FAILURE);
}
mysql_free_result(res);
snprintf(str, sizeof(str), "SELECT ttl, rdtype, rdata FROM %s WHERE UPPER(name) = UPPER('*.%s') ",dbi->table, domain);
result = maybe_reconnect(dbi);
if (result != ISC_R_SUCCESS)
return (result);
if( mysql_query(&dbi->conn, str) != 0 )
{
return (ISC_R_FAILURE);
}
res = mysql_store_result(&dbi->conn);
if (mysql_num_rows(res) == 0)
{
mysql_free_result(res);
return (ISC_R_NOTFOUND);
}
}
// END PATCH
Logged In: YES
user_id=1849057
Originator: NO
AlwaysHC
I have modified your patch so now it can use unlimited subdomain depth. e.g.
Unlimited.a.b.c.d.e.f.doamin.com.
new function that extract the domain name
// NEW FUNC BEGIN
/*
Extract the domain name
*/
static int d_ex(char *search, char *domain)
{
char mdot[]=".";
char *array[142];
int loop;
array[0]=strtok(search,mdot);
if(array[0]==NULL)
{
return 1;
}
for(loop=1;loop<142;loop++)
{
array[loop]=strtok(NULL,mdot);
if(array[loop]==NULL)
break;
}
if(loop<2) {
return 1;
}
snprintf(domain,255,"%s.%s",array[loop-2],array[loop-1]);
return 0;
}
// NEW FUNC END
AND YOUR PATCH MODIFIED HERE
// BEGIN PATCH
snprintf(str, sizeof(str),
"SELECT ttl, rdtype, rdata FROM %s WHERE "
"UPPER(name) = UPPER('%s') ", dbi->table, name);
//isc_mem_put(ns_g_mctx, canonname, strlen(name) *
2 + 1);
result = maybe_reconnect(dbi);
if (result != ISC_R_SUCCESS)
return (result);
if( mysql_query(&dbi->conn, str) != 0 )
{
return (ISC_R_FAILURE);
}
res = mysql_store_result(&dbi->conn);
if (mysql_num_rows(res) == 0)
{
char domain[255];
char non_cons_name[255];
strcpy(non_cons_name,name);
if(d_ex(non_cons_name,domain) != 0) {
return (ISC_R_FAILURE);
}
mysql_free_result(res);
snprintf(str, sizeof(str), "SELECT ttl, rdtype, rdata FROM %s WHERE UPPER(name) = UPPER('*.%s') ",dbi->table, domain);
result = maybe_reconnect(dbi);
if (result != ISC_R_SUCCESS)
return (result);
if( mysql_query(&dbi->conn, str) != 0 )
{
return (ISC_R_FAILURE);
}
res = mysql_store_result(&dbi->conn);
if (mysql_num_rows(res) == 0)
{
mysql_free_result(res);
return (ISC_R_NOTFOUND);
}
}
// END PATCH