diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2005-02-14 02:30:00 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2005-02-14 02:30:00 +0000 |
commit | 9883351c45502bc6aec878ba11d8ef5fe1843397 (patch) | |
tree | d9cfa9f19110fa167a0fec9f07c6fcfacd77aafb /contrib/sendmail/mail.local | |
parent | 1fc446a819a244515d9461fa50d34ee191414d6f (diff) | |
download | FreeBSD-src-9883351c45502bc6aec878ba11d8ef5fe1843397.zip FreeBSD-src-9883351c45502bc6aec878ba11d8ef5fe1843397.tar.gz |
Import sendmail 8.13.3
Diffstat (limited to 'contrib/sendmail/mail.local')
-rw-r--r-- | contrib/sendmail/mail.local/Makefile.m4 | 3 | ||||
-rw-r--r-- | contrib/sendmail/mail.local/mail.local.c | 51 |
2 files changed, 36 insertions, 18 deletions
diff --git a/contrib/sendmail/mail.local/Makefile.m4 b/contrib/sendmail/mail.local/Makefile.m4 index 3a06a3b..c9af26f 100644 --- a/contrib/sendmail/mail.local/Makefile.m4 +++ b/contrib/sendmail/mail.local/Makefile.m4 @@ -1,4 +1,4 @@ -dnl $Id: Makefile.m4,v 8.50 2002/06/21 22:01:39 ca Exp $ +dnl $Id: Makefile.m4,v 8.51 2004/11/18 22:29:52 ca Exp $ include(confBUILDTOOLSDIR`/M4/switch.m4') define(`confREQUIRE_LIBSM', `true') @@ -8,6 +8,7 @@ PREPENDDEF(`confENVDEF', `confMAPDEF') PREPENDDEF(`confINCDIRS', `-I${SMSRCDIR} ') bldPRODUCT_START(`executable', `mail.local') +define(`bldINSTALL_DIR', `E') define(`bldNO_INSTALL', `true') define(`bldSOURCES', `mail.local.c ') bldPUSH_SMLIB(`sm') diff --git a/contrib/sendmail/mail.local/mail.local.c b/contrib/sendmail/mail.local/mail.local.c index 7230584..0da5e7d 100644 --- a/contrib/sendmail/mail.local/mail.local.c +++ b/contrib/sendmail/mail.local/mail.local.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2003 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -13,12 +13,12 @@ #include <sm/gen.h> SM_IDSTR(copyright, -"@(#) Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.\n\ +"@(#) Copyright (c) 1998-2004 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") -SM_IDSTR(id, "@(#)$Id: mail.local.c,v 8.251 2003/11/03 18:38:29 ca Exp $") +SM_IDSTR(id, "@(#)$Id: mail.local.c,v 8.253 2004/11/01 20:42:42 ca Exp $") #include <stdlib.h> #include <sm/errstring.h> @@ -144,6 +144,7 @@ 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 CloseMBDB = false; char *HomeMailFile = NULL; /* store mail in homedir */ #if HASHSPOOL @@ -155,6 +156,9 @@ bool StripRcptDomain = true; #endif /* HASHSPOOL */ char SpoolPath[MAXPATHLEN]; +char *parseaddr __P((char *, bool)); +char *process_recipient __P((char *)); +void dolmtp __P((void)); void deliver __P((int, char *)); int e_to_sys __P((int)); void notifybiff __P((char *)); @@ -169,6 +173,18 @@ const char *hashname __P((char *)); #endif /* HASHSPOOL */ +static void +sm_exit(status) + int status; +{ + if (CloseMBDB) + { + sm_mbdb_terminate(); + CloseMBDB = false; /* not really necessary, but ... */ + } + exit(status); +} + int main(argc, argv) int argc; @@ -198,11 +214,13 @@ main(argc, argv) # endif /* LOG_MAIL */ from = NULL; + + /* XXX can this be converted to a compile time check? */ if (sm_strlcpy(SpoolPath, _PATH_MAILDIR, sizeof(SpoolPath)) >= sizeof(SpoolPath)) { mailerr("421", "Configuration error: _PATH_MAILDIR too large"); - exit(EX_CONFIG); + sm_exit(EX_CONFIG); } #if HASHSPOOL while ((ch = getopt(argc, argv, "7bdD:f:h:r:lH:p:n")) != -1) @@ -328,22 +346,21 @@ main(argc, argv) mailerr(errcode, "Can not open mailbox database %s: %s", mbdbname, sm_strexit(err)); - exit(err); + sm_exit(err); } + CloseMBDB = true; if (LMTPMode) { - extern void dolmtp __P((void)); - if (argc > 0) { mailerr("421", "Users should not be specified in command line if LMTP required"); - exit(EX_TEMPFAIL); + sm_exit(EX_TEMPFAIL); } dolmtp(); /* NOTREACHED */ - exit(EX_OK); + sm_exit(EX_OK); } /* Non-LMTP from here on out */ @@ -378,11 +395,11 @@ main(argc, argv) if (fd < 0) { flush_error(); - exit(ExitVal); + sm_exit(ExitVal); } for (; *argv != NULL; ++argv) deliver(fd, *argv); - exit(ExitVal); + sm_exit(ExitVal); /* NOTREACHED */ return ExitVal; } @@ -472,7 +489,7 @@ parseaddr(s, rcpt) if (p == NULL) { mailerr("421 4.3.0", "Memory exhausted"); - exit(EX_TEMPFAIL); + sm_exit(EX_TEMPFAIL); } (void) sm_strlcpy(p, s, l); @@ -528,7 +545,7 @@ dolmtp() { (void) fflush(stdout); if (fgets(buf, sizeof(buf) - 1, stdin) == NULL) - exit(EX_OK); + sm_exit(EX_OK); p = buf + strlen(buf) - 1; if (p >= buf && *p == '\n') *p-- = '\0'; @@ -642,7 +659,7 @@ dolmtp() if (sm_strcasecmp(buf, "quit") == 0) { printf("221 2.0.0 Bye\r\n"); - exit(EX_OK); + sm_exit(EX_OK); } goto syntaxerr; /* NOTREACHED */ @@ -669,7 +686,7 @@ dolmtp() { mailerr("421 4.3.0", "Memory exhausted"); - exit(EX_TEMPFAIL); + sm_exit(EX_TEMPFAIL); } } if (sm_strncasecmp(buf + 5, "to:", 3) != 0 || @@ -888,7 +905,7 @@ store(from, inbody) if (LMTPMode) { /* Got a premature EOF -- toss message and exit */ - exit(EX_OK); + sm_exit(EX_OK); } /* If message not newline terminated, need an extra. */ @@ -1548,7 +1565,7 @@ usage() { ExitVal = EX_USAGE; mailerr(NULL, "usage: mail.local [-7] [-b] [-d] [-l] [-f from|-r from] [-h filename] user ..."); - exit(ExitVal); + sm_exit(ExitVal); } void |