aboutsummaryrefslogtreecommitdiff
path: root/contrib/sendmail/mail.local
diff options
context:
space:
mode:
authorGregory Neil Shapiro <gshapiro@FreeBSD.org>2001-02-28 00:22:47 +0000
committerGregory Neil Shapiro <gshapiro@FreeBSD.org>2001-02-28 00:22:47 +0000
commitb4662009523ec096fb4069a551374975ae205613 (patch)
treea28ee62536093230ce58a5604116f537c8d57f8f /contrib/sendmail/mail.local
parent1ed4a948e1e90356ea79bab18495d577540c7165 (diff)
downloadsrc-b4662009523ec096fb4069a551374975ae205613.tar.gz
src-b4662009523ec096fb4069a551374975ae205613.zip
Repair 8.11.3 merge conflicts
Notes
Notes: svn path=/head/; revision=73191
Diffstat (limited to 'contrib/sendmail/mail.local')
-rw-r--r--contrib/sendmail/mail.local/mail.local.c374
1 files changed, 178 insertions, 196 deletions
diff --git a/contrib/sendmail/mail.local/mail.local.c b/contrib/sendmail/mail.local/mail.local.c
index 6a7b5bf91999..4729c548a406 100644
--- a/contrib/sendmail/mail.local/mail.local.c
+++ b/contrib/sendmail/mail.local/mail.local.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -12,14 +12,14 @@
#ifndef lint
static char copyright[] =
-"@(#) Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.\n\
+"@(#) Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.\n\
All rights reserved.\n\
Copyright (c) 1990, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* ! lint */
#ifndef lint
-static char id[] = "@(#)$Id: mail.local.c,v 8.143.4.39 2000/11/14 20:02:47 gshapiro Exp $";
+static char id[] = "@(#)$Id: mail.local.c,v 8.143.4.57 2001/02/11 20:08:20 gshapiro Exp $";
#endif /* ! lint */
/* $FreeBSD$ */
@@ -108,37 +108,25 @@ extern size_t strlcat __P((char *, const char *, size_t));
# if defined(_AIX)
# define USE_LOCKF 1
# define USE_SETEUID 1
-# define USE_VSYSLOG 0
# endif /* defined(_AIX) */
# if defined(__hpux)
# define USE_LOCKF 1
# define USE_SETRESUID 1
-# define USE_VSYSLOG 0
# endif /* defined(__hpux) */
# ifdef DGUX
# define HASSNPRINTF 1
# define USE_LOCKF 1
-# define USE_VSYSLOG 0
# endif /* DGUX */
# if defined(_CRAY)
# if !defined(MAXPATHLEN)
# define MAXPATHLEN PATHSIZE
# endif /* !defined(MAXPATHLEN) */
-# define USE_VSYSLOG 0
# define _PATH_MAILDIR "/usr/spool/mail"
# endif /* defined(_CRAY) */
-# if defined(ultrix)
-# define USE_VSYSLOG 0
-# endif /* defined(ultrix) */
-
-# if defined(__osf__)
-# define USE_VSYSLOG 0
-# endif /* defined(__osf__) */
-
# if defined(NeXT) && !defined(__APPLE__)
# include <libc.h>
# define _PATH_MAILDIR "/usr/spool/mail"
@@ -162,10 +150,6 @@ extern size_t strlcat __P((char *, const char *, size_t));
# define LOCK_EX F_LOCK
# endif /* USE_LOCKF */
-# ifndef USE_VSYSLOG
-# define USE_VSYSLOG 1
-# endif /* ! USE_VSYSLOG */
-
# ifndef LOCK_EX
# include <sys/file.h>
# endif /* ! LOCK_EX */
@@ -207,18 +191,19 @@ extern FILE *fdopen __P((int, const char *));
# define HASSNPRINTF 1 /* has snprintf starting in 4.3 */
# endif /* _AIX4 >= 40300 */
-# if !HASSNPRINTF
+# if !HASSNPRINTF && !SFIO
extern int snprintf __P((char *, size_t, const char *, ...));
# ifndef _CRAY
extern int vsnprintf __P((char *, size_t, const char *, ...));
# endif /* ! _CRAY */
-# endif /* !HASSNPRINTF */
+# endif /* !HASSNPRINTF && !SFIO */
/*
** If you don't have setreuid, and you have saved uids, and you have
** a seteuid() call that doesn't try to emulate using setuid(), then
** you can try defining USE_SETEUID.
*/
+
# ifdef USE_SETEUID
# define setreuid(r, e) seteuid(e)
# endif /* USE_SETEUID */
@@ -226,6 +211,7 @@ extern int vsnprintf __P((char *, size_t, const char *, ...));
/*
** And of course on hpux you have setresuid()
*/
+
# ifdef USE_SETRESUID
# define setreuid(r, e) setresuid(-1, e, -1)
# endif /* USE_SETRESUID */
@@ -263,21 +249,23 @@ off_t BodyLength;
#endif /* CONTENTLENGTH */
bool EightBitMime = TRUE; /* advertise 8BITMIME in LMTP */
+char ErrBuf[10240]; /* error buffer */
int ExitVal = EX_OK; /* sysexits.h error value. */
+bool HoldErrs = FALSE; /* Hold errors in ErrBuf */
bool LMTPMode = FALSE;
-bool bouncequota = FALSE; /* permanent error when over quota */
+bool BounceQuota = FALSE; /* permanent error when over quota */
bool nobiff = FALSE;
bool nofsync = FALSE;
-void deliver __P((int, char *, bool));
+void deliver __P((int, char *));
int e_to_sys __P((int));
void notifybiff __P((char *));
-int store __P((char *, int));
+int store __P((char *, int, bool *));
void usage __P((void));
-void vwarn __P((const char *, _BSD_VA_LIST_));
int lockmbox __P((char *));
void unlockmbox __P((void));
void mailerr __P((const char *, const char *, ...));
+void flush_error __P((void));
int
@@ -291,7 +279,6 @@ main(argc, argv)
char *from;
extern char *optarg;
extern int optind;
- extern void dolmtp __P((bool));
/* make sure we have some open file descriptors */
@@ -321,7 +308,7 @@ main(argc, argv)
break;
case 'b': /* bounce mail when over quota. */
- bouncequota = TRUE;
+ BounceQuota = TRUE;
break;
case 'd': /* Backward compatible. */
@@ -331,7 +318,7 @@ main(argc, argv)
case 'r': /* Backward compatible. */
if (from != NULL)
{
- mailerr(NULL, "multiple -f options");
+ mailerr(NULL, "Multiple -f options");
usage();
}
from = optarg;
@@ -358,8 +345,21 @@ main(argc, argv)
notifybiff(NULL);
if (LMTPMode)
- dolmtp(bouncequota);
+ {
+ extern void dolmtp __P((void));
+ if (argc > 0)
+ {
+ mailerr("421", "Users should not be specified in command line if LMTP required");
+ exit(EX_TEMPFAIL);
+ }
+
+ dolmtp();
+ /* NOTREACHED */
+ exit(EX_OK);
+ }
+
+ /* Non-LMTP from here on out */
if (*argv == '\0')
usage();
@@ -368,6 +368,7 @@ main(argc, argv)
** uid matches, otherwise, use the name from the password file
** corresponding to the uid.
*/
+
uid = getuid();
if (from == NULL && ((from = getlogin()) == NULL ||
@@ -384,8 +385,17 @@ main(argc, argv)
** failures. This results in the delivery being reattempted later
** at the expense of repeated failures and multiple deliveries.
*/
- for (fd = store(from, 0); *argv; ++argv)
- deliver(fd, *argv, bouncequota);
+
+ HoldErrs = TRUE;
+ fd = store(from, 0, NULL);
+ HoldErrs = FALSE;
+ if (fd < 0)
+ {
+ flush_error();
+ exit(ExitVal);
+ }
+ for (; *argv != NULL; ++argv)
+ deliver(fd, *argv);
exit(ExitVal);
/* NOTREACHED */
return ExitVal;
@@ -473,7 +483,7 @@ parseaddr(s, rcpt)
p = malloc(l);
if (p == NULL)
{
- printf("421 4.3.0 memory exhausted\r\n");
+ mailerr("421 4.3.0", "Memory exhausted");
exit(EX_TEMPFAIL);
}
@@ -486,15 +496,14 @@ process_recipient(addr)
char *addr;
{
if (getpwnam(addr) == NULL)
- return "550 5.1.1 user unknown";
+ return "550 5.1.1 User unknown";
return NULL;
}
#define RCPT_GROW 30
void
-dolmtp(bouncequota)
- bool bouncequota;
+dolmtp()
{
char *return_path = NULL;
char **rcpt_addr = NULL;
@@ -508,7 +517,10 @@ dolmtp(bouncequota)
char myhostname[1024];
char buf[4096];
+ memset(myhostname, '\0', sizeof myhostname);
(void) gethostname(myhostname, sizeof myhostname - 1);
+ if (myhostname[0] == '\0')
+ strlcpy(myhostname, "localhost", sizeof myhostname);
printf("220 %s LMTP ready\r\n", myhostname);
for (;;)
@@ -528,24 +540,37 @@ dolmtp(bouncequota)
case 'D':
if (strcasecmp(buf, "data") == 0)
{
+ bool inbody = FALSE;
+
if (rcpt_num == 0)
{
- printf("503 5.5.1 No recipients\r\n");
+ mailerr("503 5.5.1", "No recipients");
continue;
}
- msgfd = store(return_path, rcpt_num);
- if (msgfd == -1)
+ HoldErrs = TRUE;
+ msgfd = store(return_path, rcpt_num, &inbody);
+ HoldErrs = FALSE;
+ if (msgfd < 0 && !inbody)
+ {
+ flush_error();
continue;
+ }
for (i = 0; i < rcpt_num; i++)
{
+ if (msgfd < 0)
+ {
+ /* print error for rcpt */
+ flush_error();
+ continue;
+ }
p = strchr(rcpt_addr[i], '+');
if (p != NULL)
- *p++ = '\0';
- deliver(msgfd, rcpt_addr[i],
- bouncequota);
+ *p = '\0';
+ deliver(msgfd, rcpt_addr[i]);
}
- (void) close(msgfd);
+ if (msgfd >= 0)
+ (void) close(msgfd);
goto rset;
}
goto syntaxerr;
@@ -559,7 +584,7 @@ dolmtp(bouncequota)
/* check for duplicate per RFC 1651 4.2 */
if (gotlhlo)
{
- printf("503 %s Duplicate LHLO\r\n",
+ mailerr("503", "%s Duplicate LHLO",
myhostname);
continue;
}
@@ -581,17 +606,19 @@ dolmtp(bouncequota)
{
if (return_path != NULL)
{
- printf("503 5.5.1 Nested MAIL command\r\n");
+ mailerr("503 5.5.1",
+ "Nested MAIL command");
continue;
}
if (strncasecmp(buf+5, "from:", 5) != 0 ||
((return_path = parseaddr(buf + 10,
FALSE)) == NULL))
{
- printf("501 5.5.4 Syntax error in parameters\r\n");
+ mailerr("501 5.5.4",
+ "Syntax error in parameters");
continue;
}
- printf("250 2.5.0 ok\r\n");
+ printf("250 2.5.0 Ok\r\n");
continue;
}
goto syntaxerr;
@@ -602,7 +629,7 @@ dolmtp(bouncequota)
case 'N':
if (strcasecmp(buf, "noop") == 0)
{
- printf("250 2.0.0 ok\r\n");
+ printf("250 2.0.0 Ok\r\n");
continue;
}
goto syntaxerr;
@@ -613,7 +640,7 @@ dolmtp(bouncequota)
case 'Q':
if (strcasecmp(buf, "quit") == 0)
{
- printf("221 2.0.0 bye\r\n");
+ printf("221 2.0.0 Bye\r\n");
exit(EX_OK);
}
goto syntaxerr;
@@ -626,7 +653,8 @@ dolmtp(bouncequota)
{
if (return_path == NULL)
{
- printf("503 5.5.1 Need MAIL command\r\n");
+ mailerr("503 5.5.1",
+ "Need MAIL command");
continue;
}
if (rcpt_num >= rcpt_alloc)
@@ -638,7 +666,8 @@ dolmtp(bouncequota)
sizeof(char **));
if (rcpt_addr == NULL)
{
- printf("421 4.3.0 memory exhausted\r\n");
+ mailerr("421 4.3.0",
+ "Memory exhausted");
exit(EX_TEMPFAIL);
}
}
@@ -646,21 +675,23 @@ dolmtp(bouncequota)
((rcpt_addr[rcpt_num] = parseaddr(buf + 8,
TRUE)) == NULL))
{
- printf("501 5.5.4 Syntax error in parameters\r\n");
+ mailerr("501 5.5.4",
+ "Syntax error in parameters");
continue;
}
- if ((err = process_recipient(rcpt_addr[rcpt_num])) != NULL)
+ err = process_recipient(rcpt_addr[rcpt_num]);
+ if (err != NULL)
{
- printf("%s\r\n", err);
+ mailerr(NULL, "%s", err);
continue;
}
rcpt_num++;
- printf("250 2.1.5 ok\r\n");
+ printf("250 2.1.5 Ok\r\n");
continue;
}
else if (strcasecmp(buf, "rset") == 0)
{
- printf("250 2.0.0 ok\r\n");
+ printf("250 2.0.0 Ok\r\n");
rset:
while (rcpt_num > 0)
@@ -678,7 +709,7 @@ rset:
case 'V':
if (strncasecmp(buf, "vrfy ", 5) == 0)
{
- printf("252 2.3.3 try RCPT to attempt delivery\r\n");
+ printf("252 2.3.3 Try RCPT to attempt delivery\r\n");
continue;
}
goto syntaxerr;
@@ -687,7 +718,7 @@ rset:
default:
syntaxerr:
- printf("500 5.5.2 Syntax error\r\n");
+ mailerr("500 5.5.2", "Syntax error");
continue;
/* NOTREACHED */
break;
@@ -696,9 +727,10 @@ rset:
}
int
-store(from, lmtprcpts)
+store(from, lmtprcpts, inbody)
char *from;
int lmtprcpts;
+ bool *inbody;
{
FILE *fp = NULL;
time_t tval;
@@ -709,28 +741,25 @@ store(from, lmtprcpts)
int fd;
char tmpbuf[sizeof _PATH_LOCTMP + 1];
+ if (inbody != NULL)
+ *inbody = FALSE;
+
(void) umask(0077);
(void) strlcpy(tmpbuf, _PATH_LOCTMP, sizeof tmpbuf);
- if ((fd = mkstemp(tmpbuf)) == -1 || (fp = fdopen(fd, "w+")) == NULL)
+ if ((fd = mkstemp(tmpbuf)) < 0 || (fp = fdopen(fd, "w+")) == NULL)
{
- if (lmtprcpts)
- {
- printf("451 4.3.0 unable to open temporary file\r\n");
- return -1;
- }
- else
- {
- mailerr("451 4.3.0", "unable to open temporary file");
- exit(ExitVal);
- }
+ mailerr("451 4.3.0", "Unable to open temporary file");
+ return -1;
}
(void) unlink(tmpbuf);
if (LMTPMode)
{
- printf("354 go ahead\r\n");
+ printf("354 Go ahead\r\n");
(void) fflush(stdout);
}
+ if (inbody != NULL)
+ *inbody = TRUE;
(void) time(&tval);
(void) fprintf(fp, "From %s %s", from, ctime(&tval));
@@ -742,7 +771,7 @@ store(from, lmtprcpts)
line[0] = '\0';
eline = TRUE;
- while (fgets(line, sizeof(line), stdin) != (char *)NULL)
+ while (fgets(line, sizeof(line), stdin) != (char *) NULL)
{
size_t line_len = 0;
int peek;
@@ -753,7 +782,7 @@ store(from, lmtprcpts)
line_len++;
/* Check for dot-stuffing */
- if (prevfl && lmtprcpts && line[0] == '.')
+ if (prevfl && LMTPMode && line[0] == '.')
{
if (line[1] == '\n' ||
(line[1] == '\r' && line[2] == '\n'))
@@ -797,7 +826,8 @@ store(from, lmtprcpts)
if (prevfl && line[0] == '\n' && HeaderLength == 0)
{
eline = FALSE;
- HeaderLength = ftell(fp);
+ if (fp != NULL)
+ HeaderLength = ftell(fp);
if (HeaderLength <= 0)
{
/*
@@ -815,6 +845,7 @@ store(from, lmtprcpts)
else
{
if (eline && line[0] == 'F' &&
+ fp != NULL &&
!memcmp(line, "From ", 5))
(void) putc('>', fp);
eline = FALSE;
@@ -834,40 +865,39 @@ store(from, lmtprcpts)
#endif /* CONTENTLENGTH */
}
- (void) fwrite(line, sizeof(char), line_len, fp);
- if (ferror(fp))
+ if (fp != NULL)
{
- if (lmtprcpts)
- {
- while (lmtprcpts--)
- printf("451 4.3.0 temporary file write error\r\n");
- (void) fclose(fp);
- return -1;
- }
- else
+ (void) fwrite(line, sizeof(char), line_len, fp);
+ if (ferror(fp))
{
mailerr("451 4.3.0",
- "temporary file write error");
+ "Temporary file write error");
(void) fclose(fp);
- exit(ExitVal);
+ fp = NULL;
+ continue;
}
}
}
- if (lmtprcpts)
+ /* check if an error occurred */
+ if (fp == NULL)
+ return -1;
+
+ if (LMTPMode)
{
/* Got a premature EOF -- toss message and exit */
exit(EX_OK);
}
/* If message not newline terminated, need an extra. */
- if (strchr(line, '\n') == NULL)
+ if (fp != NULL && strchr(line, '\n') == NULL)
(void) putc('\n', fp);
lmtpdot:
#ifdef CONTENTLENGTH
- BodyLength = ftell(fp);
+ if (fp != NULL)
+ BodyLength = ftell(fp);
if (HeaderLength == 0 && BodyLength > 0) /* empty body */
{
HeaderLength = BodyLength;
@@ -893,32 +923,23 @@ store(from, lmtprcpts)
#endif /* CONTENTLENGTH */
/* Output a newline; note, empty messages are allowed. */
- (void) putc('\n', fp);
+ if (fp != NULL)
+ (void) putc('\n', fp);
- if (fflush(fp) == EOF || ferror(fp) != 0)
+ if (fp == NULL || fflush(fp) == EOF || ferror(fp) != 0)
{
- if (lmtprcpts)
- {
- while (lmtprcpts--)
- printf("451 4.3.0 temporary file write error\r\n");
- (void) fclose(fp);
- return -1;
- }
- else
- {
- mailerr("451 4.3.0", "temporary file write error");
+ mailerr("451 4.3.0", "Temporary file write error");
+ if (fp != NULL)
(void) fclose(fp);
- exit(ExitVal);
- }
+ return -1;
}
return fd;
}
void
-deliver(fd, name, bouncequota)
+deliver(fd, name)
int fd;
char *name;
- bool bouncequota;
{
struct stat fsb;
struct stat sb;
@@ -926,6 +947,7 @@ deliver(fd, name, bouncequota)
char path[MAXPATHLEN];
int mbfd = -1, nr = 0, nw, off;
char *p;
+ char *errcode;
off_t curoff;
#ifdef CONTENTLENGTH
off_t headerbytes;
@@ -939,28 +961,17 @@ deliver(fd, name, bouncequota)
** Disallow delivery to unknown names -- special mailboxes can be
** handled in the sendmail aliases file.
*/
+
if ((pw = getpwnam(name)) == NULL)
{
- if (ExitVal != EX_TEMPFAIL)
- ExitVal = EX_UNAVAILABLE;
- if (LMTPMode)
- {
- if (ExitVal == EX_TEMPFAIL)
- printf("451 4.3.0 cannot lookup name: %s\r\n",
- name);
- else
- printf("550 5.1.1 unknown name: %s\r\n", name);
- }
+ if (ExitVal == EX_TEMPFAIL)
+ errcode = "451 4.3.0";
else
{
- char *errcode = NULL;
-
- if (ExitVal == EX_TEMPFAIL)
- errcode = "451 4.3.0";
- else
- errcode = "550 5.1.1";
- mailerr(errcode, "unknown name: %s", name);
+ ExitVal = EX_UNAVAILABLE;
+ errcode = "550 5.1.1";
}
+ mailerr(errcode, "Unknown name: %s", name);
return;
}
endpwent();
@@ -1020,16 +1031,13 @@ tryagain:
if (off == EX_TEMPFAIL || e_to_sys(off) == EX_TEMPFAIL)
{
ExitVal = EX_TEMPFAIL;
- mailerr("451 4.3.0",
- "lockmailbox %s failed; error code %d %s",
- p, off, errno > 0 ? errstring(errno) : "");
+ errcode = "451 4.3.0";
}
else
- {
- mailerr("551 5.3.0",
- "lockmailbox %s failed; error code %d %s",
- p, off, errno > 0 ? errstring(errno) : "");
- }
+ errcode = "551 5.3.0";
+
+ mailerr(errcode, "lockmailbox %s failed; error code %d %s",
+ p, off, errno > 0 ? errstring(errno) : "");
return;
}
@@ -1056,7 +1064,7 @@ tryagain:
"%s: lstat: file changed after open", path);
goto err1;
}
- if (mbfd == -1)
+ if (mbfd < 0)
{
if (save_errno == EEXIST)
goto tryagain;
@@ -1143,7 +1151,7 @@ tryagain:
if (!nobiff)
{
/* Get the starting offset of the new message for biff. */
- curoff = lseek(mbfd, (off_t)0, SEEK_END);
+ curoff = lseek(mbfd, (off_t) 0, SEEK_END);
if (sizeof curoff > sizeof(long))
(void) snprintf(biffmsg, sizeof(biffmsg), "%s@%s\n",
name, quad_to_string(curoff));
@@ -1153,9 +1161,9 @@ tryagain:
}
/* Copy the message into the file. */
- if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1)
+ if (lseek(fd, (off_t) 0, SEEK_SET) == (off_t) -1)
{
- mailerr("450 4.2.0", "temporary file: %s",
+ mailerr("450 4.2.0", "Temporary file: %s",
errstring(errno));
goto err1;
}
@@ -1192,13 +1200,12 @@ tryagain:
{
if ((nw = write(mbfd, buf + off, nr - off)) < 0)
{
+ errcode = "450 4.2.0";
#ifdef EDQUOT
- if (errno == EDQUOT && bouncequota)
- mailerr("552 5.2.2", "%s: %s",
- path, errstring(errno));
- else
+ if (errno == EDQUOT && BounceQuota)
+ errcode = "552 5.2.2";
#endif /* EDQUOT */
- mailerr("450 4.2.0", "%s: %s",
+ mailerr(errcode, "%s: %s",
path, errstring(errno));
goto err3;
}
@@ -1206,7 +1213,7 @@ tryagain:
}
if (nr < 0)
{
- mailerr("450 4.2.0", "temporary file: %s",
+ mailerr("450 4.2.0", "Temporary file: %s",
errstring(errno));
goto err3;
}
@@ -1216,15 +1223,7 @@ tryagain:
{
mailerr("450 4.2.0", "%s: %s", path, errstring(errno));
err3:
- if (setreuid(0, 0) < 0)
- {
-#if 0
- /* already printed an error above for this recipient */
- (void) e_to_sys(errno);
- mailerr("450 4.2.0", "setreuid(0, 0): %s",
- errstring(errno));
-#endif /* 0 */
- }
+ (void) setreuid(0, 0);
#ifdef DEBUG
fprintf(stderr, "reset euid = %d\n", geteuid());
#endif /* DEBUG */
@@ -1238,12 +1237,12 @@ err0: unlockmbox();
/* Close and check -- NFS doesn't write until the close. */
if (close(mbfd))
{
+ errcode = "450 4.2.0";
#ifdef EDQUOT
- if (errno == EDQUOT && bouncequota)
- mailerr("552 5.2.2", "%s: %s", path, errstring(errno));
- else
+ if (errno == EDQUOT && BounceQuota)
+ errcode = "552 5.2.2";
#endif /* EDQUOT */
- mailerr("450 4.2.0", "%s: %s", path, errstring(errno));
+ mailerr(errcode, "%s: %s", path, errstring(errno));
(void) truncate(path, curoff);
}
else if (!nobiff)
@@ -1260,7 +1259,7 @@ err0: unlockmbox();
#endif /* DEBUG */
unlockmbox();
if (LMTPMode)
- printf("250 2.1.5 %s OK\r\n", name);
+ printf("250 2.1.5 %s Ok\r\n", name);
}
/*
@@ -1415,7 +1414,7 @@ notifybiff(msg)
if (addr.sin_family == AF_UNSPEC)
return;
- if (f < 0 && (f = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+ if (f < 0 && (f = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
return;
len = strlen(msg) + 1;
(void) sendto(f, msg, len, 0, (struct sockaddr *) &addr, sizeof(addr));
@@ -1439,61 +1438,53 @@ mailerr(hdr, fmt, va_alist)
va_dcl
#endif /* __STDC__ */
{
+ size_t len = 0;
va_list ap;
+ (void) e_to_sys(errno);
+
#ifdef __STDC__
va_start(ap, fmt);
#else /* __STDC__ */
va_start(ap);
#endif /* __STDC__ */
+
if (LMTPMode)
{
if (hdr != NULL)
- printf("%s ", hdr);
- (void) vprintf(fmt, ap);
- (void) printf("\r\n");
- }
- else
- {
- (void) e_to_sys(errno);
- vwarn(fmt, ap);
+ {
+ snprintf(ErrBuf, sizeof ErrBuf, "%s ", hdr);
+ len = strlen(ErrBuf);
+ }
}
+ (void) vsnprintf(&ErrBuf[len], sizeof ErrBuf - len, fmt, ap);
+
+ if (!HoldErrs)
+ flush_error();
+
+ /* Log the message to syslog. */
+ if (!LMTPMode)
+ syslog(LOG_ERR, "%s", ErrBuf);
}
void
-vwarn(fmt, ap)
- const char *fmt;
- _BSD_VA_LIST_ ap;
+flush_error()
{
- /*
- ** Log the message to stderr.
- **
- ** Don't use LOG_PERROR as an openlog() flag to do this,
- ** it's not portable enough.
- */
-
- if (ExitVal != EX_USAGE)
- (void) fprintf(stderr, "mail.local: ");
- (void) vfprintf(stderr, fmt, ap);
- (void) fprintf(stderr, "\n");
-
-#if USE_VSYSLOG
- /* Log the message to syslog. */
- vsyslog(LOG_ERR, fmt, ap);
-#else /* USE_VSYSLOG */
+ if (LMTPMode)
+ printf("%s\r\n", ErrBuf);
+ else
{
- char fmtbuf[10240];
-
- (void) vsnprintf(fmtbuf, sizeof fmtbuf, fmt, ap);
- syslog(LOG_ERR, "%s", fmtbuf);
+ if (ExitVal != EX_USAGE)
+ (void) fprintf(stderr, "mail.local: ");
+ fprintf(stderr, "%s\n", ErrBuf);
}
-#endif /* USE_VSYSLOG */
}
/*
* e_to_sys --
* Guess which errno's are temporary. Gag me.
*/
+
int
e_to_sys(num)
int num;
@@ -1506,7 +1497,7 @@ e_to_sys(num)
{
#ifdef EDQUOT
case EDQUOT: /* Disc quota exceeded */
- if (bouncequota)
+ if (BounceQuota)
{
ExitVal = EX_UNAVAILABLE;
break;
@@ -1647,15 +1638,6 @@ mkstemp(path)
return (_gettemp(path, &fd) ? fd : -1);
}
-# if 0
-char *
-mktemp(path)
- char *path;
-{
- return(_gettemp(path, (int *)NULL) ? path : (char *)NULL);
-}
-# endif /* 0 */
-
static
_gettemp(path, doopen)
char *path;