conf.c (71348) | conf.c (73191) |
---|---|
1/* | 1/* |
2 * Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers. | 2 * Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers. |
3 * All rights reserved. 4 * Copyright (c) 1983, 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#ifndef lint | 3 * All rights reserved. 4 * Copyright (c) 1983, 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#ifndef lint |
15static char id[] = "@(#)$Id: conf.c,v 8.646.2.2.2.61 2000/12/28 23:46:41 gshapiro Exp $"; | 15static char id[] = "@(#)$Id: conf.c,v 8.646.2.2.2.69 2001/02/27 19:50:11 gshapiro Exp $"; |
16#endif /* ! lint */ 17 | 16#endif /* ! lint */ 17 |
18/* $FreeBSD: head/contrib/sendmail/src/conf.c 71348 2001-01-21 22:21:43Z gshapiro $ */ | 18/* $FreeBSD: head/contrib/sendmail/src/conf.c 73191 2001-02-28 00:22:47Z gshapiro $ */ |
19 20#include <sendmail.h> 21#include <sendmail/pathnames.h> 22 23# include <sys/ioctl.h> 24# include <sys/param.h> 25 26#include <limits.h> --- 4328 unchanged lines hidden (view full) --- 4355 struct hostent *h; 4356 4357 if (family == AF_INET6) 4358 { 4359 /* From RFC2133, section 6.1 */ 4360 resv6 = bitset(RES_USE_INET6, _res.options); 4361 _res.options |= RES_USE_INET6; 4362 } | 19 20#include <sendmail.h> 21#include <sendmail/pathnames.h> 22 23# include <sys/ioctl.h> 24# include <sys/param.h> 25 26#include <limits.h> --- 4328 unchanged lines hidden (view full) --- 4355 struct hostent *h; 4356 4357 if (family == AF_INET6) 4358 { 4359 /* From RFC2133, section 6.1 */ 4360 resv6 = bitset(RES_USE_INET6, _res.options); 4361 _res.options |= RES_USE_INET6; 4362 } |
4363 h_errno = 0; | 4363 SM_SET_H_ERRNO(0); |
4364 h = gethostbyname(name); 4365 *err = h_errno; 4366 if (family == AF_INET6 && !resv6) 4367 _res.options &= ~RES_USE_INET6; 4368 return h; 4369} 4370 4371static struct hostent * 4372getipnodebyaddr(addr, len, family, err) 4373 char *addr; 4374 int len; 4375 int family; 4376 int *err; 4377{ 4378 struct hostent *h; 4379 | 4364 h = gethostbyname(name); 4365 *err = h_errno; 4366 if (family == AF_INET6 && !resv6) 4367 _res.options &= ~RES_USE_INET6; 4368 return h; 4369} 4370 4371static struct hostent * 4372getipnodebyaddr(addr, len, family, err) 4373 char *addr; 4374 int len; 4375 int family; 4376 int *err; 4377{ 4378 struct hostent *h; 4379 |
4380 h_errno = 0; | 4380 SM_SET_H_ERRNO(0); |
4381 h = gethostbyaddr(addr, len, family); 4382 *err = h_errno; 4383 return h; 4384} 4385 4386# if _FFR_FREEHOSTENT 4387void 4388freehostent(h) --- 9 unchanged lines hidden (view full) --- 4398# endif /* _FFR_FREEHOSTENT */ 4399#endif /* NEEDSGETIPNODE && NETINET6 && __RES < 19990909 */ 4400 4401struct hostent * 4402sm_gethostbyname(name, family) 4403 char *name; 4404 int family; 4405{ | 4381 h = gethostbyaddr(addr, len, family); 4382 *err = h_errno; 4383 return h; 4384} 4385 4386# if _FFR_FREEHOSTENT 4387void 4388freehostent(h) --- 9 unchanged lines hidden (view full) --- 4398# endif /* _FFR_FREEHOSTENT */ 4399#endif /* NEEDSGETIPNODE && NETINET6 && __RES < 19990909 */ 4400 4401struct hostent * 4402sm_gethostbyname(name, family) 4403 char *name; 4404 int family; 4405{ |
4406 int save_errno; |
|
4406 struct hostent *h = NULL; 4407#if (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) 4408# if SOLARIS == 20300 || SOLARIS == 203 4409 static struct hostent hp; 4410 static char buf[1000]; 4411 extern struct hostent *_switch_gethostbyname_r(); 4412 4413 if (tTd(61, 10)) 4414 dprintf("_switch_gethostbyname_r(%s)... ", name); 4415 h = _switch_gethostbyname_r(name, &hp, buf, sizeof(buf), &h_errno); | 4407 struct hostent *h = NULL; 4408#if (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) 4409# if SOLARIS == 20300 || SOLARIS == 203 4410 static struct hostent hp; 4411 static char buf[1000]; 4412 extern struct hostent *_switch_gethostbyname_r(); 4413 4414 if (tTd(61, 10)) 4415 dprintf("_switch_gethostbyname_r(%s)... ", name); 4416 h = _switch_gethostbyname_r(name, &hp, buf, sizeof(buf), &h_errno); |
4417 save_errno = errno; |
|
4416# else /* SOLARIS == 20300 || SOLARIS == 203 */ 4417 extern struct hostent *__switch_gethostbyname(); 4418 4419 if (tTd(61, 10)) 4420 dprintf("__switch_gethostbyname(%s)... ", name); 4421 h = __switch_gethostbyname(name); | 4418# else /* SOLARIS == 20300 || SOLARIS == 203 */ 4419 extern struct hostent *__switch_gethostbyname(); 4420 4421 if (tTd(61, 10)) 4422 dprintf("__switch_gethostbyname(%s)... ", name); 4423 h = __switch_gethostbyname(name); |
4424 save_errno = errno; |
|
4422# endif /* SOLARIS == 20300 || SOLARIS == 203 */ 4423#else /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */ 4424 int nmaps; 4425# if NETINET6 4426 int flags = AI_DEFAULT|AI_ALL; 4427 int err; 4428# endif /* NETINET6 */ | 4425# endif /* SOLARIS == 20300 || SOLARIS == 203 */ 4426#else /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */ 4427 int nmaps; 4428# if NETINET6 4429 int flags = AI_DEFAULT|AI_ALL; 4430 int err; 4431# endif /* NETINET6 */ |
4429 int save_errno; | |
4430 char *maptype[MAXMAPSTACK]; 4431 short mapreturn[MAXMAPACTIONS]; 4432 char hbuf[MAXNAME]; 4433 4434 if (tTd(61, 10)) 4435 dprintf("sm_gethostbyname(%s, %d)... ", name, family); 4436 4437# if NETINET6 4438# if ADDRCONFIG_IS_BROKEN 4439 flags &= ~AI_ADDRCONFIG; 4440# endif /* ADDRCONFIG_IS_BROKEN */ 4441 h = getipnodebyname(name, family, flags, &err); | 4432 char *maptype[MAXMAPSTACK]; 4433 short mapreturn[MAXMAPACTIONS]; 4434 char hbuf[MAXNAME]; 4435 4436 if (tTd(61, 10)) 4437 dprintf("sm_gethostbyname(%s, %d)... ", name, family); 4438 4439# if NETINET6 4440# if ADDRCONFIG_IS_BROKEN 4441 flags &= ~AI_ADDRCONFIG; 4442# endif /* ADDRCONFIG_IS_BROKEN */ 4443 h = getipnodebyname(name, family, flags, &err); |
4442 h_errno = err; | 4444 SM_SET_H_ERRNO(err); |
4443# else /* NETINET6 */ 4444 h = gethostbyname(name); 4445# endif /* NETINET6 */ 4446 4447 save_errno = errno; 4448 if (h == NULL) 4449 { 4450 if (tTd(61, 10)) --- 11 unchanged lines hidden (view full) --- 4462 { 4463 /* try short name */ 4464 if (strlen(name) > (SIZE_T) sizeof hbuf - 1) 4465 { 4466 errno = save_errno; 4467 return NULL; 4468 } 4469 (void) strlcpy(hbuf, name, sizeof hbuf); | 4445# else /* NETINET6 */ 4446 h = gethostbyname(name); 4447# endif /* NETINET6 */ 4448 4449 save_errno = errno; 4450 if (h == NULL) 4451 { 4452 if (tTd(61, 10)) --- 11 unchanged lines hidden (view full) --- 4464 { 4465 /* try short name */ 4466 if (strlen(name) > (SIZE_T) sizeof hbuf - 1) 4467 { 4468 errno = save_errno; 4469 return NULL; 4470 } 4471 (void) strlcpy(hbuf, name, sizeof hbuf); |
4470 shorten_hostname(hbuf); | 4472 (void) shorten_hostname(hbuf); |
4471 4472 /* if it hasn't been shortened, there's no point */ 4473 if (strcmp(hbuf, name) != 0) 4474 { 4475 if (tTd(61, 10)) 4476 dprintf("sm_gethostbyname(%s, %d)... ", 4477 hbuf, family); 4478 4479# if NETINET6 4480 h = getipnodebyname(hbuf, family, 4481 AI_V4MAPPED|AI_ALL, 4482 &err); | 4473 4474 /* if it hasn't been shortened, there's no point */ 4475 if (strcmp(hbuf, name) != 0) 4476 { 4477 if (tTd(61, 10)) 4478 dprintf("sm_gethostbyname(%s, %d)... ", 4479 hbuf, family); 4480 4481# if NETINET6 4482 h = getipnodebyname(hbuf, family, 4483 AI_V4MAPPED|AI_ALL, 4484 &err); |
4483 h_errno = err; | 4485 SM_SET_H_ERRNO(err); |
4484 save_errno = errno; 4485# else /* NETINET6 */ 4486 h = gethostbyname(hbuf); 4487 save_errno = errno; 4488# endif /* NETINET6 */ 4489 } 4490 } 4491 } --- 46 unchanged lines hidden (view full) --- 4538 4539struct hostent * 4540sm_gethostbyaddr(addr, len, type) 4541 char *addr; 4542 int len; 4543 int type; 4544{ 4545 struct hostent *hp; | 4486 save_errno = errno; 4487# else /* NETINET6 */ 4488 h = gethostbyname(hbuf); 4489 save_errno = errno; 4490# endif /* NETINET6 */ 4491 } 4492 } 4493 } --- 46 unchanged lines hidden (view full) --- 4540 4541struct hostent * 4542sm_gethostbyaddr(addr, len, type) 4543 char *addr; 4544 int len; 4545 int type; 4546{ 4547 struct hostent *hp; |
4548 4549#if NETINET6 4550 if (type == AF_INET6 && 4551 IN6_IS_ADDR_UNSPECIFIED((struct in6_addr *) addr)) 4552 { 4553 /* Avoid reverse lookup for IPv6 unspecified address */ 4554 SM_SET_H_ERRNO(HOST_NOT_FOUND); 4555 return NULL; 4556 } 4557#endif /* NETINET6 */ 4558 |
|
4546#if (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) 4547# if SOLARIS == 20300 || SOLARIS == 203 | 4559#if (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) 4560# if SOLARIS == 20300 || SOLARIS == 203 |
4548 static struct hostent he; 4549 static char buf[1000]; 4550 extern struct hostent *_switch_gethostbyaddr_r(); | 4561 { 4562 static struct hostent he; 4563 static char buf[1000]; 4564 extern struct hostent *_switch_gethostbyaddr_r(); |
4551 | 4565 |
4552 hp = _switch_gethostbyaddr_r(addr, len, type, &he, buf, sizeof(buf), &h_errno); | 4566 hp = _switch_gethostbyaddr_r(addr, len, type, &he, 4567 buf, sizeof(buf), &h_errno); 4568 } |
4553# else /* SOLARIS == 20300 || SOLARIS == 203 */ | 4569# else /* SOLARIS == 20300 || SOLARIS == 203 */ |
4554 extern struct hostent *__switch_gethostbyaddr(); | 4570 { 4571 extern struct hostent *__switch_gethostbyaddr(); |
4555 | 4572 |
4556 hp = __switch_gethostbyaddr(addr, len, type); | 4573 hp = __switch_gethostbyaddr(addr, len, type); 4574 } |
4557# endif /* SOLARIS == 20300 || SOLARIS == 203 */ 4558#else /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) */ 4559# if NETINET6 | 4575# endif /* SOLARIS == 20300 || SOLARIS == 203 */ 4576#else /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) */ 4577# if NETINET6 |
4560 int err; 4561# endif /* NETINET6 */ | 4578 { 4579 int err; |
4562 | 4580 |
4563# if NETINET6 4564 hp = getipnodebyaddr(addr, len, type, &err); 4565 h_errno = err; | 4581 hp = getipnodebyaddr(addr, len, type, &err); 4582 SM_SET_H_ERRNO(err); 4583 } |
4566# else /* NETINET6 */ 4567 hp = gethostbyaddr(addr, len, type); 4568# endif /* NETINET6 */ 4569 return hp; 4570#endif /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) */ 4571} 4572/* 4573** SM_GETPW{NAM,UID} -- wrapper for getpwnam and getpwuid --- 358 unchanged lines hidden (view full) --- 4932# endif /* SIOCGLIFFLAGS */ 4933 4934 ip_addr[0] = '\0'; 4935 4936 /* extract IP address from the list*/ 4937 switch (af) 4938 { 4939 case AF_INET6: | 4584# else /* NETINET6 */ 4585 hp = gethostbyaddr(addr, len, type); 4586# endif /* NETINET6 */ 4587 return hp; 4588#endif /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) */ 4589} 4590/* 4591** SM_GETPW{NAM,UID} -- wrapper for getpwnam and getpwuid --- 358 unchanged lines hidden (view full) --- 4950# endif /* SIOCGLIFFLAGS */ 4951 4952 ip_addr[0] = '\0'; 4953 4954 /* extract IP address from the list*/ 4955 switch (af) 4956 { 4957 case AF_INET6: |
4940 ia6 = sa->sin6.sin6_addr; 4941# ifdef __KAME__ 4942 /* convert into proper scoped address - */ 4943 if ((IN6_IS_ADDR_LINKLOCAL(&ia6) || 4944 IN6_IS_ADDR_SITELOCAL(&ia6)) && | 4958# ifdef __KAME__ 4959 /* convert into proper scoped address */ 4960 if ((IN6_IS_ADDR_LINKLOCAL(&sa->sin6.sin6_addr) || 4961 IN6_IS_ADDR_SITELOCAL(&sa->sin6.sin6_addr)) && |
4945 sa->sin6.sin6_scope_id == 0) 4946 { | 4962 sa->sin6.sin6_scope_id == 0) 4963 { |
4947 sa->sin6.sin6_scope_id = ntohs(ia6.s6_addr[3] | 4948 ((unsigned int) ia6.s6_addr[2] << 8)); 4949 ia6.s6_addr[2] = ia6.s6_addr[3] = 0; | 4964 struct in6_addr *ia6p; 4965 4966 ia6p = &sa->sin6.sin6_addr; 4967 sa->sin6.sin6_scope_id = ntohs(ia6p->s6_addr[3] | 4968 ((unsigned int)ia6p->s6_addr[2] << 8)); 4969 ia6p->s6_addr[2] = ia6p->s6_addr[3] = 0; |
4950 } | 4970 } |
4951# endif /* __KAME__ */ | 4971# endif /* __KAME__ */ 4972 ia6 = sa->sin6.sin6_addr; |
4952 if (IN6_IS_ADDR_UNSPECIFIED(&ia6)) 4953 { 4954 addr = anynet_ntop(&ia6, buf6, sizeof buf6); 4955 message("WARNING: interface %s is UP with %s address", 4956 ifr->lifr_name, 4957 addr == NULL ? "(NULL)" : addr); 4958 continue; 4959 } --- 166 unchanged lines hidden (view full) --- 5126 /* save IP address in text from */ 5127 (void) snprintf(ip_addr, sizeof ip_addr, "[%.*s]", 5128 (int) sizeof ip_addr - 3, 5129 inet_ntoa(ia)); 5130 break; 5131 5132# if NETINET6 5133 case AF_INET6: | 4973 if (IN6_IS_ADDR_UNSPECIFIED(&ia6)) 4974 { 4975 addr = anynet_ntop(&ia6, buf6, sizeof buf6); 4976 message("WARNING: interface %s is UP with %s address", 4977 ifr->lifr_name, 4978 addr == NULL ? "(NULL)" : addr); 4979 continue; 4980 } --- 166 unchanged lines hidden (view full) --- 5147 /* save IP address in text from */ 5148 (void) snprintf(ip_addr, sizeof ip_addr, "[%.*s]", 5149 (int) sizeof ip_addr - 3, 5150 inet_ntoa(ia)); 5151 break; 5152 5153# if NETINET6 5154 case AF_INET6: |
5155# ifdef __KAME__ 5156 /* convert into proper scoped address */ 5157 if ((IN6_IS_ADDR_LINKLOCAL(&sa->sin6.sin6_addr) || 5158 IN6_IS_ADDR_SITELOCAL(&sa->sin6.sin6_addr)) && 5159 sa->sin6.sin6_scope_id == 0) 5160 { 5161 struct in6_addr *ia6p; 5162 5163 ia6p = &sa->sin6.sin6_addr; 5164 sa->sin6.sin6_scope_id = ntohs(ia6p->s6_addr[3] | 5165 ((unsigned int)ia6p->s6_addr[2] << 8)); 5166 ia6p->s6_addr[2] = ia6p->s6_addr[3] = 0; 5167 } 5168# endif /* __KAME__ */ |
|
5134 ia6 = sa->sin6.sin6_addr; 5135 if (IN6_IS_ADDR_UNSPECIFIED(&ia6)) 5136 { 5137 addr = anynet_ntop(&ia6, buf6, sizeof buf6); 5138 message("WARNING: interface %s is UP with %s address", 5139 ifr->ifr_name, 5140 addr == NULL ? "(NULL)" : addr); 5141 continue; --- 604 unchanged lines hidden --- | 5169 ia6 = sa->sin6.sin6_addr; 5170 if (IN6_IS_ADDR_UNSPECIFIED(&ia6)) 5171 { 5172 addr = anynet_ntop(&ia6, buf6, sizeof buf6); 5173 message("WARNING: interface %s is UP with %s address", 5174 ifr->ifr_name, 5175 addr == NULL ? "(NULL)" : addr); 5176 continue; --- 604 unchanged lines hidden --- |