summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/mail.local
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-01-12 12:38:06 +0000
committerpeter <peter@FreeBSD.org>1999-01-12 12:38:06 +0000
commit5b758ef6d89ac3abe22adbdc3386c76d72691136 (patch)
tree6c4f3826ab567145a7eba959bc71c7eab01748b1 /contrib/sendmail/mail.local
parent6788eff0e6370de72568309d3a8b1891341b0991 (diff)
downloadFreeBSD-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.
Diffstat (limited to 'contrib/sendmail/mail.local')
-rw-r--r--contrib/sendmail/mail.local/mail.local.82
-rw-r--r--contrib/sendmail/mail.local/mail.local.c128
2 files changed, 58 insertions, 72 deletions
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;
OpenPOWER on IntegriCloud