diff options
Diffstat (limited to 'contrib/sendmail/src/conf.c')
-rw-r--r-- | contrib/sendmail/src/conf.c | 114 |
1 files changed, 76 insertions, 38 deletions
diff --git a/contrib/sendmail/src/conf.c b/contrib/sendmail/src/conf.c index 6bebd2c..f1d5a8a 100644 --- a/contrib/sendmail/src/conf.c +++ b/contrib/sendmail/src/conf.c @@ -12,7 +12,7 @@ */ #ifndef lint -static char id[] = "@(#)$Id: conf.c,v 8.646.2.2.2.32 2000/09/23 00:31:33 ca Exp $"; +static char id[] = "@(#)$Id: conf.c,v 8.646.2.2.2.61 2000/12/28 23:46:41 gshapiro Exp $"; #endif /* ! lint */ #include <sendmail.h> @@ -380,7 +380,7 @@ setupmailers() { char buf[100]; - (void) strlcpy(buf, "prog, P=/bin/sh, F=lsoDq9, T=X-Unix/X-Unix/X-Unix, A=sh -c \201u", + (void) strlcpy(buf, "prog, P=/bin/sh, F=lsouDq9, T=X-Unix/X-Unix/X-Unix, A=sh -c \201u", sizeof buf); makemailer(buf); @@ -825,7 +825,7 @@ switch_map_find(service, maptype, mapreturn) char *maptype[MAXMAPSTACK]; short mapreturn[MAXMAPACTIONS]; { - int svcno; + int svcno = 0; int save_errno = errno; #ifdef _USE_SUN_NSSWITCH_ @@ -845,7 +845,7 @@ switch_map_find(service, maptype, mapreturn) else lk = nsw_conf->lookups; svcno = 0; - while (lk != NULL) + while (lk != NULL && svcno < MAXMAPSTACK) { maptype[svcno] = lk->service_name; if (lk->actions[__NSW_NOTFOUND] == __NSW_RETURN) @@ -882,7 +882,7 @@ switch_map_find(service, maptype, mapreturn) errno = save_errno; return -1; } - for (svcno = 0; svcno < SVC_PATHSIZE; svcno++) + for (svcno = 0; svcno < SVC_PATHSIZE && svcno < MAXMAPSTACK; svcno++) { switch (svcinfo->svcpath[svc][svcno]) { @@ -1512,6 +1512,7 @@ init_vendor_macros(e) #define LA_KSTAT 12 /* special Solaris kstat(3k) implementation */ #define LA_DEVSHORT 13 /* read short from a device */ #define LA_ALPHAOSF 14 /* Digital UNIX (OSF/1 on Alpha) table() call */ +#define LA_PSET 15 /* Solaris per-processor-set load average */ /* do guesses based on general OS type */ #ifndef LA_TYPE @@ -2069,6 +2070,28 @@ int getla() #endif /* LA_TYPE == LA_ALPHAOSF */ +#if LA_TYPE == LA_PSET + +static int +getla() +{ + double avenrun[3]; + + if (pset_getloadavg(PS_MYID, avenrun, + sizeof(avenrun) / sizeof(avenrun[0])) < 0) + { + if (tTd(3, 1)) + dprintf("getla: pset_getloadavg failed: %s", + errstring(errno)); + return -1; + } + if (tTd(3, 1)) + dprintf("getla: %d\n", (int) (avenrun[0] +0.5)); + return ((int) (avenrun[0] + 0.5)); +} + +#endif /* LA_TYPE == LA_PSET */ + #if LA_TYPE == LA_ZERO static int @@ -2228,35 +2251,12 @@ refuseconnections(name, e, d) ENVELOPE *e; int d; { - time_t now; - static time_t lastconn[MAXDAEMONS]; - static int conncnt[MAXDAEMONS]; - - #ifdef XLA if (!xla_smtp_ok()) return TRUE; #endif /* XLA */ - now = curtime(); - if (now != lastconn[d]) - { - lastconn[d] = now; - conncnt[d] = 0; - } - else if (conncnt[d]++ > ConnRateThrottle && ConnRateThrottle > 0) - { - /* sleep to flatten out connection load */ - sm_setproctitle(TRUE, e, "deferring connections on daemon %s: %d per second", - name, ConnRateThrottle); - if (LogLevel >= 9) - sm_syslog(LOG_INFO, NOQID, - "deferring connections on daemon %s: %d per second", - name, ConnRateThrottle); - (void) sleep(1); - } - - CurrentLA = getla(); + CurrentLA = sm_getla(NULL); if (RefuseLA > 0 && CurrentLA >= RefuseLA) { sm_setproctitle(TRUE, e, "rejecting connections on daemon %s: load average: %d", @@ -2473,7 +2473,7 @@ setproctitle(fmt, va_alist) if (kmem < 0 || kmempid != getpid()) { if (kmem >= 0) - close(kmem); + (void) close(kmem); kmem = open(_PATH_KMEM, O_RDWR, 0); if (kmem < 0) return; @@ -3629,6 +3629,7 @@ transienterror(err) ** type -- type of the lock. Bits can be: ** LOCK_EX -- exclusive lock. ** LOCK_NB -- non-blocking. +** LOCK_UN -- unlock. ** ** Returns: ** TRUE if the lock was acquired. @@ -4137,7 +4138,7 @@ validate_connection(sap, hostname, e) hostname, anynet_ntoa(sap)); if (rscheck("check_relay", hostname, anynet_ntoa(sap), - e, TRUE, TRUE, 4) != EX_OK) + e, TRUE, TRUE, 4, NULL) != EX_OK) { static char reject[BUFSIZ*2]; extern char MsgBuf[]; @@ -4379,6 +4380,20 @@ getipnodebyaddr(addr, len, family, err) *err = h_errno; return h; } + +# if _FFR_FREEHOSTENT +void +freehostent(h) + struct hostent *h; +{ + /* + ** Stub routine -- if they don't have getipnodeby*(), + ** they probably don't have the free routine either. + */ + + return; +} +# endif /* _FFR_FREEHOSTENT */ #endif /* NEEDSGETIPNODE && NETINET6 && __RES < 19990909 */ struct hostent * @@ -4435,9 +4450,12 @@ sm_gethostbyname(name, family) nmaps = switch_map_find("hosts", maptype, mapreturn); while (--nmaps >= 0) + { if (strcmp(maptype[nmaps], "nis") == 0 || strcmp(maptype[nmaps], "files") == 0) break; + } + if (nmaps >= 0) { /* try short name */ @@ -4668,14 +4686,16 @@ add_hostnames(sa) #if NETINET case AF_INET: hp = sm_gethostbyaddr((char *) &sa->sin.sin_addr, - sizeof(sa->sin.sin_addr), sa->sa.sa_family); + sizeof(sa->sin.sin_addr), + sa->sa.sa_family); break; #endif /* NETINET */ #if NETINET6 case AF_INET6: hp = sm_gethostbyaddr((char *) &sa->sin6.sin6_addr, - sizeof(sa->sin6.sin6_addr), sa->sa.sa_family); + sizeof(sa->sin6.sin6_addr), + sa->sa.sa_family); break; #endif /* NETINET6 */ @@ -4748,6 +4768,9 @@ add_hostnames(sa) *ha); } } +#if _FFR_FREEHOSTENT && NETINET6 + freehostent(hp); +#endif /* _FFR_FREEHOSTENT && NETINET6 */ return 0; } /* @@ -4816,7 +4839,7 @@ load_if_names() if (numifs <= 0) { - close(s); + (void) close(s); return; } lifc.lifc_len = numifs * sizeof (struct lifreq); @@ -4827,7 +4850,8 @@ load_if_names() { if (tTd(0, 4)) dprintf("SIOCGLIFCONF failed: %s\n", errstring(errno)); - close(s); + (void) close(s); + free(lifc.lifc_buf); return; } @@ -4860,7 +4884,10 @@ load_if_names() s = socket(af, SOCK_DGRAM, 0); if (s == -1) + { + free(lifc.lifc_buf); return; + } /* ** If we don't have a complete ifr structure, @@ -4909,7 +4936,18 @@ load_if_names() { case AF_INET6: ia6 = sa->sin6.sin6_addr; - if (ia6.s6_addr == in6addr_any.s6_addr) +# ifdef __KAME__ + /* convert into proper scoped address - */ + if ((IN6_IS_ADDR_LINKLOCAL(&ia6) || + IN6_IS_ADDR_SITELOCAL(&ia6)) && + sa->sin6.sin6_scope_id == 0) + { + sa->sin6.sin6_scope_id = ntohs(ia6.s6_addr[3] | + ((unsigned int) ia6.s6_addr[2] << 8)); + ia6.s6_addr[2] = ia6.s6_addr[3] = 0; + } +# endif /* __KAME__ */ + if (IN6_IS_ADDR_UNSPECIFIED(&ia6)) { addr = anynet_ntop(&ia6, buf6, sizeof buf6); message("WARNING: interface %s is UP with %s address", @@ -4960,7 +4998,7 @@ load_if_names() (void) add_hostnames(sa); } free(lifc.lifc_buf); - close(s); + (void) close(s); #else /* NETINET6 && defined(SIOCGLIFCONF) */ # if defined(SIOCGIFCONF) && !SIOCGIFCONF_IS_BROKEN int s; @@ -5092,7 +5130,7 @@ load_if_names() # if NETINET6 case AF_INET6: ia6 = sa->sin6.sin6_addr; - if (ia6.s6_addr == in6addr_any.s6_addr) + if (IN6_IS_ADDR_UNSPECIFIED(&ia6)) { addr = anynet_ntop(&ia6, buf6, sizeof buf6); message("WARNING: interface %s is UP with %s address", |