|
Lines 399-406
Link Here
|
| 399 |
return 0; |
399 |
return 0; |
| 400 |
} |
400 |
} |
| 401 |
|
401 |
|
| 402 |
BOOL tptp_checkHost(network_list_t *list, unsigned char *address) { |
402 |
int isLocalHost(char* name) { |
|
|
403 |
tptp_IPAddresses_t localAddresses; |
| 404 |
struct hostent *he; |
| 405 |
unsigned char *addr, *cur; |
| 406 |
int len, res; |
| 407 |
|
| 408 |
if (name == NULL) return 0; |
| 409 |
|
| 410 |
he = gethostbyname(name); |
| 411 |
if (he == NULL || he->h_addr_list == NULL || he->h_addr_list[0] == '\0') return 0; |
| 412 |
|
| 413 |
addr = he->h_addr_list[0]; |
| 414 |
|
| 415 |
if(tptp_getLocalIPAddresses(&localAddresses) != 0) return 0; |
| 416 |
|
| 417 |
res = 0; |
| 418 |
len = localAddresses.addressLength; |
| 419 |
cur = localAddresses.addresses; |
| 420 |
|
| 421 |
while(*cur) { |
| 422 |
if(cur[0]==addr[0] && cur[1]==addr[1] && cur[2]==addr[2] && cur[3] == addr[3]) { |
| 423 |
res = 1; |
| 424 |
break; |
| 425 |
} |
| 403 |
|
426 |
|
|
|
427 |
cur+=len; |
| 428 |
} |
| 429 |
|
| 430 |
tptp_free(localAddresses.addresses); |
| 431 |
|
| 432 |
return res; |
| 433 |
} |
| 434 |
|
| 435 |
BOOL tptp_checkHost(network_list_t *list, unsigned char *address) { |
| 404 |
network_list_node_t *current; |
436 |
network_list_node_t *current; |
| 405 |
|
437 |
|
| 406 |
//If the list or host address is not specified then return TRUE. |
438 |
//If the list or host address is not specified then return TRUE. |
|
Lines 420-425
Link Here
|
| 420 |
tptp_IPAddresses_t localAddresses; |
452 |
tptp_IPAddresses_t localAddresses; |
| 421 |
network_t *entry=current->entry; |
453 |
network_t *entry=current->entry; |
| 422 |
/* Is this an allow rule */ |
454 |
/* Is this an allow rule */ |
|
|
455 |
|
| 423 |
switch(entry->wildcard) { |
456 |
switch(entry->wildcard) { |
| 424 |
case TPTP_HW_ALL: |
457 |
case TPTP_HW_ALL: |
| 425 |
if(entry->allow) { |
458 |
if(entry->allow) { |
|
Lines 480-485
Link Here
|
| 480 |
/* 1 hostent structure per thread, */ |
513 |
/* 1 hostent structure per thread, */ |
| 481 |
struct hostent *hostentTemp; |
514 |
struct hostent *hostentTemp; |
| 482 |
|
515 |
|
|
|
516 |
/* Resolve the listed IP address in the config file */ |
| 517 |
hostentTemp = gethostbyname(entry->hostname); |
| 518 |
if(hostentTemp != NULL) { |
| 519 |
strcpy(hostnameAllowed, hostentTemp->h_name); |
| 520 |
} |
| 521 |
|
| 483 |
/* Resolve the remote host IP address */ |
522 |
/* Resolve the remote host IP address */ |
| 484 |
hostentTemp = gethostbyaddr((char*)address, 4 * sizeof(char), AF_INET); |
523 |
hostentTemp = gethostbyaddr((char*)address, 4 * sizeof(char), AF_INET); |
| 485 |
|
524 |
|
|
Lines 488-499
Link Here
|
| 488 |
aliases = *(hostentTemp->h_aliases); /* Check the aliases */ |
527 |
aliases = *(hostentTemp->h_aliases); /* Check the aliases */ |
| 489 |
} |
528 |
} |
| 490 |
|
529 |
|
| 491 |
/* Resolve the listed IP address in the config file */ |
|
|
| 492 |
hostentTemp = gethostbyname(entry->hostname); |
| 493 |
if(hostentTemp != NULL) { |
| 494 |
strcpy(hostnameAllowed, hostentTemp->h_name); |
| 495 |
} |
| 496 |
|
| 497 |
/* First, check the hostname, if identical, check if it is set to ALLOW */ |
530 |
/* First, check the hostname, if identical, check if it is set to ALLOW */ |
| 498 |
if(strcasecmp(hostnameEntry, hostnameAllowed)==0) { |
531 |
if(strcasecmp(hostnameEntry, hostnameAllowed)==0) { |
| 499 |
if(entry->allow) { |
532 |
if(entry->allow) { |
|
Lines 512-521
Link Here
|
| 512 |
} |
545 |
} |
| 513 |
aliases+=sizeof(char*); |
546 |
aliases+=sizeof(char*); |
| 514 |
} |
547 |
} |
|
|
548 |
|
| 549 |
if (isLocalHost(hostnameAllowed) && isLocalHost(hostnameEntry)) { |
| 550 |
return entry->allow ? TRUE : FALSE; |
| 551 |
} |
| 515 |
} |
552 |
} |
| 516 |
break; |
553 |
break; |
| 517 |
} |
554 |
} |
| 518 |
current=current->next; |
555 |
current=current->next; |
| 519 |
} |
556 |
} |
|
|
557 |
|
| 520 |
return FALSE; |
558 |
return FALSE; |
| 521 |
} |
559 |
} |