domain.c (64562) | domain.c (71345) |
---|---|
1/* 2 * Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * Copyright (c) 1986, 1995-1997 Eric P. Allman. All rights reserved. 5 * Copyright (c) 1988, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * By using this file, you agree to the terms and conditions set 9 * forth in the LICENSE file which can be found at the top level of 10 * the sendmail distribution. 11 * 12 */ 13 14#include <sendmail.h> 15 16#ifndef lint 17# if NAMED_BIND | 1/* 2 * Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * Copyright (c) 1986, 1995-1997 Eric P. Allman. All rights reserved. 5 * Copyright (c) 1988, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * By using this file, you agree to the terms and conditions set 9 * forth in the LICENSE file which can be found at the top level of 10 * the sendmail distribution. 11 * 12 */ 13 14#include <sendmail.h> 15 16#ifndef lint 17# if NAMED_BIND |
18static char id[] = "@(#)$Id: domain.c,v 8.114.6.1.2.3 2000/06/13 18:00:08 gshapiro Exp $ (with name server)"; | 18static char id[] = "@(#)$Id: domain.c,v 8.114.6.1.2.6 2000/12/19 02:50:33 gshapiro Exp $ (with name server)"; |
19# else /* NAMED_BIND */ | 19# else /* NAMED_BIND */ |
20static char id[] = "@(#)$Id: domain.c,v 8.114.6.1.2.3 2000/06/13 18:00:08 gshapiro Exp $ (without name server)"; | 20static char id[] = "@(#)$Id: domain.c,v 8.114.6.1.2.6 2000/12/19 02:50:33 gshapiro Exp $ (without name server)"; |
21# endif /* NAMED_BIND */ 22#endif /* ! lint */ 23 24 25#if NAMED_BIND 26 27# include <arpa/inet.h> 28 --- 359 unchanged lines hidden (view full) --- 388 389 if (h == NULL) 390 { 391 *rcode = EX_CONFIG; 392 syserr("MX list for %s points back to %s", 393 host, MyHostName); 394 return -1; 395 } | 21# endif /* NAMED_BIND */ 22#endif /* ! lint */ 23 24 25#if NAMED_BIND 26 27# include <arpa/inet.h> 28 --- 359 unchanged lines hidden (view full) --- 388 389 if (h == NULL) 390 { 391 *rcode = EX_CONFIG; 392 syserr("MX list for %s points back to %s", 393 host, MyHostName); 394 return -1; 395 } |
396# if _FFR_FREEHOSTENT && NETINET6 397 freehostent(h); 398 hp = NULL; 399# endif /* _FFR_FREEHOSTENT && NETINET6 */ |
|
396 } 397 if (strlen(host) >= (SIZE_T) sizeof MXHostBuf) 398 { 399 *rcode = EX_CONFIG; 400 syserr("Host name %s too long", 401 shortenstring(host, MAXSHORTSTR)); 402 return -1; 403 } --- 231 unchanged lines hidden (view full) --- 635 dprintf("dns_getcanonname(%s, trymx=%d)\n", host, trymx); 636 637 if ((_res.options & RES_INIT) == 0 && res_init() == -1) 638 { 639 *statp = EX_UNAVAILABLE; 640 return FALSE; 641 } 642 | 400 } 401 if (strlen(host) >= (SIZE_T) sizeof MXHostBuf) 402 { 403 *rcode = EX_CONFIG; 404 syserr("Host name %s too long", 405 shortenstring(host, MAXSHORTSTR)); 406 return -1; 407 } --- 231 unchanged lines hidden (view full) --- 639 dprintf("dns_getcanonname(%s, trymx=%d)\n", host, trymx); 640 641 if ((_res.options & RES_INIT) == 0 && res_init() == -1) 642 { 643 *statp = EX_UNAVAILABLE; 644 return FALSE; 645 } 646 |
647 *statp = EX_OK; 648 |
|
643 /* 644 ** Initialize domain search list. If there is at least one 645 ** dot in the name, search the unmodified name first so we 646 ** find "vse.CS" in Czechoslovakia instead of in the local 647 ** domain (e.g., vse.CS.Berkeley.EDU). Note that there is no 648 ** longer a country named Czechoslovakia but this type of problem 649 ** is still present. 650 ** --- 74 unchanged lines hidden (view full) --- 725 host, *dp, 726 qtype == T_ANY ? "ANY" : 727# if NETINET6 728 qtype == T_AAAA ? "AAAA" : 729# endif /* NETINET6 */ 730 qtype == T_A ? "A" : 731 qtype == T_MX ? "MX" : 732 "???"); | 649 /* 650 ** Initialize domain search list. If there is at least one 651 ** dot in the name, search the unmodified name first so we 652 ** find "vse.CS" in Czechoslovakia instead of in the local 653 ** domain (e.g., vse.CS.Berkeley.EDU). Note that there is no 654 ** longer a country named Czechoslovakia but this type of problem 655 ** is still present. 656 ** --- 74 unchanged lines hidden (view full) --- 731 host, *dp, 732 qtype == T_ANY ? "ANY" : 733# if NETINET6 734 qtype == T_AAAA ? "AAAA" : 735# endif /* NETINET6 */ 736 qtype == T_A ? "A" : 737 qtype == T_MX ? "MX" : 738 "???"); |
739 errno = 0; |
|
733 ret = res_querydomain(host, *dp, C_IN, qtype, 734 answer.qb2, sizeof(answer.qb2)); 735 if (ret <= 0) 736 { 737 if (tTd(8, 7)) 738 dprintf("\tNO: errno=%d, h_errno=%d\n", 739 errno, h_errno); 740 741 if (errno == ECONNREFUSED || h_errno == TRY_AGAIN) 742 { | 740 ret = res_querydomain(host, *dp, C_IN, qtype, 741 answer.qb2, sizeof(answer.qb2)); 742 if (ret <= 0) 743 { 744 if (tTd(8, 7)) 745 dprintf("\tNO: errno=%d, h_errno=%d\n", 746 errno, h_errno); 747 748 if (errno == ECONNREFUSED || h_errno == TRY_AGAIN) 749 { |
743 /* the name server seems to be down */ | 750 /* 751 ** the name server seems to be down or 752 ** broken. 753 */ 754 |
744 h_errno = TRY_AGAIN; 745 *statp = EX_TEMPFAIL; 746 747 /* 748 ** If the ANY query is larger than the 749 ** UDP packet size, the resolver will 750 ** fall back to TCP. However, some 751 ** misconfigured firewalls block 53/TCP 752 ** so the ANY lookup fails whereas an MX 753 ** or A record might work. Therefore, 754 ** don't fail on ANY queries. 755 ** 756 ** The ANY query is really meant to prime 757 ** the cache so this isn't dangerous. 758 */ 759 | 755 h_errno = TRY_AGAIN; 756 *statp = EX_TEMPFAIL; 757 758 /* 759 ** If the ANY query is larger than the 760 ** UDP packet size, the resolver will 761 ** fall back to TCP. However, some 762 ** misconfigured firewalls block 53/TCP 763 ** so the ANY lookup fails whereas an MX 764 ** or A record might work. Therefore, 765 ** don't fail on ANY queries. 766 ** 767 ** The ANY query is really meant to prime 768 ** the cache so this isn't dangerous. 769 */ 770 |
771#if _FFR_WORKAROUND_BROKEN_NAMESERVERS 772 /* 773 ** Only return if not TRY_AGAIN as an 774 ** attempt with a different qtype may 775 ** succeed (res_querydomain() calls 776 ** res_query() calls res_send() which 777 ** sets errno to ETIMEDOUT if the 778 ** nameservers could be contacted but 779 ** didn't give an answer). 780 */ 781 782 if (qtype != T_ANY && errno != ETIMEDOUT) 783 return FALSE; 784#else /* _FFR_WORKAROUND_BROKEN_NAMESERVERS */ |
|
760 if (qtype != T_ANY) 761 return FALSE; | 785 if (qtype != T_ANY) 786 return FALSE; |
787#endif /* _FFR_WORKAROUND_BROKEN_NAMESERVERS */ |
|
762 } 763 764 if (h_errno != HOST_NOT_FOUND) 765 { 766 /* might have another type of interest */ 767 if (qtype == T_ANY) 768 { 769# if NETINET6 --- 201 unchanged lines hidden (view full) --- 971 qtype = T_ANY; 972 dp++; 973 } 974 } 975 976 /* if nothing was found, we are done */ 977 if (mxmatch == NULL) 978 { | 788 } 789 790 if (h_errno != HOST_NOT_FOUND) 791 { 792 /* might have another type of interest */ 793 if (qtype == T_ANY) 794 { 795# if NETINET6 --- 201 unchanged lines hidden (view full) --- 997 qtype = T_ANY; 998 dp++; 999 } 1000 } 1001 1002 /* if nothing was found, we are done */ 1003 if (mxmatch == NULL) 1004 { |
979 *statp = EX_NOHOST; | 1005 if (*statp == EX_OK) 1006 *statp = EX_NOHOST; |
980 return FALSE; 981 } 982 983 /* 984 ** Create canonical name and return. 985 ** If saved domain name is null, name was already canonical. 986 ** Otherwise append the saved domain name. 987 */ --- 61 unchanged lines hidden --- | 1007 return FALSE; 1008 } 1009 1010 /* 1011 ** Create canonical name and return. 1012 ** If saved domain name is null, name was already canonical. 1013 ** Otherwise append the saved domain name. 1014 */ --- 61 unchanged lines hidden --- |