diff options
author | peter <peter@FreeBSD.org> | 1999-01-12 12:38:06 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-01-12 12:38:06 +0000 |
commit | 5b758ef6d89ac3abe22adbdc3386c76d72691136 (patch) | |
tree | 6c4f3826ab567145a7eba959bc71c7eab01748b1 | |
parent | 6788eff0e6370de72568309d3a8b1891341b0991 (diff) | |
download | FreeBSD-src-5b758ef6d89ac3abe22adbdc3386c76d72691136.zip FreeBSD-src-5b758ef6d89ac3abe22adbdc3386c76d72691136.tar.gz |
Merge sendmail 8.9.1 -> 8.9.2 changes into mainline. Some of our changes
were submitted back to sendmail.org (stage 1) and were incorporated.
-rw-r--r-- | contrib/sendmail/cf/m4/cfhead.m4 | 6 | ||||
-rw-r--r-- | contrib/sendmail/cf/ostype/bsd4.4.m4 | 6 | ||||
-rw-r--r-- | contrib/sendmail/cf/sh/makeinfo.sh | 2 | ||||
-rw-r--r-- | contrib/sendmail/mail.local/mail.local.8 | 2 | ||||
-rw-r--r-- | contrib/sendmail/mail.local/mail.local.c | 128 | ||||
-rw-r--r-- | contrib/sendmail/mailstats/mailstats.c | 60 | ||||
-rw-r--r-- | contrib/sendmail/makemap/makemap.c | 85 | ||||
-rw-r--r-- | contrib/sendmail/praliases/praliases.c | 237 | ||||
-rw-r--r-- | contrib/sendmail/rmail/rmail.c | 6 | ||||
-rw-r--r-- | contrib/sendmail/smrsh/smrsh.8 | 2 | ||||
-rw-r--r-- | contrib/sendmail/smrsh/smrsh.c | 2 | ||||
-rw-r--r-- | contrib/sendmail/src/aliases.5 | 2 | ||||
-rw-r--r-- | contrib/sendmail/src/conf.c | 265 | ||||
-rw-r--r-- | contrib/sendmail/src/conf.h | 90 | ||||
-rw-r--r-- | contrib/sendmail/src/err.c | 2 | ||||
-rw-r--r-- | contrib/sendmail/src/headers.c | 125 | ||||
-rw-r--r-- | contrib/sendmail/src/mailq.1 | 2 | ||||
-rw-r--r-- | contrib/sendmail/src/mci.c | 12 | ||||
-rw-r--r-- | contrib/sendmail/src/savemail.c | 5 | ||||
-rw-r--r-- | contrib/sendmail/src/sendmail.8 | 7 |
20 files changed, 797 insertions, 249 deletions
diff --git a/contrib/sendmail/cf/m4/cfhead.m4 b/contrib/sendmail/cf/m4/cfhead.m4 index d5778e8..abd390e 100644 --- a/contrib/sendmail/cf/m4/cfhead.m4 +++ b/contrib/sendmail/cf/m4/cfhead.m4 @@ -105,7 +105,7 @@ define(`_OPTINS', `ifdef(`$1', `$2$1$3')') m4wrap(`include(_CF_DIR_`m4/proto.m4')') # set up default values for options -define(`ALIAS_FILE', `/etc/aliases') +define(`ALIAS_FILE', ifdef(`_USE_ETC_MAIL_', `/etc/mail/aliases', `/etc/aliases')) define(`confMAILER_NAME', ``MAILER-DAEMON'') define(`confFROM_LINE', `From $g $d') define(`confOPERATORS', `.:%@!^/[]+') @@ -134,10 +134,10 @@ define(`confSAFE_QUEUE', `True') define(`confTO_QUEUERETURN', `5d') define(`confTO_QUEUEWARN', `4h') define(`confTIME_ZONE', `USE_SYSTEM') -define(`confCW_FILE', `/etc/sendmail.cw') +define(`confCW_FILE', ifdef(`_USE_ETC_MAIL_', `/etc/mail/local-host-names', `/etc/sendmail.cw')) define(`confMIME_FORMAT_ERRORS', `True') define(`confFORWARD_PATH', `$z/.forward.$w:$z/.forward') define(`confCR_FILE', `-o /etc/mail/relay-domains') divert(0)dnl -VERSIONID(`@(#)cfhead.m4 8.22 (Berkeley) 5/19/98') +VERSIONID(`@(#)cfhead.m4 8.23 (Berkeley) 10/6/1998') diff --git a/contrib/sendmail/cf/ostype/bsd4.4.m4 b/contrib/sendmail/cf/ostype/bsd4.4.m4 index 711610c..f94e653 100644 --- a/contrib/sendmail/cf/ostype/bsd4.4.m4 +++ b/contrib/sendmail/cf/ostype/bsd4.4.m4 @@ -13,9 +13,9 @@ divert(-1) # divert(0) -VERSIONID(`@(#)bsd4.4.m4 8.9 (Berkeley) 5/19/98') -ifdef(`HELP_FILE',, `define(`HELP_FILE', /usr/share/misc/sendmail.hf)')dnl -ifdef(`STATUS_FILE',, `define(`STATUS_FILE', /var/log/sendmail.st)')dnl +VERSIONID(`@(#)bsd4.4.m4 8.10 (Berkeley) 10/6/1998') +ifdef(`HELP_FILE',, `define(`HELP_FILE', ifdef(`_USE_ETC_MAIL_', `/etc/mail/helpfile', `/usr/share/misc/sendmail.hf'))')dnl +ifdef(`STATUS_FILE',, `define(`STATUS_FILE', ifdef(`_USE_ETC_MAIL_', `/etc/mail/statistics', `/var/log/sendmail.st'))')dnl ifdef(`LOCAL_MAILER_PATH',, `define(`LOCAL_MAILER_PATH', /usr/libexec/mail.local)')dnl ifdef(`LOCAL_MAILER_ARGS',, `define(`LOCAL_MAILER_ARGS', `mail $u')')dnl ifdef(`UUCP_MAILER_ARGS',, `define(`UUCP_MAILER_ARGS', `uux - -r -z -a$g $h!rmail ($u)')')dnl diff --git a/contrib/sendmail/cf/sh/makeinfo.sh b/contrib/sendmail/cf/sh/makeinfo.sh index 0cbb335..91de99b 100644 --- a/contrib/sendmail/cf/sh/makeinfo.sh +++ b/contrib/sendmail/cf/sh/makeinfo.sh @@ -10,7 +10,7 @@ # the sendmail distribution. # # -# @(#)makeinfo.sh 8.11 (Berkeley) 5/19/98 +# @(#)makeinfo.sh 8.11 (Berkeley) 5/19/1998 # usewhoami=0 diff --git a/contrib/sendmail/mail.local/mail.local.8 b/contrib/sendmail/mail.local/mail.local.8 index 7aa7cdb..541a7ee 100644 --- a/contrib/sendmail/mail.local/mail.local.8 +++ b/contrib/sendmail/mail.local/mail.local.8 @@ -7,7 +7,7 @@ .\" the sendmail distribution. .\" .\" -.\" @(#)mail.local.8 8.7 (Berkeley) 5/19/98 +.\" @(#)mail.local.8 8.7 (Berkeley) 5/19/1998 .\" .Dd May 19, 1998 .Dt MAIL.LOCAL 8 diff --git a/contrib/sendmail/mail.local/mail.local.c b/contrib/sendmail/mail.local/mail.local.c index 2a3b072..2a405c5e 100644 --- a/contrib/sendmail/mail.local/mail.local.c +++ b/contrib/sendmail/mail.local/mail.local.c @@ -1,4 +1,4 @@ -/*- +/* * Copyright (c) 1998 Sendmail, Inc. All rights reserved. * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)mail.local.c 8.78 (Berkeley) 5/19/98"; +static char sccsid[] = "@(#)mail.local.c 8.83 (Berkeley) 12/17/1998"; #endif /* not lint */ /* @@ -102,7 +102,7 @@ static char sccsid[] = "@(#)mail.local.c 8.78 (Berkeley) 5/19/98"; # define USE_VSYSLOG 0 #endif -#if defined(NeXT) +#if defined(NeXT) && !defined(__APPLE__) # include <libc.h> # define _PATH_MAILDIR "/usr/spool/mail" # define __dead /* empty */ @@ -216,18 +216,20 @@ extern char *strerror __P((int)); # define S_ISREG(mode) (((mode) & _S_IFMT) == S_IFREG) #endif +#ifndef MAILER_DAEMON +# define MAILER_DAEMON "MAILER-DAEMON" +#endif + int eval = EX_OK; /* sysexits.h error value. */ int lmtpmode = 0; u_char tTdvect[100]; void deliver __P((int, char *, int, int)); void e_to_sys __P((int)); -void err __P((const char *, ...)) __dead2; void notifybiff __P((char *)); int store __P((char *, int)); void usage __P((void)); void vwarn __P((const char *, _BSD_VA_LIST_)); -void warn __P((const char *, ...)); void lockmbox __P((char *)); void unlockmbox __P((void)); void mailerr __P((const char *, const char *, ...)); @@ -271,7 +273,7 @@ main(argc, argv) case 'f': case 'r': /* Backward compatible. */ if (from != NULL) { - warn("multiple -f options"); + mailerr(NULL, "multiple -f options"); usage(); } from = optarg; @@ -344,7 +346,7 @@ parseaddr(s) return NULL; } else { while ((isascii(*p) && isalnum(*p)) || - *p == '.' || *p == '-') + strchr(".-_", *p)) p++; } if (*p == ',' && p[1] == '@') @@ -355,6 +357,8 @@ parseaddr(s) return NULL; } + s = p; + /* local-part */ if (*p == '\"') { p++; @@ -394,7 +398,7 @@ parseaddr(s) return NULL; } else { while ((isascii(*p) && isalnum(*p)) || - *p == '.' || *p == '-') + strchr(".-_", *p)) p++; } } @@ -404,6 +408,11 @@ parseaddr(s) if (*p && *p != ' ') return NULL; len = p - s - 1; + if (*s == '\0' || len <= 0) + { + s = MAILER_DAEMON; + len = strlen(s); + } p = malloc(len + 1); if (p == NULL) { @@ -591,7 +600,7 @@ store(from, lmtprcpts) char *from; int lmtprcpts; { - FILE *fp; + FILE *fp = NULL; time_t tval; int fd, eline; char line[2048]; @@ -603,8 +612,8 @@ store(from, lmtprcpts) printf("451 4.3.0 unable to open temporary file\r\n"); return -1; } else { - e_to_sys(errno); - err("unable to open temporary file"); + mailerr("451 4.3.0", "unable to open temporary file"); + exit(eval); } } (void)unlink(tmpbuf); @@ -619,13 +628,21 @@ store(from, lmtprcpts) line[0] = '\0'; for (eline = 1; fgets(line, sizeof(line), stdin);) { - if (line[strlen(line)-2] == '\r') { - strcpy(line+strlen(line)-2, "\n"); + size_t line_len = strlen(line); + + if (line_len >= 2 && + line[line_len - 2] == '\r' && + line[line_len - 1] == '\n') { + strcpy(line + line_len - 2, "\n"); } if (lmtprcpts && line[0] == '.') { + char *src = line + 1, *dest = line; + if (line[1] == '\n') goto lmtpdot; - strcpy(line, line+1); + while (*src != '\0') + *dest++ = *src++; + *dest = '\0'; } if (line[0] == '\n') eline = 1; @@ -644,8 +661,10 @@ store(from, lmtprcpts) fclose(fp); return -1; } else { - e_to_sys(errno); - err("temporary file write error"); + mailerr("451 4.3.0", + "temporary file write error"); + fclose(fp); + exit(eval); } } } @@ -672,8 +691,9 @@ store(from, lmtprcpts) fclose(fp); return -1; } else { - e_to_sys(errno); - err("temporary file write error"); + mailerr("451 4.3.0", "temporary file write error"); + fclose(fp); + exit(eval); } } return (fd); @@ -708,7 +728,13 @@ deliver(fd, name, nobiff, nofsync) } } else { - warn("unknown name: %s", name); + char *errcode = NULL; + + if (eval == EX_TEMPFAIL) + errcode = "451 4.3.0"; + else + errcode = "550 5.1.1"; + mailerr(errcode, "unknown name: %s", name); } return; } @@ -763,7 +789,8 @@ tryagain: if (lstat(path, &sb) < 0) { eval = EX_CANTCREAT; - warn("%s: lstat: file changed after open", path); + mailerr("550 5.2.0", + "%s: lstat: file changed after open", path); goto err1; } else @@ -802,7 +829,8 @@ tryagain: #endif sb.st_uid != fsb.st_uid) { eval = EX_TEMPFAIL; - warn("%s: fstat: file changed after open", path); + mailerr("550 5.2.0", "%s: fstat: file changed after open", + path); goto err1; } @@ -855,9 +883,12 @@ tryagain: mailerr("450 4.2.0", "%s: %s", path, strerror(errno)); err3: if (setreuid(0, 0) < 0) { +#if 0 + /* already printed an error above for this recipient */ e_to_sys(errno); mailerr("450 4.2.0", "setreuid(0, 0): %s", strerror(errno)); +#endif } #ifdef DEBUG printf("reset euid = %d\n", geteuid()); @@ -960,7 +991,6 @@ notifybiff(msg) if ((sp = getservbyname("biff", "udp")) == NULL) return; if ((hp = gethostbyname("localhost")) == NULL) { - warn("localhost: %s", strerror(errno)); return; } addr.sin_family = hp->h_addrtype; @@ -968,20 +998,18 @@ notifybiff(msg) addr.sin_port = sp->s_port; } if (f < 0 && (f = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { - warn("socket: %s", strerror(errno)); return; } len = strlen(msg) + 1; - if (sendto(f, msg, len, 0, (struct sockaddr *)&addr, sizeof(addr)) - != len) - warn("sendto biff: %s", strerror(errno)); + (void) sendto(f, msg, len, 0, (struct sockaddr *)&addr, sizeof(addr)); } void usage() { eval = EX_USAGE; - err("usage: mail.local [-b] [-l] [-f from] [-s] user ..."); + mailerr(NULL, "usage: mail.local [-b] [-l] [-f from] [-s] user ..."); + exit(eval); } void @@ -1003,7 +1031,8 @@ mailerr(hdr, fmt, va_alist) #endif if (lmtpmode) { - printf("%s ", hdr); + if (hdr != NULL) + printf("%s ", hdr); vprintf(fmt, ap); printf("\r\n"); } @@ -1014,49 +1043,6 @@ mailerr(hdr, fmt, va_alist) } } -#ifdef __STDC__ -void -err(const char *fmt, ...) -#else -void -err(fmt, va_alist) - const char *fmt; - va_dcl -#endif -{ - va_list ap; - -#ifdef __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - vwarn(fmt, ap); - va_end(ap); - - exit(eval); -} - -void -#ifdef __STDC__ -warn(const char *fmt, ...) -#else -warn(fmt, va_alist) - const char *fmt; - va_dcl -#endif -{ - va_list ap; - -#ifdef __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - vwarn(fmt, ap); - va_end(ap); -} - void vwarn(fmt, ap) const char *fmt; diff --git a/contrib/sendmail/mailstats/mailstats.c b/contrib/sendmail/mailstats/mailstats.c index 2ad489f..55a7b96 100644 --- a/contrib/sendmail/mailstats/mailstats.c +++ b/contrib/sendmail/mailstats/mailstats.c @@ -18,7 +18,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)mailstats.c 8.26 (Berkeley) 7/2/98"; +static char sccsid[] = "@(#)mailstats.c 8.28 (Berkeley) 9/14/1998"; #endif /* not lint */ #ifndef NOT_SENDMAIL @@ -45,17 +45,20 @@ main(argc, argv) char *cfile; FILE *cfp; bool mnames; + bool progmode; long frmsgs = 0, frbytes = 0, tomsgs = 0, tobytes = 0, rejmsgs = 0; long dismsgs = 0; char mtable[MAXMAILERS][MNAMELEN+1]; char sfilebuf[MAXLINE]; char buf[MAXLINE]; + time_t now; extern char *ctime(); cfile = _PATH_SENDMAILCF; sfile = NULL; mnames = TRUE; - while ((ch = getopt(argc, argv, "C:f:o")) != -1) + progmode = FALSE; + while ((ch = getopt(argc, argv, "C:f:op")) != -1) { switch (ch) { @@ -71,11 +74,22 @@ main(argc, argv) mnames = FALSE; break; +#if _FFR_MAILSTATS_PROGMODE + case 'p': + progmode = TRUE; + break; +#endif + case '?': default: usage: - fputs("usage: mailstats [-o] [-C cffile] [-f stfile]\n", +#if _FFR_MAILSTATS_PROGMODE + fputs("usage: mailstats [-o] [-C cffile] [-f stfile] -o -p\n", + stderr); +#else + fputs("usage: mailstats [-o] [-C cffile] [-f stfile] -o \n", stderr); +#endif exit(EX_USAGE); } } @@ -226,15 +240,29 @@ main(argc, argv) } } - printf("Statistics from %s", ctime(&stat.stat_itime)); - printf(" M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis%s\n", - mnames ? " Mailer" : ""); + if (progmode) + { + time(&now); + printf("%ld %ld\n", (long) stat.stat_itime, (long) now); + } + else + { + printf("Statistics from %s", ctime(&stat.stat_itime)); + printf(" M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis%s\n", + mnames ? " Mailer" : ""); + } for (i = 0; i < MAXMAILERS; i++) { if (stat.stat_nf[i] || stat.stat_nt[i] || stat.stat_nr[i] || stat.stat_nd[i]) { - printf("%2d %8ld %10ldK %8ld %10ldK %6ld %6ld", i, + char *format; + + if (progmode) + format = "%2d %8ld %10ld %8ld %10ld %6ld %6ld"; + else + format = "%2d %8ld %10ldK %8ld %10ldK %6ld %6ld"; + printf(format, i, stat.stat_nf[i], stat.stat_bf[i], stat.stat_nt[i], stat.stat_bt[i], stat.stat_nr[i], stat.stat_nd[i]); @@ -249,8 +277,20 @@ main(argc, argv) dismsgs += stat.stat_nd[i]; } } - printf("=============================================================\n"); - printf(" T %8ld %10ldK %8ld %10ldK %6ld %6ld\n", - frmsgs, frbytes, tomsgs, tobytes, rejmsgs, dismsgs); + if (progmode) + { + printf(" T %8ld %10ld %8ld %10ld %6ld %6ld\n", + frmsgs, frbytes, tomsgs, tobytes, rejmsgs, dismsgs); + close(fd); + fd = open(sfile, O_RDWR | O_TRUNC); + if (fd > 0) + close(fd); + } + else + { + printf("=============================================================\n"); + printf(" T %8ld %10ldK %8ld %10ldK %6ld %6ld\n", + frmsgs, frbytes, tomsgs, tobytes, rejmsgs, dismsgs); + } exit(EX_OK); } diff --git a/contrib/sendmail/makemap/makemap.c b/contrib/sendmail/makemap/makemap.c index 5891d75..9717a43 100644 --- a/contrib/sendmail/makemap/makemap.c +++ b/contrib/sendmail/makemap/makemap.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)makemap.c 8.62 (Berkeley) 6/24/98"; +static char sccsid[] = "@(#)makemap.c 8.71 (Berkeley) 11/29/1998"; #endif /* not lint */ #include <sys/types.h> @@ -57,10 +57,10 @@ uid_t RunAsUid; uid_t RunAsGid; char *RunAsUserName; int Verbose = 2; -bool DontInitGroups = TRUE; +bool DontInitGroups = FALSE; long DontBlameSendmail = DBS_SAFE; u_char tTdvect[100]; -uid_t TrustedFileUid = 0; +uid_t TrustedUid = 0; #define BUFSIZE 1024 @@ -79,16 +79,20 @@ main(argc, argv) bool foldcase = TRUE; int exitstat; int opt; - char *typename; - char *mapname; - char *ext; + char *typename = NULL; + char *mapname = NULL; + char *ext = NULL; int lineno; int st; int mode; - int putflags; + int putflags = 0; +#ifdef NEWDB long dbcachesize = 1024 * 1024; +#endif enum type type; +#if !O_EXLOCK int fd; +#endif int sff = SFF_ROOTOK|SFF_REGONLY; struct passwd *pw; union @@ -116,7 +120,7 @@ main(argc, argv) #ifdef NDBM char pbuf[MAXNAME]; #endif -#if _FFR_TRUSTED_FILE_OWNER +#if _FFR_TRUSTED_USER FILE *cfp; char buf[MAXLINE]; #endif @@ -145,7 +149,7 @@ main(argc, argv) RunAsUserName = RealUserName = rnamebuf; #if _FFR_NEW_MAKEMAP_FLAGS -#define OPTIONS "C:Nc:dforsv" +#define OPTIONS "C:Nc:dflorsv" #else #define OPTIONS "C:Ndforsv" #endif @@ -163,7 +167,9 @@ main(argc, argv) #if _FFR_NEW_MAKEMAP_FLAGS case 'c': +# ifdef NEWDB dbcachesize = atol(optarg); +# endif break; #endif @@ -175,6 +181,19 @@ main(argc, argv) foldcase = FALSE; break; +#if _FFR_NEW_MAKEMAP_FLAGS + case 'l': +# ifdef NDBM + printf("dbm\n"); +# endif +# ifdef NEWDB + printf("hash\n"); + printf("btree\n"); +# endif + exit(EX_OK); + break; +#endif + case 'o': notrunc = TRUE; break; @@ -232,7 +251,7 @@ main(argc, argv) type = T_UNKNOWN; } -#if _FFR_TRUSTED_FILE_OWNER +#if _FFR_TRUSTED_USER if ((cfp = fopen(cfile, "r")) == NULL) { fprintf(stderr, "mailstats: "); @@ -250,8 +269,8 @@ main(argc, argv) switch (*b++) { case 'O': /* option */ - if (strncasecmp(b, " TrustedFileOwner", 17) == 0 && - !(isascii(b[17]) && isalnum(b[17]))) + if (strncasecmp(b, " TrustedUser", 12) == 0 && + !(isascii(b[12]) && isalnum(b[12]))) { b = strchr(b, '='); if (b == NULL) @@ -259,26 +278,26 @@ main(argc, argv) while (isascii(*++b) && isspace(*b)) continue; if (isascii(*b) && isdigit(*b)) - TrustedFileUid = atoi(b); + TrustedUid = atoi(b); else { register struct passwd *pw; - TrustedFileUid = 0; + TrustedUid = 0; pw = getpwnam(b); if (pw == NULL) fprintf(stderr, - "TrustedFileOwner: unknown user %s", b); + "TrustedUser: unknown user %s\n", b); else - TrustedFileUid = pw->pw_uid; + TrustedUid = pw->pw_uid; } # ifdef UID_MAX - if (TrustedFileUid > UID_MAX) + if (TrustedUid > UID_MAX) { - syserr("TrustedFileOwner: uid value (%ld) > UID_MAX (%ld)", - TrustedFileUid, UID_MAX); - TrustedFileUid = 0; + syserr("TrustedUser: uid value (%ld) > UID_MAX (%ld)", + TrustedUid, UID_MAX); + TrustedUid = 0; } # endif break; @@ -296,7 +315,7 @@ main(argc, argv) case T_ERR: #if _FFR_NEW_MAKEMAP_FLAGS fprintf(stderr, - "Usage: %s [-N] [-c cachesize] [-d] [-f] [-o] [-r] [-s] [-v] type mapname\n", + "Usage: %s [-N] [-c cachesize] [-d] [-f] [-l] [-o] [-r] [-s] [-v] type mapname\n", progname); #else fprintf(stderr, "Usage: %s [-N] [-d] [-f] [-o] [-r] [-s] [-v] type mapname\n", progname); @@ -505,16 +524,18 @@ main(argc, argv) dbm_close(dbp.dbm); exit(EX_CANTCREAT); } - if (geteuid() == 0 && TrustedFileUid != 0) +#if _FFR_TRUSTED_USER + if (geteuid() == 0 && TrustedUid != 0) { - if (fchown(dbm_dirfno(dbp.dbm), TrustedFileUid, -1) < 0 || - fchown(dbm_pagfno(dbp.dbm), TrustedFileUid, -1) < 0) + if (fchown(dbm_dirfno(dbp.dbm), TrustedUid, -1) < 0 || + fchown(dbm_pagfno(dbp.dbm), TrustedUid, -1) < 0) { fprintf(stderr, "WARNING: ownership change on %s failed: %s", mapname, errstring(errno)); } } +#endif break; #endif @@ -569,15 +590,17 @@ main(argc, argv) exit(EX_CANTCREAT); } (void) (*dbp.db->sync)(dbp.db, 0); - if (geteuid() == 0 && TrustedFileUid != 0) +#if _FFR_TRUSTED_USER + if (geteuid() == 0 && TrustedUid != 0) { - if (fchown(fd, TrustedFileUid, -1) < 0) + if (fchown(fd, TrustedUid, -1) < 0) { fprintf(stderr, "WARNING: ownership change on %s failed: %s", mapname, errstring(errno)); } } +#endif } break; @@ -628,15 +651,17 @@ main(argc, argv) exit(EX_CANTCREAT); } (void) (*dbp.db->sync)(dbp.db, 0); - if (geteuid() == 0 && TrustedFileUid != 0) +#if _FFR_TRUSTED_USER + if (geteuid() == 0 && TrustedUid != 0) { - if (fchown(fd, TrustedFileUid, -1) < 0) + if (fchown(fd, TrustedUid, -1) < 0) { fprintf(stderr, "WARNING: ownership change on %s failed: %s", mapname, errstring(errno)); } } +#endif } break; #endif @@ -936,10 +961,12 @@ const char * errstring(err) int err; { +#if !HASSTRERROR static char errstr[64]; -#if !HASSTRERROR && !defined(ERRLIST_PREDEFINED) +# if !defined(ERRLIST_PREDEFINED) extern char *sys_errlist[]; extern int sys_nerr; +# endif #endif /* handle pseudo-errors internal to sendmail */ diff --git a/contrib/sendmail/praliases/praliases.c b/contrib/sendmail/praliases/praliases.c index db7aa68..8b0057a 100644 --- a/contrib/sendmail/praliases/praliases.c +++ b/contrib/sendmail/praliases/praliases.c @@ -17,7 +17,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)praliases.c 8.17 (Berkeley) 6/25/98"; +static char sccsid[] = "@(#)praliases.c 8.21 (Berkeley) 12/27/1998"; #endif /* not lint */ #if !defined(NDBM) && !defined(NEWDB) @@ -32,6 +32,7 @@ static char sccsid[] = "@(#)praliases.c 8.17 (Berkeley) 6/25/98"; # define NOT_SENDMAIL #endif #include <sendmail.h> +#include <pathnames.h> #ifdef NEWDB # include <db.h> # ifndef DB_VERSION_MAJOR @@ -50,6 +51,11 @@ static char sccsid[] = "@(#)praliases.c 8.17 (Berkeley) 6/25/98"; extern char *strerror __P((int)); #endif +static void praliases __P((char *, int, char **)); +#ifdef NDBM +static void praliases_dbm __P((char *, int, char **)); +#endif + int main(argc, argv) int argc; @@ -57,32 +63,148 @@ main(argc, argv) { extern char *optarg; extern int optind; -#ifdef NDBM - DBM *dbp; - datum content, key; + char *cfile; +#if _FFR_GRAB_ALIASFILE_OPTION + char *filename = NULL; +#else + char *filename = "/etc/aliases"; #endif - char *filename; + FILE *cfp; int ch; -#ifdef NEWDB - DB *db; - DBT newdbkey, newdbcontent; - char buf[MAXNAME]; -#endif + char afilebuf[MAXLINE]; + char buf[MAXLINE]; - filename = "/etc/aliases"; + cfile = _PATH_SENDMAILCF; +#if _FFR_GRAB_ALIASFILE_OPTION + while ((ch = getopt(argc, argv, "C:f:")) != -1) +#else while ((ch = getopt(argc, argv, "f:")) != -1) - switch((char)ch) { +#endif + { + switch ((char)ch) { + case 'C': + cfile = optarg; + break; case 'f': filename = optarg; break; case '?': default: - (void)fprintf(stderr, "usage: praliases [-f file]\n"); + (void)fprintf(stderr, +#if _FFR_GRAB_ALIASFILE_OPTION + "usage: praliases [-C cffile] [-f aliasfile]\n"); +#else + "usage: praliases [-f aliasfile]\n"); +#endif exit(EX_USAGE); } + } argc -= optind; argv += optind; + if (filename != NULL) + { + praliases(filename, argc, argv); + exit(EX_OK); + } + + if ((cfp = fopen(cfile, "r")) == NULL) + { + fprintf(stderr, "praliases: "); + perror(cfile); + exit(EX_NOINPUT); + } + + while (fgets(buf, sizeof(buf), cfp) != NULL) + { + register char *b, *p; + + b = buf; + switch (*b++) + { + case 'O': /* option -- see if alias file */ + if (strncasecmp(b, " AliasFile", 10) == 0 && + !(isascii(b[10]) && isalnum(b[10]))) + { + /* new form -- find value */ + b = strchr(b, '='); + if (b == NULL) + continue; + while (isascii(*++b) && isspace(*b)) + continue; + } + else if (*b++ != 'A') + { + /* something else boring */ + continue; + } + + /* this is the A or AliasFile option -- save it */ + if (strlen(b) >= sizeof afilebuf) + { + fprintf(stderr, + "AliasFile filename too long: %.30s...\n", + b); + (void) fclose(cfp); + exit(EX_CONFIG); + } + strcpy(afilebuf, b); + b = afilebuf; + + for (p = b; p != NULL; ) + { + while (isascii(*p) && isspace(*p)) + p++; + if (*p == '\0') + break; + b = p; + + p = strpbrk(p, " ,/"); + /* find end of spec */ + if (p != NULL) + p = strpbrk(p, ",\n"); + if (p != NULL) + *p++ = '\0'; + + praliases(b, argc, argv); + } + + default: + continue; + } + } + (void) fclose(cfp); + exit(EX_OK); +} + +static void +praliases(filename, argc, argv) + char *filename; + int argc; + char **argv; +{ +#ifdef NEWDB + DB *db; + DBT newdbkey, newdbcontent; + char buf[MAXNAME]; +#endif + char *class; + + class = strchr(filename, ':'); + if (class != NULL) + { + if (strncasecmp(filename, "dbm:", 4) == 0) + { +#ifdef NDBM + praliases_dbm(class + 1, argc, argv); + return; +#else + fprintf(stderr, "class dbm not available\n"); + exit(EX_DATAERR); +#endif + } + filename = class + 1; + } #ifdef NEWDB if (strlen(filename) + 4 >= sizeof buf) { @@ -99,7 +221,8 @@ main(argc, argv) # endif if (db != NULL) { - if (!argc) { + if (!argc) + { # if DB_VERSION_MAJOR > 1 DBC *dbc; # endif @@ -109,7 +232,11 @@ main(argc, argv) # if DB_VERSION_MAJOR < 2 while(!db->seq(db, &newdbkey, &newdbcontent, R_NEXT)) # else +# if DB_VERSION_MAJOR > 2 || DB_VERSION_MINOR >=6 + if ((errno = db->cursor(db, NULL, &dbc, 0)) == 0) +# else if ((errno = db->cursor(db, NULL, &dbc)) == 0) +# endif { while ((errno = dbc->c_get(dbc, &newdbkey, &newdbcontent, @@ -128,11 +255,13 @@ main(argc, argv) fprintf(stderr, "praliases: %s: Could not set cursor: %s\n", buf, strerror(errno)); + errno = db->close(db, 0); exit(EX_DATAERR); } # endif } - else for (; *argv; ++argv) { + else for (; *argv; ++argv) + { bzero(&newdbkey, sizeof newdbkey); bzero(&newdbcontent, sizeof newdbcontent); newdbkey.data = *argv; @@ -156,39 +285,71 @@ main(argc, argv) errno = db->close(db, 0); # endif } - else { + else + { +#endif +#ifdef NDBM + praliases_dbm(filename, argc, argv); +#endif +#ifdef NEWDB + } #endif +} + #ifdef NDBM - if ((dbp = dbm_open(filename, O_RDONLY, 0)) == NULL) { - (void)fprintf(stderr, - "praliases: %s: %s\n", filename, strerror(errno)); - exit(EX_OSFILE); +static void +praliases_dbm(filename, argc, argv) + char *filename; + int argc; + char **argv; +{ + DBM *dbp; + datum content, key; + + if ((dbp = dbm_open(filename, O_RDONLY, 0)) == NULL) + { + (void)fprintf(stderr, + "praliases: %s: %s\n", filename, strerror(errno)); + exit(EX_OSFILE); + } + if (!argc) + { + for (key = dbm_firstkey(dbp); + key.dptr != NULL; key = dbm_nextkey(dbp)) + { + content = dbm_fetch(dbp, key); + (void)printf("%.*s:%.*s\n", + (int) key.dsize, key.dptr, + (int) content.dsize, content.dptr); } - if (!argc) - for (key = dbm_firstkey(dbp); - key.dptr != NULL; key = dbm_nextkey(dbp)) { - content = dbm_fetch(dbp, key); - (void)printf("%.*s:%.*s\n", - (int) key.dsize, key.dptr, - (int) content.dsize, content.dptr); - } - else for (; *argv; ++argv) { + } + else + { + for (; *argv; ++argv) + { + /* + ** Use the sendmail adaptive algorithm of trying + ** the key first without, then if needed with, + ** the terminating NULL byte. + */ key.dptr = *argv; - key.dsize = strlen(*argv) + 1; + key.dsize = strlen(*argv); content = dbm_fetch(dbp, key); - if (!content.dptr) - (void)printf("%s: No such key\n", key.dptr); - else + if (content.dptr == NULL) + { + key.dsize++; + content = dbm_fetch(dbp, key); + } + if (content.dptr != NULL) (void)printf("%s:%.*s\n", key.dptr, (int) content.dsize, content.dptr); + else + (void)printf("%s: No such key\n", key.dptr); } - dbm_close(dbp); -#endif -#ifdef NEWDB } -#endif - exit(EX_OK); + dbm_close(dbp); } +#endif #if !HASSTRERROR diff --git a/contrib/sendmail/rmail/rmail.c b/contrib/sendmail/rmail/rmail.c index ff3fcef..3c268ab 100644 --- a/contrib/sendmail/rmail/rmail.c +++ b/contrib/sendmail/rmail/rmail.c @@ -16,7 +16,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)rmail.c 8.17 (Berkeley) 5/19/98"; +static char sccsid[] = "@(#)rmail.c 8.18 (Berkeley) 10/23/1998"; #endif /* not lint */ /* @@ -136,10 +136,10 @@ main(argc, argv) extern int errno, optind; FILE *fp; struct stat sb; - size_t fplen, fptlen, len; + size_t fplen = 0, fptlen = 0, len; off_t offset; int ch, debug, i, pdes[2], pid, status; - char *addrp, *domain, *p, *t; + char *addrp = NULL, *domain, *p, *t; char *from_path, *from_sys, *from_user; char *args[100], buf[2048], lbuf[2048]; diff --git a/contrib/sendmail/smrsh/smrsh.8 b/contrib/sendmail/smrsh/smrsh.8 index 2e76f7e..bd0fb69 100644 --- a/contrib/sendmail/smrsh/smrsh.8 +++ b/contrib/sendmail/smrsh/smrsh.8 @@ -8,7 +8,7 @@ .\" the sendmail distribution. .\" .\" -.\" @(#)smrsh.8 8.7 (Berkeley) 5/19/98 +.\" @(#)smrsh.8 8.7 (Berkeley) 5/19/1998 .\" .TH SMRSH 8 11/02/93 .SH NAME diff --git a/contrib/sendmail/smrsh/smrsh.c b/contrib/sendmail/smrsh/smrsh.c index ff90733..cf7768f 100644 --- a/contrib/sendmail/smrsh/smrsh.c +++ b/contrib/sendmail/smrsh/smrsh.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)smrsh.c 8.11 (Berkeley) 5/19/98"; +static char sccsid[] = "@(#)smrsh.c 8.11 (Berkeley) 5/19/1998"; #endif /* not lint */ /* diff --git a/contrib/sendmail/src/aliases.5 b/contrib/sendmail/src/aliases.5 index 3fa4d6e..513bf49 100644 --- a/contrib/sendmail/src/aliases.5 +++ b/contrib/sendmail/src/aliases.5 @@ -8,7 +8,7 @@ .\" the sendmail distribution. .\" .\" -.\" @(#)aliases.5 8.8 (Berkeley) 5/19/98 +.\" @(#)aliases.5 8.8 (Berkeley) 5/19/1998 .\" .Dd May 19, 1998 .Dt ALIASES 5 diff --git a/contrib/sendmail/src/conf.c b/contrib/sendmail/src/conf.c index 538ade4..82e7543 100644 --- a/contrib/sendmail/src/conf.c +++ b/contrib/sendmail/src/conf.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)conf.c 8.431 (Berkeley) 6/25/98"; +static char sccsid[] = "@(#)conf.c 8.450 (Berkeley) 12/17/1998"; #endif /* not lint */ # include "sendmail.h" @@ -217,7 +217,6 @@ setdefaults(e) int i; struct passwd *pw; char buf[MAXNAME]; - extern void inittimeouts __P((char *)); extern void setdefuser __P((void)); extern void setupmaps __P((void)); extern void setupmailers __P((void)); @@ -247,7 +246,7 @@ setdefaults(e) DefGid = 1; /* option g */ setdefuser(); } - TrustedFileUid = 0; + TrustedUid = 0; if (tTd(37, 4)) printf("setdefaults: DefUser=%s, DefUid=%d, DefGid=%d\n", DefUser != NULL ? DefUser : "<1:1>", @@ -292,6 +291,7 @@ setdefaults(e) #ifdef HESIOD_INIT HesiodContext = NULL; #endif + ControlSocketName = NULL; setupmaps(); setupmailers(); setupheaders(); @@ -324,7 +324,6 @@ void setupmailers() { char buf[100]; - extern void makemailer __P((char *)); strcpy(buf, "prog, P=/bin/sh, F=lsoDq9, T=DNS/RFC822/X-Unix, A=sh -c \201u"); makemailer(buf); @@ -838,6 +837,14 @@ switch_map_find(service, maptype, mapreturn) *p++ = '\0'; if (buf[0] == '\0') continue; + if (p == NULL) + { + sm_syslog(LOG_ERR, NOQID, + "Bad line on %.100s: %.100s", + ServiceSwitchFile, + buf); + continue; + } while (isspace(*p)) p++; if (*p == '\0') @@ -1280,10 +1287,10 @@ init_md(argc, argv) #endif #ifdef __QNX__ /* - ** Due to QNX's network distributed nature, you can target a tcpip - ** stack on a different node in the qnx network; this patch lets - ** this feature work. The __sock_locate() must be done before the - ** environment is clear. + ** Due to QNX's network distributed nature, you can target a tcpip + ** stack on a different node in the qnx network; this patch lets + ** this feature work. The __sock_locate() must be done before the + ** environment is clear. */ __sock_locate(); #endif @@ -2047,7 +2054,7 @@ refuseconnections(port) else if (conncnt++ > ConnRateThrottle && ConnRateThrottle > 0) { /* sleep to flatten out connection load */ - setproctitle("deferring connections on port %d: %d per second", + sm_setproctitle(TRUE, "deferring connections on port %d: %d per second", port, ConnRateThrottle); if (LogLevel >= 14) sm_syslog(LOG_INFO, NOQID, @@ -2059,7 +2066,7 @@ refuseconnections(port) CurrentLA = getla(); if (CurrentLA >= refusela) { - setproctitle("rejecting connections on port %d: load average: %d", + sm_setproctitle(TRUE, "rejecting connections on port %d: load average: %d", port, CurrentLA); if (LogLevel >= 14) sm_syslog(LOG_INFO, NOQID, @@ -2070,7 +2077,7 @@ refuseconnections(port) if (!enoughdiskspace(MinBlocksFree + 1)) { - setproctitle("rejecting connections on port %d: min free: %d", + sm_setproctitle(TRUE, "rejecting connections on port %d: min free: %d", port, MinBlocksFree); if (LogLevel >= 14) sm_syslog(LOG_INFO, NOQID, @@ -2081,12 +2088,10 @@ refuseconnections(port) if (MaxChildren > 0 && CurChildren >= MaxChildren) { - extern void proc_list_probe __P((void)); - proc_list_probe(); if (CurChildren >= MaxChildren) { - setproctitle("rejecting connections on port %d: %d children, max %d", + sm_setproctitle(TRUE, "rejecting connections on port %d: %d children, max %d", port, CurChildren, MaxChildren); if (LogLevel >= 14) sm_syslog(LOG_INFO, NOQID, @@ -2170,12 +2175,12 @@ typedef unsigned int *pt_entry_t; # define SPT_PADCHAR ' ' # endif +#endif /* SPT_TYPE != SPT_NONE && SPT_TYPE != SPT_BUILTIN */ + # ifndef SPT_BUFSIZE # define SPT_BUFSIZE MAXLINE # endif -#endif /* SPT_TYPE != SPT_NONE && SPT_TYPE != SPT_BUILTIN */ - /* ** Pointers for setproctitle. ** This allows "ps" listings to give more useful information. @@ -2320,6 +2325,44 @@ setproctitle(fmt, va_alist) #endif /* SPT_TYPE != SPT_BUILTIN */ /* +** SM_SETPROCTITLE -- set process task and set process title for ps +** +** Possibly set process status and call setproctitle() to +** change the ps display. +** +** Parameters: +** status -- whether or not to store as process status +** fmt -- a printf style format string. +** a, b, c -- possible parameters to fmt. +** +** Returns: +** none. +*/ + +/*VARARGS2*/ +void +# ifdef __STDC__ +sm_setproctitle(bool status, const char *fmt, ...) +# else +sm_setproctitle(status, fmt, va_alist) + bool status; + const char *fmt; + va_dcl +#endif +{ + char buf[SPT_BUFSIZE]; + + VA_LOCAL_DECL + /* print the argument string */ + VA_START(fmt); + (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); + VA_END; + + if (status) + proc_list_set(getpid(), buf); + setproctitle("%s", buf); +} +/* ** WAITFOR -- wait for a particular process id. ** ** Parameters: @@ -2789,8 +2832,8 @@ dgux_inet_addr(host) /* -** this version hacked to add `atend' flag to allow state machine -** to reset if invoked by the program to scan args for a 2nd time +** this version hacked to add `atend' flag to allow state machine +** to reset if invoked by the program to scan args for a 2nd time */ #if defined(LIBC_SCCS) && !defined(lint) @@ -2962,7 +3005,7 @@ char *DefaultUserShells[] = "/bin/bsh", /* Bourne shell */ "/usr/bin/bsh", #endif -#ifdef __svr4__ +#if defined(__svr4__) || defined(__svr5__) "/bin/ksh", /* Korn shell */ "/usr/bin/ksh", #endif @@ -3665,9 +3708,63 @@ setvendor(vendor) } #endif +#if defined(VENDOR_NAME) && defined(VENDOR_CODE) + if (strcasecmp(vendor, VENDOR_NAME) == 0) + { + VendorCode = VENDOR_CODE; + return TRUE; + } +#endif + return FALSE; } /* +** GETVENDOR -- return vendor name based on vendor code +** +** Parameters: +** vendorcode -- numeric representation of vendor. +** +** Returns: +** string containing vendor name. +*/ + +char * +getvendor(vendorcode) + int vendorcode; +{ +#if defined(VENDOR_NAME) && defined(VENDOR_CODE) + /* + ** Can't have the same switch case twice so need to + ** handle VENDOR_CODE outside of switch. It might + ** match one of the existing VENDOR_* codes. + */ + + if (vendorcode == VENDOR_CODE) + return VENDOR_NAME; +#endif + + switch (vendorcode) + { + case VENDOR_BERKELEY: + return "Berkeley"; + + case VENDOR_SUN: + return "Sun"; + + case VENDOR_HP: + return "HP"; + + case VENDOR_IBM: + return "IBM"; + + case VENDOR_SENDMAIL: + return "Sendmail"; + + default: + return "Unknown"; + } +} +/* ** VENDOR_PRE_DEFAULTS, VENDOR_POST_DEFAULTS -- set vendor-specific defaults ** ** Vendor_pre_defaults is called before reading the configuration @@ -3730,7 +3827,7 @@ vendor_daemon_setup(e) if (getluid() != -1) { usrerr("Daemon cannot have LUID"); - exit(EX_USAGE); + finis(FALSE, EX_USAGE); } #endif /* SECUREWARE */ } @@ -4173,11 +4270,88 @@ secureware_setup_secure(uid) rc, uid); break; } - exit(EX_NOPERM); + finis(FALSE, EX_NOPERM); } } #endif /* SECUREWARE */ /* +** ADD_LOCAL_HOST_NAMES -- Add a hostname to class 'w' based on IP address +** +** Add hostnames to class 'w' based on the IP address read from +** the network interface. +** +** Parameters: +** sa -- a pointer to a SOCKADDR containing the address +** +** Returns: +** 0 if successful, -1 if host lookup fails. +*/ + +int +add_hostnames(sa) + SOCKADDR *sa; +{ + struct hostent *hp; + + /* lookup name with IP address */ + switch (sa->sa.sa_family) + { + case AF_INET: + hp = sm_gethostbyaddr((char *) &sa->sin.sin_addr, + sizeof(sa->sin.sin_addr), sa->sa.sa_family); + break; + + default: +#if _FFR_LOG_UNSUPPORTED_FAMILIES + /* XXX: Give warning about unsupported family */ + if (LogLevel > 3) + sm_syslog(LOG_WARNING, NOQID, + "Unsupported address family %d: %.100s", + sa->sa.sa_family, anynet_ntoa(sa)); +#endif + return -1; + } + + if (hp == NULL) + { + int save_errno = errno; + + if (LogLevel > 3) + sm_syslog(LOG_WARNING, NOQID, + "gethostbyaddr(%.100s) failed: %d\n", + anynet_ntoa(sa), +#if NAMED_BIND + h_errno +#else + -1 +#endif + ); + errno = save_errno; + return -1; + } + + /* save its cname */ + if (!wordinclass((char *) hp->h_name, 'w')) + { + setclass('w', (char *) hp->h_name); + if (tTd(0, 4)) + printf("\ta.k.a.: %s\n", hp->h_name); + } + + /* save all it aliases name */ + while (*hp->h_aliases) + { + if (!wordinclass(*hp->h_aliases, 'w')) + { + setclass('w', *hp->h_aliases); + if (tTd(0, 4)) + printf("\ta.k.a.: %s\n", *hp->h_aliases); + } + hp->h_aliases++; + } + return 0; +} +/* ** LOAD_IF_NAMES -- load interface-specific names into $=w ** ** Parameters: @@ -4254,9 +4428,8 @@ load_if_names() for (i = 0; i < ifc.ifc_len; ) { struct ifreq *ifr = (struct ifreq *) &ifc.ifc_buf[i]; - struct sockaddr *sa = &ifr->ifr_addr; + SOCKADDR *sa = (SOCKADDR *) &ifr->ifr_addr; struct in_addr ia; - struct hostent *hp; #ifdef SIOCGIFFLAGS struct ifreq ifrf; #endif @@ -4264,14 +4437,14 @@ load_if_names() extern char *inet_ntoa(); #ifdef BSD4_4_SOCKADDR - if (sa->sa_len > sizeof ifr->ifr_addr) - i += sizeof ifr->ifr_name + sa->sa_len; + if (sa->sa.sa_len > sizeof ifr->ifr_addr) + i += sizeof ifr->ifr_name + sa->sa.sa_len; else #endif i += sizeof *ifr; if (tTd(0, 20)) - printf("%s\n", anynet_ntoa((SOCKADDR *) sa)); + printf("%s\n", anynet_ntoa(sa)); if (ifr->ifr_addr.sa_family != AF_INET) continue; @@ -4290,7 +4463,7 @@ load_if_names() continue; /* extract IP address from the list*/ - ia = (((struct sockaddr_in *) sa)->sin_addr); + ia = sa->sin.sin_addr; if (ia.s_addr == INADDR_ANY || ia.s_addr == INADDR_NONE) { message("WARNING: interface %s is UP with %s address", @@ -4313,41 +4486,7 @@ load_if_names() if (bitset(IFF_LOOPBACK, IFRFREF.ifr_flags)) continue; - /* lookup name with IP address */ - hp = sm_gethostbyaddr((char *) &ia, sizeof(ia), AF_INET); - if (hp == NULL) - { - if (LogLevel > 3) - sm_syslog(LOG_WARNING, NOQID, - "gethostbyaddr(%.100s) failed: %d\n", - inet_ntoa(ia), -#if NAMED_BIND - h_errno); -#else - -1); -#endif - continue; - } - - /* save its cname */ - if (!wordinclass((char *) hp->h_name, 'w')) - { - setclass('w', (char *) hp->h_name); - if (tTd(0, 4)) - printf("\ta.k.a.: %s\n", hp->h_name); - } - - /* save all it aliases name */ - while (*hp->h_aliases) - { - if (!wordinclass(*hp->h_aliases, 'w')) - { - setclass('w', *hp->h_aliases); - if (tTd(0, 4)) - printf("\ta.k.a.: %s\n", *hp->h_aliases); - } - hp->h_aliases++; - } + (void) add_hostnames(sa); } free(ifc.ifc_buf); close(s); @@ -4412,7 +4551,7 @@ sm_syslog(level, id, fmt, va_alist) extern int SyslogErrno; extern char *DoprEnd; VA_LOCAL_DECL - extern void sm_dopr __P((char *, const char *, ...)); + extern void sm_dopr __P((char *, const char *, va_list)); SyslogErrno = errno; if (id == NULL) diff --git a/contrib/sendmail/src/conf.h b/contrib/sendmail/src/conf.h index a8ad46e..b9cdc68 100644 --- a/contrib/sendmail/src/conf.h +++ b/contrib/sendmail/src/conf.h @@ -9,7 +9,7 @@ * the sendmail distribution. * * - * @(#)conf.h 8.372 (Berkeley) 6/4/98 + * @(#)conf.h 8.380 (Berkeley) 11/9/1998 */ /* @@ -64,6 +64,11 @@ struct rusage; /* forward declaration to get gcc to shut up in wait.h */ # define MACBUFSIZE 4096 /* max expanded macro buffer size */ # define TOBUFSIZE 512 /* max buffer to hold address list */ # define MAXSHORTSTR 203 /* max short string length */ +# if _FFR_MAX_MIME_HEADER_LENGTH +# define MAXMACNAMELEN 25 /* max macro name length */ +# else +# define MAXMACNAMELEN 20 /* max macro name length */ +# endif /********************************************************************** ** Compilation options. @@ -344,12 +349,12 @@ typedef int pid_t; # define GIDSET_T gid_t # define SFS_TYPE SFS_4ARGS /* four argument statfs() call */ # define SFS_BAVAIL f_bfree /* alternate field name */ +# define SYSLOG_BUFSIZE 512 # ifdef IRIX6 # define STAT64 1 # define QUAD_T unsigned long long # define LA_TYPE LA_IRIX6 /* figure out at run time */ # define SAFENFSPATHCONF 0 /* pathconf(2) lies on NFS filesystems */ -# define SYSLOG_BUFSIZE 512 # else # define LA_TYPE LA_INT @@ -674,6 +679,41 @@ typedef int pid_t; #endif +/* +** Apple Rhapsody +** Contributed by Wilfredo Sanchez <wsanchez@apple.com> +*/ + +#ifdef __APPLE__ +# define HASFCHMOD 1 /* has fchmod(2) syscall */ +# define HASFLOCK 1 /* has flock(2) syscall */ +# define HASUNAME 1 /* has uname(2) syscall */ +# define HASUNSETENV 1 +# define HASSETSID 1 /* has the setsid(2) POSIX syscall */ +# define HASINITGROUPS 1 +# define HASSETVBUF 1 +# define HASSETREUID 1 +# define USESETEUID 1 /* has useable seteuid(2) call */ +# define HASLSTAT 1 +# define HASSETRLIMIT 1 +# define HASWAITPID 1 +# define HASSTRERROR 1 /* has strerror(3) */ +# define HASSNPRINTF 1 /* has snprintf(3) and vsnprintf(3) */ +# define USESTRERROR 1 /* has strerror(3) */ +# define HASGETDTABLESIZE 1 +# define HASGETUSERSHELL 1 +# define NEEDGETOPT 1 /* need a replacement for getopt(3) */ +# define BSD4_4_SOCKADDR /* has sa_len */ +# define NETLINK 1 /* supports AF_LINK */ +# define HAS_ST_GEN 1 /* has st_gen field in stat struct */ +# define GIDSET_T gid_t +# define LA_TYPE LA_SUBR /* use getloadavg(3) */ +# define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */ +# define SPT_TYPE SPT_PSSTRINGS +# define SPT_PADCHAR '\0' /* pad process title with nulls */ +# define ERRLIST_PREDEFINED /* don't declare sys_errlist */ +#endif + /* ** 4.4 BSD @@ -821,7 +861,7 @@ typedef int pid_t; # define SPT_TYPE SPT_BUILTIN # endif # if __FreeBSD_version >= 222000 /* 2.2.2-release and later */ -# define HASSETUSERCONTEXT 1 /* BSDI-style login classes */ +# define HASSETUSERCONTEXT 1 /* BSDI-style login classes */ # endif # endif # ifndef SPT_TYPE @@ -1219,9 +1259,9 @@ extern void *malloc(); ** Florian La Roche <rzsfl@rz.uni-sb.de> ** Karl London <karl@borg.demon.co.uk> ** -** Last compiled against: [06/10/96 @ 09:21:40 PM (Monday)] -** sendmail 8.8-a4 named bind-4.9.4-T4B db-1.85 -** gcc 2.7.2 libc-5.3.12 linux 2.0.0 +** Last compiled against: [07/21/98 @ 11:47:34 AM (Tuesday)] +** sendmail 8.9.1 bind-8.1.2 db-2.4.14 +** gcc-2.8.1 glibc-2.0.94 linux-2.1.109 ** ** NOTE: Override HASFLOCK as you will but, as of 1.99.6, mixed-style ** file locking is no longer allowed. In particular, make sure @@ -1231,6 +1271,7 @@ extern void *malloc(); #ifdef __linux__ # define BSD 1 /* include BSD defines */ +# define USESETEUID 0 /* Have it due to POSIX, but doesn't work */ # define NEEDGETOPT 1 /* need a replacement for getopt(3) */ # define HASUNAME 1 /* use System V uname(2) system call */ # define HASUNSETENV 1 /* has unsetenv(3) call */ @@ -1258,7 +1299,7 @@ extern void *malloc(); # ifndef _PATH_SENDMAILPID # define _PATH_SENDMAILPID "/var/run/sendmail.pid" # endif -# define TZ_TYPE TZ_TNAME +# define TZ_TYPE TZ_TZNAME # include <sys/sysmacros.h> # undef atol /* wounded in <stdlib.h> */ #endif @@ -1487,6 +1528,37 @@ typedef int pid_t; # endif #endif +/* +** System V Rel 5.x (a.k.a Unixware7 w/o BSD-Compatiblity Libs ie. native) +** +** Contributed by Paul Gampe <paulg@apnic.net> +*/ + +#ifdef __svr5__ +# include <sys/mkdev.h> +# define __svr4__ +# define SYS5SIGNALS 1 +# define HASSETSID 1 +# define HASSETREUID 1 +# define HASWAITPID 1 +# define HASGETDTABLESIZE 1 +# define GIDSET_T gid_t +# define SOCKADDR_LEN_T size_t +# define SOCKOPT_LEN_T size_t +# ifndef _PATH_UNIX +# define _PATH_UNIX "/stand/unix" +# endif +# define SPT_PADCHAR '\0' /* pad process title with nulls */ +# define SYSLOG_BUFSIZE 1024 /* unsure */ +# ifndef _PATH_VENDOR_CF +# define _PATH_VENDOR_CF "/etc/sendmail.cf" +# endif +# ifndef _PATH_SENDMAILPID +# define _PATH_SENDMAILPID "/etc/sendmail.pid" +# endif +#endif + +/* ###################################################################### */ /* ** UnixWare 2.x @@ -1519,7 +1591,9 @@ typedef int pid_t; # define LA_TYPE LA_ZERO # undef WIFEXITED # undef WEXITSTATUS -# define _PATH_UNIX "/unix" +# ifndef _PATH_UNIX +# define _PATH_UNIX "/unix" +# endif # ifndef _PATH_VENDOR_CF # define _PATH_VENDOR_CF "/usr/ucblib/sendmail.cf" # endif diff --git a/contrib/sendmail/src/err.c b/contrib/sendmail/src/err.c index a07d62d..38a3576 100644 --- a/contrib/sendmail/src/err.c +++ b/contrib/sendmail/src/err.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)err.c 8.74 (Berkeley) 6/4/98"; +static char sccsid[] = "@(#)err.c 8.74 (Berkeley) 6/4/1998"; #endif /* not lint */ # include "sendmail.h" diff --git a/contrib/sendmail/src/headers.c b/contrib/sendmail/src/headers.c index 91a4261..500e375 100644 --- a/contrib/sendmail/src/headers.c +++ b/contrib/sendmail/src/headers.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)headers.c 8.127 (Berkeley) 6/4/98"; +static char sccsid[] = "@(#)headers.c 8.134 (Berkeley) 11/29/1998"; #endif /* not lint */ # include <errno.h> @@ -521,8 +521,8 @@ eatheader(e, full) #if 0 /* - ** Change functionality so a fatal error on an - ** address doesn't affect the entire envelope. + ** Change functionality so a fatal error on an + ** address doesn't affect the entire envelope. */ /* delete fatal errors generated by this address */ @@ -1198,6 +1198,59 @@ putheader(mci, hdr, e) xputs(p); } +#if _FFR_MAX_MIME_HEADER_LENGTH + /* heuristic shortening of MIME fields to avoid MUA overflows */ + if (MaxMimeFieldLength > 0 && + wordinclass(h->h_field, + macid("{checkMIMEFieldHeaders}", NULL))) + { + extern bool fix_mime_header __P((char *)); + + if (fix_mime_header(h->h_value)) + { + sm_syslog(LOG_ALERT, e->e_id, + "Truncated MIME %s header due to field size (possible attack)", + h->h_field); + if (tTd(34, 11)) + printf(" truncated MIME %s header due to field size (possible attack)\n", + h->h_field); + } + } + + if (MaxMimeHeaderLength > 0 && + wordinclass(h->h_field, + macid("{checkMIMETextHeaders}", NULL))) + { + if (strlen(h->h_value) > MaxMimeHeaderLength) + { + h->h_value[MaxMimeHeaderLength - 1] = '\0'; + sm_syslog(LOG_ALERT, e->e_id, + "Truncated long MIME %s header (possible attack)", + h->h_field); + if (tTd(34, 11)) + printf(" truncated long MIME %s header (possible attack)\n", + h->h_field); + } + } + + if (MaxMimeHeaderLength > 0 && + wordinclass(h->h_field, + macid("{checkMIMEHeaders}", NULL))) + { + extern bool shorten_rfc822_string __P((char *, int)); + + if (shorten_rfc822_string(h->h_value, MaxMimeHeaderLength)) + { + sm_syslog(LOG_ALERT, e->e_id, + "Truncated long MIME %s header (possible attack)", + h->h_field); + if (tTd(34, 11)) + printf(" truncated long MIME %s header (possible attack)\n", + h->h_field); + } + } +#endif + /* suppress Content-Transfer-Encoding: if we are MIMEing */ if (bitset(H_CTE, h->h_flags) && bitset(MCIF_CVT8TO7|MCIF_CVT7TO8|MCIF_INMIME, mci->mci_flags)) @@ -1568,3 +1621,69 @@ copyheader(header) return ret; } +/* +** FIX_MIME_HEADER -- possibly truncate/rebalance parameters in a MIME header +** +** Run through all of the parameters of a MIME header and +** possibly truncate and rebalance the parameter according +** to MaxMimeFieldLength. +** +** Parameters: +** string -- the full header +** +** Returns: +** TRUE if the header was modified, FALSE otherwise +** +** Side Effects: +** string modified in place +*/ + +bool +fix_mime_header(string) + char *string; +{ + bool modified = FALSE; + char *begin = string; + char *end; + extern char *find_character __P((char *, char)); + extern bool shorten_rfc822_string __P((char *, int)); + + if (string == NULL || *string == '\0') + return FALSE; + + /* Split on each ';' */ + while ((end = find_character(begin, ';')) != NULL) + { + char save = *end; + char *bp; + + *end = '\0'; + + /* Shorten individual parameter */ + if (shorten_rfc822_string(begin, MaxMimeFieldLength)) + modified = TRUE; + + /* Collapse the possibly shortened string with rest */ + bp = begin + strlen(begin); + if (bp != end) + { + char *ep = end; + + *end = save; + end = bp; + + /* copy character by character due to overlap */ + while (*ep != '\0') + *bp++ = *ep++; + *bp = '\0'; + } + else + *end = save; + if (*end == '\0') + break; + + /* Move past ';' */ + begin = end + 1; + } + return modified; +} diff --git a/contrib/sendmail/src/mailq.1 b/contrib/sendmail/src/mailq.1 index ed6c0f6..bead1a2 100644 --- a/contrib/sendmail/src/mailq.1 +++ b/contrib/sendmail/src/mailq.1 @@ -8,7 +8,7 @@ .\" the sendmail distribution. .\" .\" -.\" @(#)mailq.1 8.10 (Berkeley) 5/19/98 +.\" @(#)mailq.1 8.10 (Berkeley) 5/19/1998 .\" .Dd May 19, 1998 .Dt MAILQ 1 diff --git a/contrib/sendmail/src/mci.c b/contrib/sendmail/src/mci.c index 9e1e3b6..8ebb7a0 100644 --- a/contrib/sendmail/src/mci.c +++ b/contrib/sendmail/src/mci.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)mci.c 8.82 (Berkeley) 6/15/98"; +static char sccsid[] = "@(#)mci.c 8.83 (Berkeley) 10/13/1998"; #endif /* not lint */ #include "sendmail.h" @@ -505,7 +505,7 @@ mci_dump_all(logit) mci_dump(MciCache[i], logit); } /* -** MCI_LOCK_HOST -- Lock host while sending. +** MCI_LOCK_HOST -- Lock host while sending. ** ** If we are contacting a host, we'll need to ** update the status information in the host status @@ -645,7 +645,7 @@ mci_unlock_host(mci) errno = saveErrno; } /* -** MCI_LOAD_PERSISTENT -- load persistent host info +** MCI_LOAD_PERSISTENT -- load persistent host info ** ** Load information about host that is kept ** in common for all running sendmails. @@ -1018,8 +1018,8 @@ mci_traverse_persistent(action, pathname) *hostptr = '\0'; /* - ** Do something with the file containing the persistent - ** information. + ** Do something with the file containing the persistent + ** information. */ ret = (*action)(pathname, host); } @@ -1169,7 +1169,7 @@ mci_purge_persistent(pathname, hostname) return 0; } /* -** MCI_GENERATE_PERSISTENT_PATH -- generate path from hostname +** MCI_GENERATE_PERSISTENT_PATH -- generate path from hostname ** ** Given `host', convert from a.b.c to $QueueDir/.hoststat/c./b./a, ** putting the result into `path'. if `createflag' is set, intervening diff --git a/contrib/sendmail/src/savemail.c b/contrib/sendmail/src/savemail.c index c7ae3d9..53e1a51 100644 --- a/contrib/sendmail/src/savemail.c +++ b/contrib/sendmail/src/savemail.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)savemail.c 8.138 (Berkeley) 6/17/98"; +static char sccsid[] = "@(#)savemail.c 8.139 (Berkeley) 8/5/1998"; #endif /* not lint */ # include "sendmail.h" @@ -91,8 +91,7 @@ savemail(e, sendbody) RF_COPYPARSE|RF_SENDERADDR, '\0', NULL, e) == NULL) { syserr("553 Cannot parse Postmaster!"); - ExitStat = EX_SOFTWARE; - finis(); + finis(TRUE, EX_SOFTWARE); } } e->e_to = NULL; diff --git a/contrib/sendmail/src/sendmail.8 b/contrib/sendmail/src/sendmail.8 index 7738e12..be31d2e 100644 --- a/contrib/sendmail/src/sendmail.8 +++ b/contrib/sendmail/src/sendmail.8 @@ -8,9 +8,9 @@ .\" the sendmail distribution. .\" .\" -.\" @(#)sendmail.8 8.19 (Berkeley) 5/19/98 +.\" @(#)sendmail.8 8.20 (Berkeley) 8/2/1998 .\" -.Dd May 19, 1998 +.Dd August 2, 1998 .Dt SENDMAIL 8 .Os BSD 4 .Sh NAME @@ -277,6 +277,9 @@ Log all traffic in and out of mailers in the indicated log file. This should only be used as a last resort for debugging mailer bugs. It will log a lot of data very quickly. +.It Fl - +Stop processing command flags and use the rest of the arguments +as addresses. .El .Ss Options There are also a number of processing options that may be set. |