diff options
Diffstat (limited to 'contrib/sendmail/src/conf.c')
-rw-r--r-- | contrib/sendmail/src/conf.c | 555 |
1 files changed, 257 insertions, 298 deletions
diff --git a/contrib/sendmail/src/conf.c b/contrib/sendmail/src/conf.c index 1cf447d..a681575 100644 --- a/contrib/sendmail/src/conf.c +++ b/contrib/sendmail/src/conf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2007 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -13,13 +13,17 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: conf.c,v 8.1082 2006/03/22 22:49:33 ca Exp $") +SM_RCSID("@(#)$Id: conf.c,v 8.1128 2007/04/03 21:32:29 ca Exp $") +#include <sm/sendmail.h> #include <sendmail/pathnames.h> #if NEWDB # include "sm/bdb.h" #endif /* NEWDB */ +#include <daemon.h> +#include "map.h" + #ifdef DEC # if NETINET6 /* for the IPv6 device lookup */ @@ -158,9 +162,7 @@ struct prival PrivacyValues[] = { "noreceipts", PRIV_NORECEIPTS }, { "nobodyreturn", PRIV_NOBODYRETN }, { "goaway", PRIV_GOAWAY }, -#if _FFR_PRIV_NOACTUALRECIPIENT { "noactualrecipient", PRIV_NOACTUALRECIPIENT }, -#endif /* _FFR_PRIV_NOACTUALRECIPIENT */ { NULL, 0 } }; @@ -378,7 +380,7 @@ setdefaults(e) InetMode = AF_INET; #endif /* NETINET6 */ ControlSocketName = NULL; - memset(&ConnectOnlyTo, '\0', sizeof ConnectOnlyTo); + memset(&ConnectOnlyTo, '\0', sizeof(ConnectOnlyTo)); DataFileBufferSize = 4096; XscriptFileBufferSize = 4096; for (i = 0; i < MAXRWSETS; i++) @@ -413,7 +415,7 @@ setdefuser() (void) sm_strlcpy(defuserbuf, (defpwent == NULL || defpwent->pw_name == NULL) ? "nobody" : defpwent->pw_name, - sizeof defuserbuf); + sizeof(defuserbuf)); if (tTd(37, 4)) sm_dprintf("setdefuser: DefUid=%d, DefUser=%s\n", (int) DefUid, DefUser); @@ -432,7 +434,7 @@ setupqueues() char buf[100]; MaxRunnersPerQueue = 1; - (void) sm_strlcpy(buf, "mqueue, P=/var/spool/mqueue", sizeof buf); + (void) sm_strlcpy(buf, "mqueue, P=/var/spool/mqueue", sizeof(buf)); makequeue(buf, false); } /* @@ -445,15 +447,15 @@ setupmailers() char buf[100]; (void) sm_strlcpy(buf, "prog, P=/bin/sh, F=lsouDq9, T=X-Unix/X-Unix/X-Unix, A=sh -c \201u", - sizeof buf); + sizeof(buf)); makemailer(buf); (void) sm_strlcpy(buf, "*file*, P=[FILE], F=lsDFMPEouq9, T=X-Unix/X-Unix/X-Unix, A=FILE \201u", - sizeof buf); + sizeof(buf)); makemailer(buf); (void) sm_strlcpy(buf, "*include*, P=/dev/null, F=su, A=INCLUDE \201u", - sizeof buf); + sizeof(buf)); makemailer(buf); initerrmailers(); } @@ -664,6 +666,13 @@ setupmaps() socket_map_lookup, null_map_store); #endif /* SOCKETMAP */ +#if _FFR_DPRINTF_MAP + /* dprintf map -- logs information to syslog */ + MAPDEF("dprintf", NULL, 0, + dprintf_map_parseargs, null_map_open, null_map_close, + dprintf_map_lookup, null_map_store); +#endif /* _FFR_DPRINTF_MAP */ + if (tTd(38, 2)) { /* bogus map -- always return tempfail */ @@ -704,69 +713,16 @@ inithostmaps() char buf[MAXLINE]; /* - ** Set up default hosts maps. - */ - -#if 0 - nmaps = switch_map_find("hosts", maptype, mapreturn); - for (i = 0; i < nmaps; i++) - { - if (strcmp(maptype[i], "files") == 0 && - stab("hosts.files", ST_MAP, ST_FIND) == NULL) - { - (void) sm_strlcpy(buf, "hosts.files text -k 0 -v 1 /etc/hosts", - sizeof buf); - (void) makemapentry(buf); - } -# if NAMED_BIND - else if (strcmp(maptype[i], "dns") == 0 && - stab("hosts.dns", ST_MAP, ST_FIND) == NULL) - { - (void) sm_strlcpy(buf, "hosts.dns dns A", sizeof buf); - (void) makemapentry(buf); - } -# endif /* NAMED_BIND */ -# if NISPLUS - else if (strcmp(maptype[i], "nisplus") == 0 && - stab("hosts.nisplus", ST_MAP, ST_FIND) == NULL) - { - (void) sm_strlcpy(buf, "hosts.nisplus nisplus -k name -v address hosts.org_dir", - sizeof buf); - (void) makemapentry(buf); - } -# endif /* NISPLUS */ -# if NIS - else if (strcmp(maptype[i], "nis") == 0 && - stab("hosts.nis", ST_MAP, ST_FIND) == NULL) - { - (void) sm_strlcpy(buf, "hosts.nis nis -k 0 -v 1 hosts.byname", - sizeof buf); - (void) makemapentry(buf); - } -# endif /* NIS */ -# if NETINFO - else if (strcmp(maptype[i], "netinfo") == 0 && - stab("hosts.netinfo", ST_MAP, ST_FIND) == NULL) - { - (void) sm_strlcpy(buf, "hosts.netinfo netinfo -v name /machines", - sizeof buf); - (void) makemapentry(buf); - } -# endif /* NETINFO */ - } -#endif /* 0 */ - - /* ** Make sure we have a host map. */ if (stab("host", ST_MAP, ST_FIND) == NULL) { /* user didn't initialize: set up host map */ - (void) sm_strlcpy(buf, "host host", sizeof buf); + (void) sm_strlcpy(buf, "host host", sizeof(buf)); #if NAMED_BIND if (ConfigLevel >= 2) - (void) sm_strlcat(buf, " -a. -D", sizeof buf); + (void) sm_strlcat(buf, " -a. -D", sizeof(buf)); #endif /* NAMED_BIND */ (void) makemapentry(buf); } @@ -782,7 +738,7 @@ inithostmaps() stab("aliases.files", ST_MAP, ST_FIND) == NULL) { (void) sm_strlcpy(buf, "aliases.files null", - sizeof buf); + sizeof(buf)); (void) makemapentry(buf); } #if NISPLUS @@ -790,7 +746,7 @@ inithostmaps() stab("aliases.nisplus", ST_MAP, ST_FIND) == NULL) { (void) sm_strlcpy(buf, "aliases.nisplus nisplus -kalias -vexpansion mail_aliases.org_dir", - sizeof buf); + sizeof(buf)); (void) makemapentry(buf); } #endif /* NISPLUS */ @@ -799,7 +755,7 @@ inithostmaps() stab("aliases.nis", ST_MAP, ST_FIND) == NULL) { (void) sm_strlcpy(buf, "aliases.nis nis mail.aliases", - sizeof buf); + sizeof(buf)); (void) makemapentry(buf); } #endif /* NIS */ @@ -808,7 +764,7 @@ inithostmaps() stab("aliases.netinfo", ST_MAP, ST_FIND) == NULL) { (void) sm_strlcpy(buf, "aliases.netinfo netinfo -z, /aliases", - sizeof buf); + sizeof(buf)); (void) makemapentry(buf); } #endif /* NETINFO */ @@ -817,66 +773,28 @@ inithostmaps() stab("aliases.hesiod", ST_MAP, ST_FIND) == NULL) { (void) sm_strlcpy(buf, "aliases.hesiod hesiod aliases", - sizeof buf); + sizeof(buf)); (void) makemapentry(buf); } #endif /* HESIOD */ - } - if (stab("aliases", ST_MAP, ST_FIND) == NULL) - { - (void) sm_strlcpy(buf, "aliases switch aliases", sizeof buf); - (void) makemapentry(buf); - } - -#if 0 /* "user" map class is a better choice */ - /* - ** Set up default users maps. - */ - - nmaps = switch_map_find("passwd", maptype, mapreturn); - for (i = 0; i < nmaps; i++) - { - if (strcmp(maptype[i], "files") == 0 && - stab("users.files", ST_MAP, ST_FIND) == NULL) +#if LDAPMAP && defined(SUN_EXTENSIONS) && \ + defined(SUN_SIMPLIFIED_LDAP) && HASLDAPGETALIASBYNAME + else if (strcmp(maptype[i], "ldap") == 0 && + stab("aliases.ldap", ST_MAP, ST_FIND) == NULL) { - (void) sm_strlcpy(buf, "users.files text -m -z: -k0 -v6 /etc/passwd", + (void) strlcpy(buf, "aliases.ldap ldap -b . -h localhost -k mail=%0 -v mailgroup", sizeof buf); (void) makemapentry(buf); } -# if NISPLUS - else if (strcmp(maptype[i], "nisplus") == 0 && - stab("users.nisplus", ST_MAP, ST_FIND) == NULL) - { - (void) sm_strlcpy(buf, "users.nisplus nisplus -m -kname -vhome passwd.org_dir", - sizeof buf); - (void) makemapentry(buf); - } -# endif /* NISPLUS */ -# if NIS - else if (strcmp(maptype[i], "nis") == 0 && - stab("users.nis", ST_MAP, ST_FIND) == NULL) - { - (void) sm_strlcpy(buf, "users.nis nis -m passwd.byname", - sizeof buf); - (void) makemapentry(buf); - } -# endif /* NIS */ -# if HESIOD - else if (strcmp(maptype[i], "hesiod") == 0 && - stab("users.hesiod", ST_MAP, ST_FIND) == NULL) - { - (void) sm_strlcpy(buf, "users.hesiod hesiod", sizeof buf); - (void) makemapentry(buf); - } -# endif /* HESIOD */ +#endif /* LDAPMAP && defined(SUN_EXTENSIONS) && ... */ } - if (stab("users", ST_MAP, ST_FIND) == NULL) + if (stab("aliases", ST_MAP, ST_FIND) == NULL) { - (void) sm_strlcpy(buf, "users switch -m passwd", sizeof buf); + (void) sm_strlcpy(buf, "aliases switch aliases", sizeof(buf)); (void) makemapentry(buf); } -#endif /* 0 */ } + /* ** SWITCH_MAP_FIND -- find the list of types associated with a map ** @@ -1043,7 +961,7 @@ switch_map_find(service, maptype, mapreturn) char buf[MAXLINE]; while (sm_io_fgets(fp, SM_TIME_DEFAULT, buf, - sizeof buf) != NULL) + sizeof(buf)) != NULL) { register char *p; @@ -1326,6 +1244,25 @@ checkcompat(to, e) #endif /* EXAMPLE_CODE */ return EX_OK; } + +#ifdef SUN_EXTENSIONS +static void +init_md_sun() +{ + struct stat sbuf; + + /* Check for large file descriptor */ + if (fstat(fileno(stdin), &sbuf) < 0) + { + if (errno == EOVERFLOW) + { + perror("stdin"); + exit(EX_NOINPUT); + } + } +} +#endif /* SUN_EXTENSIONS */ + /* ** INIT_MD -- do machine dependent initializations ** @@ -1358,7 +1295,7 @@ init_md(argc, argv) /* keep gethostby*() from stripping the local domain name */ set_domain_trim_off(); #endif /* _CONVEX_SOURCE */ -#ifdef __QNX__ +#if defined(__QNX__) && !defined(__QNXNTO__) /* ** Due to QNX's network distributed nature, you can target a tcpip ** stack on a different node in the qnx network; this patch lets @@ -1527,12 +1464,12 @@ getla() { # ifdef _AUX_SOURCE (void) sm_strlcpy(Nl[X_AVENRUN].n_name, LA_AVENRUN, - sizeof Nl[X_AVENRUN].n_name); + sizeof(Nl[X_AVENRUN].n_name)); Nl[1].n_name[0] = '\0'; # endif /* _AUX_SOURCE */ # if defined(_AIX3) || defined(_AIX4) - if (knlist(Nl, 1, sizeof Nl[0]) < 0) + if (knlist(Nl, 1, sizeof(Nl[0])) < 0) # else /* defined(_AIX3) || defined(_AIX4) */ if (nlist(_PATH_UNIX, Nl) < 0) # endif /* defined(_AIX3) || defined(_AIX4) */ @@ -2005,7 +1942,7 @@ getla() } } - r = read(afd, &avenrun, sizeof avenrun); + r = read(afd, &avenrun, sizeof(avenrun)); if (tTd(3, 5)) sm_dprintf("getla: avenrun = %d\n", avenrun); @@ -2152,7 +2089,7 @@ sm_getla() char labuf[8]; CurrentLA = getla(); - (void) sm_snprintf(labuf, sizeof labuf, "%d", CurrentLA); + (void) sm_snprintf(labuf, sizeof(labuf), "%d", CurrentLA); macdefine(&GlobalMacros, A_TEMP, macid("{load_avg}"), labuf); } /* @@ -2208,26 +2145,18 @@ shouldqueue(pri, ct) sm_dprintf("false (CurrentLA < QueueLA)\n"); return false; } -# if 0 /* this code is reported to cause oscillation around RefuseLA */ - if (CurrentLA >= RefuseLA && QueueLA < RefuseLA) - { - if (tTd(3, 30)) - sm_dprintf("TRUE (CurrentLA >= RefuseLA)\n"); - return true; - } -# endif /* 0 */ rval = pri > (QueueFactor / (CurrentLA - QueueLA + 1)); if (tTd(3, 30)) sm_dprintf("%s (by calculation)\n", rval ? "true" : "false"); return rval; } + /* ** REFUSECONNECTIONS -- decide if connections should be refused ** ** Parameters: -** name -- daemon name (for error messages only) ** e -- the current envelope. -** d -- number of daemon +** dn -- number of daemon. ** active -- was this daemon actually active? ** ** Returns: @@ -2240,16 +2169,16 @@ shouldqueue(pri, ct) */ bool -refuseconnections(name, e, d, active) - char *name; +refuseconnections(e, dn, active) ENVELOPE *e; - int d; + int dn; bool active; { static time_t lastconn[MAXDAEMONS]; static int conncnt[MAXDAEMONS]; static time_t firstrejtime[MAXDAEMONS]; static time_t nextlogtime[MAXDAEMONS]; + int limit; #if _FFR_MEMSTAT long memfree; #endif /* _FFR_MEMSTAT */ @@ -2259,8 +2188,8 @@ refuseconnections(name, e, d, active) return true; #endif /* XLA */ - SM_ASSERT(d >= 0); - SM_ASSERT(d < MAXDAEMONS); + SM_ASSERT(dn >= 0); + SM_ASSERT(dn < MAXDAEMONS); if (ConnRateThrottle > 0) { time_t now; @@ -2268,25 +2197,27 @@ refuseconnections(name, e, d, active) now = curtime(); if (active) { - if (now != lastconn[d]) + if (now != lastconn[dn]) { - lastconn[d] = now; - conncnt[d] = 1; + lastconn[dn] = now; + conncnt[dn] = 1; } - else if (conncnt[d]++ > ConnRateThrottle) + else if (conncnt[dn]++ > ConnRateThrottle) { #define D_MSG_CRT "deferring connections on daemon %s: %d per second" /* sleep to flatten out connection load */ sm_setproctitle(true, e, D_MSG_CRT, - name, ConnRateThrottle); + Daemons[dn].d_name, + ConnRateThrottle); if (LogLevel > 8) sm_syslog(LOG_INFO, NOQID, D_MSG_CRT, - name, ConnRateThrottle); + Daemons[dn].d_name, + ConnRateThrottle); (void) sleep(1); } } - else if (now != lastconn[d]) - conncnt[d] = 0; + else if (now != lastconn[dn]) + conncnt[dn] = 0; } @@ -2296,40 +2227,47 @@ refuseconnections(name, e, d, active) memfree < RefuseLowMem) { # define R_MSG_LM "rejecting connections on daemon %s: free memory: %ld" - sm_setproctitle(true, e, R_MSG_LM, name, memfree); + sm_setproctitle(true, e, R_MSG_LM, Daemons[dn].d_name, memfree); if (LogLevel > 8) - sm_syslog(LOG_NOTICE, NOQID, R_MSG_LM, name, memfree); + sm_syslog(LOG_NOTICE, NOQID, R_MSG_LM, + Daemons[dn].d_name, memfree); return true; } #endif /* _FFR_MEMSTAT */ sm_getla(); - if (RefuseLA > 0 && CurrentLA >= RefuseLA) + limit = (Daemons[dn].d_refuseLA != DPO_NOTSET) ? + Daemons[dn].d_refuseLA : RefuseLA; + if (limit > 0 && CurrentLA >= limit) { time_t now; # define R_MSG_LA "rejecting connections on daemon %s: load average: %d" # define R2_MSG_LA "have been rejecting connections on daemon %s for %s" - sm_setproctitle(true, e, R_MSG_LA, name, CurrentLA); + sm_setproctitle(true, e, R_MSG_LA, Daemons[dn].d_name, + CurrentLA); if (LogLevel > 8) - sm_syslog(LOG_NOTICE, NOQID, R_MSG_LA, name, CurrentLA); + sm_syslog(LOG_NOTICE, NOQID, R_MSG_LA, + Daemons[dn].d_name, CurrentLA); now = curtime(); - if (firstrejtime[d] == 0) + if (firstrejtime[dn] == 0) { - firstrejtime[d] = now; - nextlogtime[d] = now + RejectLogInterval; + firstrejtime[dn] = now; + nextlogtime[dn] = now + RejectLogInterval; } - else if (nextlogtime[d] < now) + else if (nextlogtime[dn] < now) { - sm_syslog(LOG_ERR, NOQID, R2_MSG_LA, name, - pintvl(now - firstrejtime[d], true)); - nextlogtime[d] = now + RejectLogInterval; + sm_syslog(LOG_ERR, NOQID, R2_MSG_LA, Daemons[dn].d_name, + pintvl(now - firstrejtime[dn], true)); + nextlogtime[dn] = now + RejectLogInterval; } return true; } else - firstrejtime[d] = 0; + firstrejtime[dn] = 0; - if (DelayLA > 0 && CurrentLA >= DelayLA) + limit = (Daemons[dn].d_delayLA != DPO_NOTSET) ? + Daemons[dn].d_delayLA : DelayLA; + if (limit > 0 && CurrentLA >= limit) { time_t now; static time_t log_delay = (time_t) 0; @@ -2337,32 +2275,37 @@ refuseconnections(name, e, d, active) # define MIN_DELAY_LOG 90 /* wait before logging this again */ # define D_MSG_LA "delaying connections on daemon %s: load average=%d >= %d" /* sleep to flatten out connection load */ - sm_setproctitle(true, e, D_MSG_LA, name, DelayLA); + sm_setproctitle(true, e, D_MSG_LA, Daemons[dn].d_name, limit); if (LogLevel > 8 && (now = curtime()) > log_delay) { sm_syslog(LOG_INFO, NOQID, D_MSG_LA, - name, CurrentLA, DelayLA); + Daemons[dn].d_name, CurrentLA, limit); log_delay = now + MIN_DELAY_LOG; } (void) sleep(1); } - if (MaxChildren > 0 && CurChildren >= MaxChildren) + limit = (Daemons[dn].d_maxchildren != DPO_NOTSET) ? + Daemons[dn].d_maxchildren : MaxChildren; + if (limit > 0 && CurChildren >= limit) { proc_list_probe(); - if (CurChildren >= MaxChildren) + if (CurChildren >= limit) { #define R_MSG_CHILD "rejecting connections on daemon %s: %d children, max %d" sm_setproctitle(true, e, R_MSG_CHILD, - name, CurChildren, MaxChildren); + Daemons[dn].d_name, CurChildren, + limit); if (LogLevel > 8) sm_syslog(LOG_INFO, NOQID, R_MSG_CHILD, - name, CurChildren, MaxChildren); + Daemons[dn].d_name, CurChildren, + limit); return true; } } return false; } + /* ** SETPROCTITLE -- set process title for ps ** @@ -2491,7 +2434,7 @@ initsetproctitle(argc, argv, envp) { for (i = 0; envp[i] != NULL; i++) continue; - environ = (char **) xalloc(sizeof (char *) * (i + 1)); + environ = (char **) xalloc(sizeof(char *) * (i + 1)); for (i = 0; envp[i] != NULL; i++) environ[i] = newstr(envp[i]); environ[i] = NULL; @@ -2660,7 +2603,7 @@ sm_setproctitle(status, e, fmt, va_alist) /* print the argument string */ SM_VA_START(ap, fmt); - (void) sm_vsnprintf(buf, sizeof buf, fmt, ap); + (void) sm_vsnprintf(buf, sizeof(buf), fmt, ap); SM_VA_END(ap); if (status) @@ -2670,7 +2613,7 @@ sm_setproctitle(status, e, fmt, va_alist) { char prefix[SPT_BUFSIZE]; - expand(ProcTitlePrefix, prefix, sizeof prefix, e); + expand(ProcTitlePrefix, prefix, sizeof(prefix), e); setproctitle("%s: %s", prefix, buf); } else @@ -2888,7 +2831,7 @@ uname(name) char buf[MAXLINE]; while (sm_io_fgets(file, SM_TIME_DEFAULT, - buf, sizeof buf) != NULL) + buf, sizeof(buf)) != NULL) { if (sm_io_sscanf(buf, "#define sysname \"%*[^\"]\"", NODE_LENGTH, name->nodename) > 0) @@ -3262,7 +3205,7 @@ usershellok(user, shell) return false; } - while (sm_io_fgets(shellf, SM_TIME_DEFAULT, buf, sizeof buf) != NULL) + while (sm_io_fgets(shellf, SM_TIME_DEFAULT, buf, sizeof(buf)) != NULL) { register char *p, *q; @@ -3334,7 +3277,7 @@ usershellok(user, shell) long freediskspace(dir, bsize) - char *dir; + const char *dir; long *bsize; { # if SFS_TYPE == SFS_NONE @@ -3372,7 +3315,7 @@ freediskspace(dir, bsize) if (stat(dir, &statbuf) == 0 && ustat(statbuf.st_dev, &fs) == 0) # else /* SFS_TYPE == SFS_USTAT */ # if SFS_TYPE == SFS_4ARGS - if (statfs(dir, &fs, sizeof fs, 0) == 0) + if (statfs(dir, &fs, sizeof(fs), 0) == 0) # else /* SFS_TYPE == SFS_4ARGS */ # if SFS_TYPE == SFS_STATVFS if (statvfs(dir, &fs) == 0) @@ -3577,7 +3520,7 @@ lockfile(fd, filename, ext, type) if (ext == NULL) ext = ""; - memset(&lfd, '\0', sizeof lfd); + memset(&lfd, '\0', sizeof(lfd)); if (bitset(LOCK_UN, type)) lfd.l_type = F_UNLCK; else if (bitset(LOCK_EX, type)) @@ -3942,11 +3885,8 @@ vendor_post_defaults(e) ENVELOPE *e; { #ifdef __QNX__ - char *p; - /* Makes sure the SOCK environment variable remains */ - if (p = getextenv("SOCK")) - sm_setuserenv("SOCK", p); + sm_setuserenv("SOCK", NULL); #endif /* __QNX__ */ #if defined(SUN_EXTENSIONS) && defined(SUN_DEFAULT_VALUES) sun_post_defaults(e); @@ -4042,7 +3982,7 @@ validate_connection(sap, hostname, e) connection_rate_check(sap, e); if (rscheck("check_relay", hostname, anynet_ntoa(sap), - e, RSF_RMCOMM|RSF_COUNT, 3, NULL, NOQID) != EX_OK) + e, RSF_RMCOMM|RSF_COUNT, 3, NULL, NOQID, NULL) != EX_OK) { static char reject[BUFSIZ*2]; extern char MsgBuf[]; @@ -4051,9 +3991,9 @@ validate_connection(sap, hostname, e) sm_dprintf(" ... validate_connection: BAD (rscheck)\n"); if (strlen(MsgBuf) >= 3) - (void) sm_strlcpy(reject, MsgBuf, sizeof reject); + (void) sm_strlcpy(reject, MsgBuf, sizeof(reject)); else - (void) sm_strlcpy(reject, "Access denied", sizeof reject); + (void) sm_strlcpy(reject, "Access denied", sizeof(reject)); return reject; } @@ -4370,12 +4310,12 @@ sm_gethostbyname(name, family) if (nmaps >= 0) { /* try short name */ - if (strlen(name) > sizeof hbuf - 1) + if (strlen(name) > sizeof(hbuf) - 1) { errno = save_errno; return NULL; } - (void) sm_strlcpy(hbuf, name, sizeof hbuf); + (void) sm_strlcpy(hbuf, name, sizeof(hbuf)); (void) shorten_hostname(hbuf); /* if it hasn't been shortened, there's no point */ @@ -4427,7 +4367,7 @@ sm_gethostbyname(name, family) memmove(&ia6, h->h_addr_list[i], IN6ADDRSZ); addr = anynet_ntop(&ia6, - buf6, sizeof buf6); + buf6, sizeof(buf6)); #else /* NETINET6 */ memmove(&ia, h->h_addr_list[i], INADDRSZ); @@ -4666,7 +4606,8 @@ add_hostnames(sa) if (tTd(0, 4)) sm_dprintf("\ta.k.a.: %s\n", hp->h_name); - if (sm_snprintf(hnb, sizeof hnb, "[%s]", hp->h_name) < sizeof hnb + if (sm_snprintf(hnb, sizeof(hnb), "[%s]", hp->h_name) < + sizeof(hnb) && !wordinclass((char *) hnb, 'w')) setclass('w', hnb); } @@ -4684,8 +4625,8 @@ add_hostnames(sa) setclass('w', *ha); if (tTd(0, 4)) sm_dprintf("\ta.k.a.: %s\n", *ha); - if (sm_snprintf(hnb, sizeof hnb, - "[%s]", *ha) < sizeof hnb && + if (sm_snprintf(hnb, sizeof(hnb), + "[%s]", *ha) < sizeof(hnb) && !wordinclass((char *) hnb, 'w')) setclass('w', hnb); } @@ -4798,7 +4739,7 @@ load_if_names() return; } - len = lifc.lifc_len = numifs * sizeof (struct lifreq); + len = lifc.lifc_len = numifs * sizeof(struct lifreq); buf = lifc.lifc_buf = xalloc(lifc.lifc_len); # ifndef __hpux lifc.lifc_family = AF_UNSPEC; @@ -4855,20 +4796,20 @@ load_if_names() ** don't try to use it. */ - if ((len - i) < sizeof *ifr) + if ((len - i) < sizeof(*ifr)) break; # ifdef BSD4_4_SOCKADDR - if (sa->sa.sa_len > sizeof ifr->lifr_addr) - i += sizeof ifr->lifr_name + sa->sa.sa_len; + if (sa->sa.sa_len > sizeof(ifr->lifr_addr)) + i += sizeof(ifr->lifr_name) + sa->sa.sa_len; else # endif /* BSD4_4_SOCKADDR */ # ifdef DEC /* fix for IPv6 size differences */ - i += sizeof ifr->ifr_name + + i += sizeof(ifr->ifr_name) + max(sizeof(ifr->ifr_addr), ifr->ifr_addr.sa_len); # else /* DEC */ - i += sizeof *ifr; + i += sizeof(*ifr); # endif /* DEC */ if (tTd(0, 20)) @@ -4922,18 +4863,18 @@ load_if_names() ia6 = sa->sin6.sin6_addr; if (IN6_IS_ADDR_UNSPECIFIED(&ia6)) { - addr = anynet_ntop(&ia6, buf6, sizeof buf6); + addr = anynet_ntop(&ia6, buf6, sizeof(buf6)); message("WARNING: interface %s is UP with %s address", name, addr == NULL ? "(NULL)" : addr); continue; } /* save IP address in text from */ - addr = anynet_ntop(&ia6, buf6, sizeof buf6); + addr = anynet_ntop(&ia6, buf6, sizeof(buf6)); if (addr != NULL) - (void) sm_snprintf(ip_addr, sizeof ip_addr, + (void) sm_snprintf(ip_addr, sizeof(ip_addr), "[%.*s]", - (int) sizeof ip_addr - 3, + (int) sizeof(ip_addr) - 3, addr); break; @@ -4948,8 +4889,8 @@ load_if_names() } /* save IP address in text from */ - (void) sm_snprintf(ip_addr, sizeof ip_addr, "[%.*s]", - (int) sizeof ip_addr - 3, inet_ntoa(ia)); + (void) sm_snprintf(ip_addr, sizeof(ip_addr), "[%.*s]", + (int) sizeof(ip_addr) - 3, inet_ntoa(ia)); break; } @@ -5005,7 +4946,7 @@ load_if_names() (void) close(s); return; } - ifc.ifc_len = numifs * sizeof (struct ifreq); + ifc.ifc_len = numifs * sizeof(struct ifreq); ifc.ifc_buf = xalloc(ifc.ifc_len); if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { @@ -5044,15 +4985,15 @@ load_if_names() ** don't try to use it. */ - if ((ifc.ifc_len - i) < sizeof *ifr) + if ((ifc.ifc_len - i) < sizeof(*ifr)) break; # ifdef BSD4_4_SOCKADDR - if (sa->sa.sa_len > sizeof ifr->ifr_addr) - i += sizeof ifr->ifr_name + sa->sa.sa_len; + if (sa->sa.sa_len > sizeof(ifr->ifr_addr)) + i += sizeof(ifr->ifr_name) + sa->sa.sa_len; else # endif /* BSD4_4_SOCKADDR */ - i += sizeof *ifr; + i += sizeof(*ifr); if (tTd(0, 20)) sm_dprintf("%s\n", anynet_ntoa(sa)); @@ -5097,8 +5038,8 @@ load_if_names() } /* save IP address in text from */ - (void) sm_snprintf(ip_addr, sizeof ip_addr, "[%.*s]", - (int) sizeof ip_addr - 3, + (void) sm_snprintf(ip_addr, sizeof(ip_addr), "[%.*s]", + (int) sizeof(ip_addr) - 3, inet_ntoa(ia)); break; @@ -5121,7 +5062,7 @@ load_if_names() ia6 = sa->sin6.sin6_addr; if (IN6_IS_ADDR_UNSPECIFIED(&ia6)) { - addr = anynet_ntop(&ia6, buf6, sizeof buf6); + addr = anynet_ntop(&ia6, buf6, sizeof(buf6)); message("WARNING: interface %s is UP with %s address", ifr->ifr_name, addr == NULL ? "(NULL)" : addr); @@ -5129,11 +5070,11 @@ load_if_names() } /* save IP address in text from */ - addr = anynet_ntop(&ia6, buf6, sizeof buf6); + addr = anynet_ntop(&ia6, buf6, sizeof(buf6)); if (addr != NULL) - (void) sm_snprintf(ip_addr, sizeof ip_addr, + (void) sm_snprintf(ip_addr, sizeof(ip_addr), "[%.*s]", - (int) sizeof ip_addr - 3, + (int) sizeof(ip_addr) - 3, addr); break; @@ -5212,7 +5153,7 @@ get_num_procs_online() mib[0] = CTL_HW; mib[1] = HW_NCPU; - sz = (size_t) sizeof nproc; + sz = (size_t) sizeof(nproc); (void) sysctl(mib, 2, &nproc, &sz, NULL, 0); # endif /* defined(CTL_HW) && defined(HW_NCPU) */ #else /* USESYSCTL */ @@ -5388,7 +5329,7 @@ sm_syslog(level, id, fmt, va_alist) idlen = strlen(id) + SyslogPrefixLen; buf = buf0; - bufsize = sizeof buf0; + bufsize = sizeof(buf0); for (;;) { @@ -5418,9 +5359,19 @@ sm_syslog(level, id, fmt, va_alist) { #if LOG if (*id == '\0') - syslog(level, "%s", newstring); + { + if (tTd(89, 8)) + sm_dprintf("%s\n", newstring); + else + syslog(level, "%s", newstring); + } else - syslog(level, "%s: %s", id, newstring); + { + if (tTd(89, 8)) + sm_dprintf("%s: %s\n", id, newstring); + else + syslog(level, "%s: %s", id, newstring); + } #else /* LOG */ /*XXX should do something more sensible */ if (*id == '\0') @@ -5472,7 +5423,10 @@ sm_syslog(level, id, fmt, va_alist) save = *end; *end = 0; #if LOG - syslog(level, "%s[%d]: %s ...", id, seq++, begin); + if (tTd(89, 8)) + sm_dprintf("%s[%d]: %s ...\n", id, seq++, begin); + else + syslog(level, "%s[%d]: %s ...", id, seq++, begin); #else /* LOG */ (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "%s[%d]: %s ...\n", id, seq++, begin); @@ -5481,20 +5435,31 @@ sm_syslog(level, id, fmt, va_alist) begin = end; } if (seq >= 999) + { #if LOG - syslog(level, "%s[%d]: log terminated, too many parts", - id, seq); + if (tTd(89, 8)) + sm_dprintf("%s[%d]: log terminated, too many parts\n", + id, seq); + else + syslog(level, "%s[%d]: log terminated, too many parts", + id, seq); #else /* LOG */ (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "%s[%d]: log terminated, too many parts\n", id, seq); #endif /* LOG */ + } else if (*begin != '\0') + { #if LOG - syslog(level, "%s[%d]: %s", id, seq, begin); + if (tTd(89, 8)) + sm_dprintf("%s[%d]: %s\n", id, seq, begin); + else + syslog(level, "%s[%d]: %s", id, seq, begin); #else /* LOG */ (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "%s[%d]: %s\n", id, seq, begin); #endif /* LOG */ + } if (buf != buf0) sm_free(buf); errno = save_errno; @@ -5533,7 +5498,7 @@ hard_syslog(pri, msg, va_alist) SM_VA_LOCAL_DECL SM_VA_START(ap, msg); - (void) sm_vsnprintf(buf, sizeof buf, msg, ap); + (void) sm_vsnprintf(buf, sizeof(buf), msg, ap); SM_VA_END(ap); for (i = MAXSYSLOGTRIES; --i >= 0 && syslog(pri, CAST "%s", buf) < 0; ) @@ -5791,6 +5756,9 @@ char *CompileOptions[] = #if SCANF "SCANF", #endif /* SCANF */ +#if SM_LDAP_ERROR_ON_MISSING_ARGS + "SM_LDAP_ERROR_ON_MISSING_ARGS", +#endif /* SM_LDAP_ERROR_ON_MISSING_ARGS */ #if SMTPDEBUG "SMTPDEBUG", #endif /* SMTPDEBUG */ @@ -5885,6 +5853,9 @@ char *OsCompileOptions[] = #if HASINITGROUPS "HASINITGROUPS", #endif /* HASINITGROUPS */ +#if HASLDAPGETALIASBYNAME + "HASLDAPGETALIASBYNAME", +#endif /* HASLDAPGETALIASBYNAME */ #if HASLSTAT "HASLSTAT", #endif /* HASLSTAT */ @@ -5957,6 +5928,9 @@ char *OsCompileOptions[] = #if O_EXLOCK && HASFLOCK && !BOGUS_O_EXCL "LOCK_ON_OPEN", #endif /* O_EXLOCK && HASFLOCK && !BOGUS_O_EXCL */ +#if MILTER_NO_NAGLE + "MILTER_NO_NAGLE ", +#endif /* MILTER_NO_NAGLE */ #if NEEDFSYNC "NEEDFSYNC", #endif /* NEEDFSYNC */ @@ -6059,22 +6033,10 @@ char *FFRCompileOptions[] = /* Better truncation of list of MX records for dns map. */ "_FFR_BESTMX_BETTER_TRUNCATION", #endif /* _FFR_BESTMX_BETTER_TRUNCATION */ -#if _FFR_BLOCK_PROXIES - /* - ** Try to deal with open HTTP proxies that are used to send spam - ** by recognizing some commands from them. - */ - - "_FFR_BLOCK_PROXIES", -#endif /* _FFR_BLOCK_PROXIES */ #if _FFR_CATCH_BROKEN_MTAS /* Deal with MTAs that send a reply during the DATA phase. */ "_FFR_CATCH_BROKEN_MTAS", #endif /* _FFR_CATCH_BROKEN_MTAS */ -#if _FFR_CHECK_EOM - /* Enable check_eom ruleset */ - "_FFR_CHECK_EOM", -#endif /* _FFR_CHECK_EOM */ #if _FFR_CHK_QUEUE /* Stricter checks about queue directory permissions. */ "_FFR_CHK_QUEUE", @@ -6083,10 +6045,6 @@ char *FFRCompileOptions[] = /* Don't try to send mail if its size exceeds SIZE= of server. */ "_FFR_CLIENT_SIZE", #endif /* _FFR_CLIENT_SIZE */ -#if _FFR_CONTROL_MSTAT - /* Extended daemon status. */ - "_FFR_CONTROL_MSTAT", -#endif /* _FFR_CONTROL_MSTAT */ #if _FFR_CRLPATH /* CRLPath; needs documentation; Al Smith */ "_FFR_CRLPATH", @@ -6108,27 +6066,11 @@ char *FFRCompileOptions[] = /* Problem noted by Anne Bennett of Concordia University */ "_FFR_DIGUNIX_SAFECHOWN", #endif /* _FFR_DIGUNIX_SAFECHOWN */ -#if _FFR_DM_PER_DAEMON - /* DeliveryMode per DaemonPortOptions: 'D' */ - "_FFR_DM_PER_DAEMON", -#endif /* _FFR_DM_PER_DAEMON */ #if _FFR_DNSMAP_ALIASABLE /* Allow dns map type to be used for aliases. */ /* Don Lewis of TDK */ "_FFR_DNSMAP_ALIASABLE", #endif /* _FFR_DNSMAP_ALIASABLE */ -#if _FFR_DNSMAP_BASE - /* Specify a "base" domain for DNS lookups. */ - "_FFR_DNSMAP_BASE", -#endif /* _FFR_DNSMAP_BASE */ -#if _FFR_DNSMAP_MULTI - /* Allow multiple return values for DNS map. */ - "_FFR_DNSMAP_MULTI", -# if _FFR_DNSMAP_MULTILIMIT - /* Limit number of return values for DNS map. */ - "_FFR_DNSMAP_MULTILIMIT", -# endif /* _FFR_DNSMAP_MULTILIMIT */ -#endif /* _FFR_DNSMAP_MULTI */ #if _FFR_DONTLOCKFILESFORREAD_OPTION /* Enable DontLockFilesForRead option. */ "_FFR_DONTLOCKFILESFORREAD_OPTION", @@ -6137,6 +6079,21 @@ char *FFRCompileOptions[] = /* Allow usernames with '.' */ "_FFR_DOTTED_USERNAMES", #endif /* _FFR_DOTTED_USERNAMES */ +#if _FFR_DPO_CS + /* + ** Make DaemonPortOptions case sensitive. + ** For some unknown reasons the code converted every option + ** to uppercase (first letter only, as that's the only one that + ** is actually checked). This prevented all new lower case options + ** from working... + ** The documentation doesn't say anything about case (in)sensitivity, + ** which means it should be case sensitive by default, + ** but it's not a good idea to change this within a patch release, + ** so let's delay this to 8.15. + */ + + "_FFR_DPO_CS", +#endif /* _FFR_DPO_CS */ #if _FFR_DROP_TRUSTUSER_WARNING /* ** Don't issue this warning: @@ -6146,10 +6103,27 @@ char *FFRCompileOptions[] = "_FFR_DROP_TRUSTUSER_WARNING", #endif /* _FFR_DROP_TRUSTUSER_WARNING */ +#if _FFR_EIGHT_BIT_ADDR_OK + /* EightBitAddrOK: allow 8-bit e-mail addresses */ + "_FFR_EIGHT_BIT_ADDR_OK", +#endif /* _FFR_EIGHT_BIT_ADDR_OK */ #if _FFR_EXTRA_MAP_CHECK /* perform extra checks on $( $) in R lines */ "_FFR_EXTRA_MAP_CHECK", #endif /* _FFR_EXTRA_MAP_CHECK */ +#if _FFR_GETHBN_ExFILE + /* + ** According to Motonori Nakamura some gethostbyname() + ** implementations (TurboLinux?) may (temporarily) fail + ** due to a lack of file discriptors. Enabling this FFR + ** will check errno for EMFILE and ENFILE and in case of a match + ** cause a temporary error instead of a permanent error. + ** The right solution is of course to file a bug against those + ** systems such that they actually set h_errno = TRY_AGAIN. + */ + + "_FFR_GETHBN_ExFILE", +#endif /* _FFR_GETHBN_ExFILE */ #if _FFR_FIX_DASHT /* ** If using -t, force not sending to argv recipients, even @@ -6166,10 +6140,6 @@ char *FFRCompileOptions[] = /* Generate a ORCPT DSN arg if not already provided */ "_FFR_GEN_ORCPT", #endif /* _FFR_GEN_ORCPT */ -#if _FFR_LOG_GREET_PAUSE - /* log time for greet_pause delay; from Nik Clayton */ - "_FFR_LOG_GREET_PAUSE", -#endif /* _FFR_LOG_GREET_PAUSE */ #if _FFR_GROUPREADABLEAUTHINFOFILE /* Allow group readable DefaultAuthInfo file. */ "_FFR_GROUPREADABLEAUTHINFOFILE", @@ -6183,14 +6153,6 @@ char *FFRCompileOptions[] = /* Peter Eriksson of Linkopings universitet */ "_FFR_HANDLE_ISO8859_GECOS", #endif /* _FFR_HANDLE_ISO8859_GECOS */ -#if _FFR_HDR_TYPE - /* Set 'h' in {addr_type} for headers. */ - "_FFR_HDR_TYPE", -#endif /* _FFR_HDR_TYPE */ -#if _FFR_HELONAME - /* option to set heloname; Nik Clayton of FreeBSD */ - "_FFR_HELONAME", -#endif /* _FFR_HELONAME */ #if _FFR_HPUX_NSSWITCH /* Use nsswitch on HP-UX */ "_FFR_HPUX_NSSWITCH", @@ -6219,14 +6181,6 @@ char *FFRCompileOptions[] = /* Randall S. Winchester of the University of Maryland */ "_FFR_MAX_FORWARD_ENTRIES", #endif /* _FFR_MAX_FORWARD_ENTRIES */ -#if _FFR_MAXKEY - /* increase key size for LDAP lookups, see conf.h */ - "_FFR_MAXKEY", -#endif /* _FFR_MAXKEY */ -#if _FFR_MAXNOOPCOMMANDS - /* runtime option for "MaxNOOPCommands" */ - "_FFR_MAXNOOPCOMMANDS", -#endif /* _FFR_MAXNOOPCOMMANDS */ #if _FFR_MAX_SLEEP_TIME /* Limit sleep(2) time in libsm/clock.c */ "_FFR_MAX_SLEEP_TIME", @@ -6235,16 +6189,35 @@ char *FFRCompileOptions[] = /* Check free memory */ "_FFR_MEMSTAT", #endif /* _FFR_MEMSTAT */ -#if _FFR_MILTER_NAGLE - /* milter: turn off Nagle ("cork" on Linux) */ - /* John Gardiner Myers of Proofpoint */ - "_FFR_MILTER_NAGLE ", -#endif /* _FFR_MILTER_NAGLE */ -#if _FFR_MILTER_NOHDR_RESP - /* milter: no response expected when sending headers */ - /* John Gardiner Myers of Proofpoint */ - "_FFR_MILTER_NOHDR_RESP", -#endif /* _FFR_MILTER_NOHDR_RESP */ +#if _FFR_MILTER_CHECK + "_FFR_MILTER_CHECK", +#endif /* _FFR_MILTER_CHECK */ +#if _FFR_MILTER_CONVERT_ALL_LF_TO_CRLF + /* + ** milter_body() uses the same conversion algorithm as putbody() + ** to translate the "local" df format (\n) to SMTP format (\r\n). + ** However, putbody() and mime8to7() use different conversion + ** algorithms. + ** If the input date does not follow the SMTP standard + ** (e.g., if it has "naked \r"s), then the output from putbody() + ** and mime8to7() will most likely be different. + ** By turning on this FFR milter_body() will try to "imitate" + ** mime8to7(). + ** Note: there is no (simple) way to deal with both conversions + ** in a consistent manner. Moreover, as the "GiGo" principle applies, + ** it's not really worth to fix it. + */ + + "_FFR_MILTER_CONVERT_ALL_LF_TO_CRLF", +#endif /* _FFR_MILTER_CONVERT_ALL_LF_TO_CRLF */ +#if _FFR_MILTER_CHECK_REJECTIONS_TOO + /* + ** Also send RCPTs that are rejected by check_rcpt to a milter + ** (if requested during option negotiation). + */ + + "_FFR_MILTER_CHECK_REJECTIONS_TOO", +#endif /* _FFR_MILTER_CHECK_REJECTIONS_TOO */ #if _FFR_MIME7TO8_OLD /* Old mime7to8 code, the new is broken for at least one example. */ "_FFR_MIME7TO8_OLD", @@ -6266,15 +6239,9 @@ char *FFRCompileOptions[] = /* log ntries=, from Nik Clayton of FreeBSD */ "_FFR_LOG_NTRIES", #endif /* _FFR_LOG_NTRIES */ -#if _FFR_PRIV_NOACTUALRECIPIENT - /* - ** PrivacyOptions=noactualrecipient stops sendmail from putting - ** X-Actual-Recipient lines in DSNs revealing the actual - ** account that addresses map to. Patch from Dan Harkless. - */ - - "_FFR_PRIV_NOACTUALRECIPIENT", -#endif /* _FFR_PRIV_NOACTUALRECIPIENT */ +#if _FFR_QF_PARANOIA + "_FFR_QF_PARANOIA", +#endif /* _FFR_QF_PARANOIA */ #if _FFR_QUEUEDELAY /* Exponential queue delay; disabled in 8.13 since it isn't used. */ "_FFR_QUEUEDELAY", @@ -6313,10 +6280,6 @@ char *FFRCompileOptions[] = /* Random shuffle for queue sorting. */ "_FFR_RHS", #endif /* _FFR_RHS */ -#if _FFR_SELECT_SHM - /* Auto-select of shared memory key */ - "_FFR_SELECT_SHM", -#endif /* _FFR_SELECT_SHM */ #if _FFR_SHM_STATUS /* Donated code (unused). */ "_FFR_SHM_STATUS", @@ -6348,10 +6311,6 @@ char *FFRCompileOptions[] = /* Use select(2) in libsm/clock.c to emulate sleep(2) */ "_FFR_SLEEP_USE_SELECT ", #endif /* _FFR_SLEEP_USE_SELECT */ -#if _FFR_SOFT_BOUNCE - /* Turn all errors into temporary errors. */ - "_FFR_SOFT_BOUNCE", -#endif /* _FFR_SOFT_BOUNCE */ #if _FFR_SPT_ALIGN /* ** It looks like the Compaq Tru64 5.1A now aligns argv and envp to 64 |