diff options
author | peter <peter@FreeBSD.org> | 1999-01-12 12:26:57 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-01-12 12:26:57 +0000 |
commit | 2a7bd60222ce3c09208a265ad3a5f1490ccb6768 (patch) | |
tree | 8d45e99e5e320ab4e55408b355a04b2be475a0ed /contrib/sendmail/mail.local | |
parent | 329949050501501c130d09efc3aee7c78c6d4f9c (diff) | |
download | FreeBSD-src-2a7bd60222ce3c09208a265ad3a5f1490ccb6768.zip FreeBSD-src-2a7bd60222ce3c09208a265ad3a5f1490ccb6768.tar.gz |
Import sendmail-8.9.2 onto vendor branch (update from 8.9.1)
Obtained from: ftp.sendamil.org
Diffstat (limited to 'contrib/sendmail/mail.local')
-rw-r--r-- | contrib/sendmail/mail.local/Makefile.m4 | 6 | ||||
-rw-r--r-- | contrib/sendmail/mail.local/README | 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/mail.local/pathnames.h | 2 |
5 files changed, 63 insertions, 77 deletions
diff --git a/contrib/sendmail/mail.local/Makefile.m4 b/contrib/sendmail/mail.local/Makefile.m4 index 5dc1857..bf9a155e 100644 --- a/contrib/sendmail/mail.local/Makefile.m4 +++ b/contrib/sendmail/mail.local/Makefile.m4 @@ -1,7 +1,7 @@ # # This Makefile is designed to work on the old "make" program. # -# @(#)Makefile.m4 8.21 (Berkeley) 6/4/98 +# @(#)Makefile.m4 8.22 (Berkeley) 7/12/1998 # # C compiler @@ -34,7 +34,7 @@ LIBDIRS=confLIBDIRS LIBS= ifdef(`confLIBS', `confLIBS') # location of mail.local binary (usually /usr/sbin or /usr/etc) -BINDIR= ${DESTDIR}ifdef(`confEBINDIR', `confEBINDIR', `/usr/libexec') +EBINDIR=${DESTDIR}ifdef(`confEBINDIR', `confEBINDIR', `/usr/libexec') # additional .o files needed OBJADD= ifdef(`confOBJADD', `confOBJADD') @@ -91,7 +91,7 @@ install: force-install: install-mail.local install-docs install-mail.local: mail.local - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} mail.local ${BINDIR} + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} mail.local ${EBINDIR} install-docs: mail.local.${MAN8SRC} ifdef(`confNO_MAN_INSTALL', `dnl', diff --git a/contrib/sendmail/mail.local/README b/contrib/sendmail/mail.local/README index a205068..5da44bbf 100644 --- a/contrib/sendmail/mail.local/README +++ b/contrib/sendmail/mail.local/README @@ -1,4 +1,4 @@ -# @(#)README 8.1 (Berkeley) 2/17/98 +# @(#)README 8.1 (Berkeley) 2/17/1998 This directory contains the source files for mail.local. diff --git a/contrib/sendmail/mail.local/mail.local.8 b/contrib/sendmail/mail.local/mail.local.8 index e872fbe..05f11ed 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 a0f176f..abe1a19 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 *)); void e_to_sys __P((int)); -__dead void err __P((const char *, ...)); 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 *, ...)); @@ -266,7 +268,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; @@ -336,7 +338,7 @@ parseaddr(s) return NULL; } else { while ((isascii(*p) && isalnum(*p)) || - *p == '.' || *p == '-') + strchr(".-_", *p)) p++; } if (*p == ',' && p[1] == '@') @@ -347,6 +349,8 @@ parseaddr(s) return NULL; } + s = p; + /* local-part */ if (*p == '\"') { p++; @@ -386,7 +390,7 @@ parseaddr(s) return NULL; } else { while ((isascii(*p) && isalnum(*p)) || - *p == '.' || *p == '-') + strchr(".-_", *p)) p++; } } @@ -396,6 +400,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) { @@ -581,7 +590,7 @@ store(from, lmtprcpts) char *from; int lmtprcpts; { - FILE *fp; + FILE *fp = NULL; time_t tval; int fd, eline; char line[2048]; @@ -593,8 +602,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); @@ -609,13 +618,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; @@ -634,8 +651,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); } } } @@ -662,8 +681,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); @@ -697,7 +717,13 @@ deliver(fd, name) } } 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; } @@ -752,7 +778,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 @@ -791,7 +818,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; } @@ -842,9 +870,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()); @@ -947,7 +978,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; @@ -955,20 +985,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 [-l] [-f from] user ..."); + mailerr(NULL, "usage: mail.local [-l] [-f from] user ..."); + exit(eval); } void @@ -990,7 +1018,8 @@ mailerr(hdr, fmt, va_alist) #endif if (lmtpmode) { - printf("%s ", hdr); + if (hdr != NULL) + printf("%s ", hdr); vprintf(fmt, ap); printf("\r\n"); } @@ -1001,49 +1030,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/mail.local/pathnames.h b/contrib/sendmail/mail.local/pathnames.h index 5ec0068..33d949e 100644 --- a/contrib/sendmail/mail.local/pathnames.h +++ b/contrib/sendmail/mail.local/pathnames.h @@ -8,7 +8,7 @@ * the sendmail distribution. * * - * @(#)pathnames.h 8.5 (Berkeley) 5/19/98 + * @(#)pathnames.h 8.5 (Berkeley) 5/19/1998 */ #include <paths.h> |