summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e0a3818)
SCCS-vsn: usr.sbin/sendmail/src/usersmtp.c 6.16
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 6.27
SCCS-vsn: usr.sbin/sendmail/src/envelope.c 6.21
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 6.28
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 6.28
SCCS-vsn: usr.sbin/sendmail/src/savemail.c 6.22
SCCS-vsn: usr.sbin/sendmail/src/util.c 6.12
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 6.44
SCCS-vsn: usr.sbin/sendmail/src/queue.c 6.26
SCCS-vsn: usr.sbin/sendmail/src/alias.c 6.25
SCCS-vsn: usr.sbin/sendmail/src/mci.c 6.6
#ifndef lint
#ifdef NEWDB
#ifdef NDBM
#ifndef lint
#ifdef NEWDB
#ifdef NDBM
-static char sccsid[] = "@(#)alias.c 6.24 (Berkeley) %G% (with NEWDB and NDBM)";
+static char sccsid[] = "@(#)alias.c 6.25 (Berkeley) %G% (with NEWDB and NDBM)";
-static char sccsid[] = "@(#)alias.c 6.24 (Berkeley) %G% (with NEWDB)";
+static char sccsid[] = "@(#)alias.c 6.25 (Berkeley) %G% (with NEWDB)";
-static char sccsid[] = "@(#)alias.c 6.24 (Berkeley) %G% (with NDBM)";
+static char sccsid[] = "@(#)alias.c 6.25 (Berkeley) %G% (with NDBM)";
-static char sccsid[] = "@(#)alias.c 6.24 (Berkeley) %G% (without NEWDB or NDBM)";
+static char sccsid[] = "@(#)alias.c 6.25 (Berkeley) %G% (without NEWDB or NDBM)";
#endif
#endif
#endif /* not lint */
#endif
#endif
#endif /* not lint */
printf("alias(%s)\n", a->q_paddr);
/* don't realias already aliased names */
printf("alias(%s)\n", a->q_paddr);
/* don't realias already aliased names */
- if (bitset(QDONTSEND|QVERIFIED, a->q_flags))
+ if (bitset(QDONTSEND|QBADADDR|QVERIFIED, a->q_flags))
return;
e->e_to = a->q_paddr;
return;
e->e_to = a->q_paddr;
-static char sccsid[] = "@(#)deliver.c 6.43 (Berkeley) %G%";
+static char sccsid[] = "@(#)deliver.c 6.44 (Berkeley) %G%";
#endif /* not lint */
#include "sendmail.h"
#endif /* not lint */
#include "sendmail.h"
bool clever = FALSE; /* running user smtp to this mailer */
ADDRESS *tochain = NULL; /* chain of users in this mailer call */
int rcode; /* response code */
bool clever = FALSE; /* running user smtp to this mailer */
ADDRESS *tochain = NULL; /* chain of users in this mailer call */
int rcode; /* response code */
- char *from; /* pointer to from person */
char *firstsig; /* signature of firstto */
char *pv[MAXPV+1];
char tobuf[MAXLINE-50]; /* text line of to people */
char buf[MAXNAME];
char *firstsig; /* signature of firstto */
char *pv[MAXPV+1];
char tobuf[MAXLINE-50]; /* text line of to people */
char buf[MAXNAME];
- char tfrombuf[MAXNAME]; /* translated from person */
char rpathbuf[MAXNAME]; /* translated return path */
extern int checkcompat();
extern ADDRESS *getctladdr();
char rpathbuf[MAXNAME]; /* translated return path */
extern int checkcompat();
extern ADDRESS *getctladdr();
{
for (; to != NULL; to = to->q_next)
{
{
for (; to != NULL; to = to->q_next)
{
- if (bitset(QDONTSEND|QQUEUEUP, to->q_flags) ||
+ if (bitset(QDONTSEND|QBADADDR|QQUEUEUP, to->q_flags) ||
to->q_mailer != m)
continue;
to->q_flags |= QQUEUEUP|QDONTSEND;
to->q_mailer != m)
continue;
to->q_flags |= QQUEUEUP|QDONTSEND;
*/
/* rewrite from address, using rewriting rules */
*/
/* rewrite from address, using rewriting rules */
- (void) strcpy(rpathbuf, remotename(e->e_returnpath, m, TRUE, FALSE,
+ (void) strcpy(rpathbuf, remotename(e->e_from.q_paddr, m, TRUE, FALSE,
- if (e->e_returnpath == e->e_sender)
- {
- from = rpathbuf;
- }
- else
- {
- (void) strcpy(tfrombuf, remotename(e->e_sender, m, TRUE, FALSE,
- TRUE, FALSE, e));
- from = tfrombuf;
- }
- define('f', e->e_returnpath, e); /* raw return path */
- define('<', rpathbuf, e); /* translated return path */
- define('g', from, e); /* translated sender */
+ define('f', e->e_from.q_paddr, e); /* raw return path */
+ define('g', rpathbuf, e); /* translated return path */
define('h', host, e); /* to host */
Errors = 0;
pvp = pv;
define('h', host, e); /* to host */
Errors = 0;
pvp = pv;
break;
/* if already sent or not for this host, don't send */
break;
/* if already sent or not for this host, don't send */
- if (bitset(QDONTSEND|QQUEUEUP, to->q_flags) ||
+ if (bitset(QDONTSEND|QBADADDR|QQUEUEUP, to->q_flags) ||
to->q_mailer != firstto->q_mailer ||
strcmp(hostsignature(to->q_mailer, to->q_host, e), firstsig) != 0)
continue;
to->q_mailer != firstto->q_mailer ||
strcmp(hostsignature(to->q_mailer, to->q_host, e), firstsig) != 0)
continue;
user = to->q_user;
e->e_to = to->q_paddr;
user = to->q_user;
e->e_to = to->q_paddr;
- to->q_flags |= QDONTSEND;
if (tTd(10, 5))
{
printf("deliver: QDONTSEND ");
printaddr(to, FALSE);
}
if (tTd(10, 5))
{
printf("deliver: QDONTSEND ");
printaddr(to, FALSE);
}
+ to->q_flags |= QDONTSEND;
/*
** Check to see that these people are allowed to
/*
** Check to see that these people are allowed to
/* close any connections */
if (mci->mci_in != NULL)
/* close any connections */
if (mci->mci_in != NULL)
- (void) fclose(mci->mci_in);
+ (void) xfclose(mci->mci_in, name, "mci_in");
if (mci->mci_out != NULL)
if (mci->mci_out != NULL)
- (void) fclose(mci->mci_out);
+ (void) xfclose(mci->mci_out, name, "mci_out");
mci->mci_in = mci->mci_out = NULL;
mci->mci_state = MCIS_CLOSED;
mci->mci_in = mci->mci_out = NULL;
mci->mci_state = MCIS_CLOSED;
char *bang;
char xbuf[MAXLINE];
char *bang;
char xbuf[MAXLINE];
- expand("\201<", buf, &buf[sizeof buf - 1], e);
+ expand("\201g", buf, &buf[sizeof buf - 1], e);
bang = strchr(buf, '!');
if (bang == NULL)
syserr("554 No ! in UUCP! (%s)", buf);
bang = strchr(buf, '!');
if (bang == NULL)
syserr("554 No ! in UUCP! (%s)", buf);
-** PARENTBODY -- put the body of the parent of a message.
-**
-** Parameters:
-** fp -- file to output onto.
-** m -- a mailer descriptor to control output format.
-** e -- the envelope whose parent to put out.
-**
-** Returns:
-** none.
-**
-** Side Effects:
-** The message is written onto fp.
-*/
-
-parentbody(fp, m, e)
- FILE *fp;
- MAILER *m;
- register ENVELOPE *e;
-{
- putbody(fp, m, e->e_parent);
-}
-\f/*
** MAILFILE -- Send a message to a file.
**
** If the file has the setuid/setgid bits set, but NO execute
** MAILFILE -- Send a message to a file.
**
** If the file has the setuid/setgid bits set, but NO execute
message("451 I/O error");
setstat(EX_IOERR);
}
message("451 I/O error");
setstat(EX_IOERR);
}
+ (void) xfclose(f, "mailfile", filename);
(void) fflush(stdout);
/* reset ISUID & ISGID bits for paranoid systems */
(void) fflush(stdout);
/* reset ISUID & ISGID bits for paranoid systems */
char mode;
{
register ADDRESS *q;
char mode;
{
register ADDRESS *q;
- bool oldverbose;
- int pid;
char *owner;
int otherowners;
ENVELOPE *splitenv = NULL;
char *owner;
int otherowners;
ENVELOPE *splitenv = NULL;
- printf("\nSENDALL: mode %c, sendqueue:\n", mode);
+ printf("\nSENDALL: mode %c, e_from ", mode);
+ printaddr(&e->e_from, FALSE);
+ printf("sendqueue:\n");
printaddr(e->e_sendqueue, TRUE);
}
printaddr(e->e_sendqueue, TRUE);
}
{
extern ADDRESS *recipient();
{
extern ADDRESS *recipient();
- e->e_from.q_flags |= QDONTSEND;
if (tTd(13, 5))
{
printf("sendall: QDONTSEND ");
printaddr(&e->e_from, FALSE);
}
if (tTd(13, 5))
{
printf("sendall: QDONTSEND ");
printaddr(&e->e_from, FALSE);
}
+ e->e_from.q_flags |= QDONTSEND;
(void) recipient(&e->e_from, &e->e_sendqueue, e);
}
(void) recipient(&e->e_from, &e->e_sendqueue, e);
}
if (a != NULL)
q->q_owner = a->q_owner;
if (a != NULL)
q->q_owner = a->q_owner;
- if (q->q_owner != NULL && !bitset(QDONTSEND, q->q_flags) &&
- strcmp(q->q_owner, e->e_returnpath) == 0)
+ if (q->q_owner != NULL &&
+ !bitset(QDONTSEND, q->q_flags) &&
+ strcmp(q->q_owner, e->e_from.q_paddr) == 0)
extern HDR *copyheader();
extern ADDRESS *copyqueue();
extern HDR *copyheader();
extern ADDRESS *copyqueue();
+ /*
+ ** Split this envelope into two.
+ */
+
ee = (ENVELOPE *) xalloc(sizeof(ENVELOPE));
ee = (ENVELOPE *) xalloc(sizeof(ENVELOPE));
+ (void) queuename(ee, '\0');
+
+ if (tTd(13, 1))
+ printf("sendall: split %s into %s\n",
+ e->e_id, ee->e_id);
+
ee->e_header = copyheader(e->e_header);
ee->e_sendqueue = copyqueue(e->e_sendqueue);
ee->e_errorqueue = copyqueue(e->e_errorqueue);
ee->e_flags = e->e_flags & ~(EF_INQUEUE|EF_CLRQUEUE);
ee->e_header = copyheader(e->e_header);
ee->e_sendqueue = copyqueue(e->e_sendqueue);
ee->e_errorqueue = copyqueue(e->e_errorqueue);
ee->e_flags = e->e_flags & ~(EF_INQUEUE|EF_CLRQUEUE);
- ee->e_returnpath = owner;
- ee->e_putbody = parentbody;
+ (void) parseaddr(owner, &ee->e_from, 1, '\0', NULL, ee);
+ if (tTd(13, 5))
+ {
+ printf("sendall(split): QDONTSEND ");
+ printaddr(&ee->e_from, FALSE);
+ }
+ ee->e_from.q_flags |= QDONTSEND;
+ ee->e_dfp = NULL;
+ ee->e_xfp = NULL;
+ ee->e_lockfp = NULL;
+ ee->e_df = NULL;
ee->e_sibling = splitenv;
splitenv = ee;
ee->e_sibling = splitenv;
splitenv = ee;
+
+ if (mode != SM_VERIFY)
+ {
+ char xfbuf1[20], xfbuf2[20];
+
+ (void) strcpy(xfbuf1, queuename(e, 'x'));
+ (void) strcpy(xfbuf2, queuename(ee, 'x'));
+ if (link(xfbuf1, xfbuf2) < 0)
+ {
+ syserr("sendall: link(%s, %s)",
+ xfbuf1, xfbuf2);
+ }
+ }
- e->e_returnpath = owner;
+ {
+ (void) parseaddr(owner, &e->e_from, 1, '\0', NULL, e);
+ if (tTd(13, 5))
+ {
+ printf("sendall(owner): QDONTSEND ");
+ printaddr(&e->e_from, FALSE);
+ }
+ e->e_from.q_flags |= QDONTSEND;
+ }
# ifdef QUEUE
if ((mode == SM_QUEUE || mode == SM_FORK ||
# ifdef QUEUE
if ((mode == SM_QUEUE || mode == SM_FORK ||
+ register ENVELOPE *ee;
+
if (tTd(13, 1))
{
printf("\nsendall: Split queue; remaining queue:\n");
printaddr(e->e_sendqueue, TRUE);
}
if (tTd(13, 1))
{
printf("\nsendall: Split queue; remaining queue:\n");
printaddr(e->e_sendqueue, TRUE);
}
- while (splitenv != NULL)
+ for (ee = splitenv; ee != NULL; ee = ee->e_sibling)
- sendall(splitenv, mode);
- splitenv = splitenv->e_sibling;
+ CurEnv = ee;
+ sendenvelope(ee, mode);
+ sendenvelope(e, mode);
+
+ for (; splitenv != NULL; splitenv = splitenv->e_sibling)
+ dropenvelope(splitenv);
+}
+
+sendenvelope(e, mode)
+ register ENVELOPE *e;
+ char mode;
+{
+ bool oldverbose;
+ int pid;
+ register ADDRESS *q;
oldverbose = Verbose;
switch (mode)
oldverbose = Verbose;
switch (mode)
if (e->e_lockfp != NULL)
{
if (e->e_lockfp != NULL)
{
- (void) fclose(e->e_lockfp);
+ (void) xfclose(e->e_lockfp, "sendenvelope", "lockfp");
e->e_lockfp = NULL;
}
# endif /* LOCKF */
e->e_lockfp = NULL;
}
# endif /* LOCKF */
# ifndef LOCKF
if (e->e_lockfp != NULL)
{
# ifndef LOCKF
if (e->e_lockfp != NULL)
{
- (void) fclose(e->e_lockfp);
+ (void) xfclose(e->e_lockfp, "sendenvelope", "lockfp");
e->e_lockfp = NULL;
}
# endif
e->e_lockfp = NULL;
}
# endif
/* close any random open files in the envelope */
if (e->e_dfp != NULL)
{
/* close any random open files in the envelope */
if (e->e_dfp != NULL)
{
- (void) fclose(e->e_dfp);
+ (void) xfclose(e->e_dfp, "sendenvelope", "dfp");
e->e_dfp = NULL;
}
if (e->e_xfp != NULL)
{
e->e_dfp = NULL;
}
if (e->e_xfp != NULL)
{
- (void) fclose(e->e_xfp);
+ (void) xfclose(e->e_xfp, "sendenvelope", "xfp");
e->e_xfp = NULL;
}
return;
e->e_xfp = NULL;
}
return;
if (!bitset(QDONTSEND|QBADADDR, q->q_flags))
message("deliverable");
}
if (!bitset(QDONTSEND|QBADADDR, q->q_flags))
message("deliverable");
}
- else if (!bitset(QDONTSEND, q->q_flags))
+ else if (!bitset(QDONTSEND|QBADADDR, q->q_flags))
*/
if (mode == SM_VERIFY)
*/
if (mode == SM_VERIFY)
for (q = e->e_sendqueue; q != NULL; q = q->q_next)
{
for (q = e->e_sendqueue; q != NULL; q = q->q_next)
{
if (!bitset(QBADADDR, q->q_flags))
continue;
if (!bitset(QBADADDR, q->q_flags))
continue;
+ e->e_flags |= EF_FATALERRS;
+
if (q->q_owner == NULL && strcmp(e->e_from.q_paddr, "<>") != 0)
(void) sendtolist(e->e_from.q_paddr, NULL,
&e->e_errorqueue, e);
if (q->q_owner == NULL && strcmp(e->e_from.q_paddr, "<>") != 0)
(void) sendtolist(e->e_from.q_paddr, NULL,
&e->e_errorqueue, e);
-static char sccsid[] = "@(#)envelope.c 6.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)envelope.c 6.21 (Berkeley) %G%";
#endif /* not lint */
#include "sendmail.h"
#endif /* not lint */
#include "sendmail.h"
- printf("dropenvelope %x id=", e);
+ printf("dropenvelope %x: id=", e);
- printf(" flags=%o\n", e->e_flags);
+ printf(", flags=%o\n", e->e_flags);
+ /* we must have an id to remove disk files */
#ifdef LOG
if (LogLevel > 84)
#ifdef LOG
if (LogLevel > 84)
id, e->e_flags, getpid());
#endif /* LOG */
id, e->e_flags, getpid());
#endif /* LOG */
- /* we must have an id to remove disk files */
- if (e->e_id == NULL)
- return;
-
/*
** Extract state information from dregs of send list.
*/
/*
** Extract state information from dregs of send list.
*/
unlockqueue(e);
/* make sure that this envelope is marked unused */
unlockqueue(e);
/* make sure that this envelope is marked unused */
- e->e_id = e->e_df = NULL;
- (void) fclose(e->e_dfp);
+ (void) xfclose(e->e_dfp, "dropenvelope", e->e_df);
+ e->e_id = e->e_df = NULL;
#ifdef LOG
if (LogLevel > 74)
#ifdef LOG
if (LogLevel > 74)
{
/* clear out any file information */
if (e->e_xfp != NULL)
{
/* clear out any file information */
if (e->e_xfp != NULL)
- (void) fclose(e->e_xfp);
+ (void) xfclose(e->e_xfp, "clearenvelope xfp", e->e_id);
- (void) fclose(e->e_dfp);
+ (void) xfclose(e->e_dfp, "clearenvelope dfp", e->e_df);
+ e->e_xfp = e->e_dfp = NULL;
}
/* now clear out the data */
}
/* now clear out the data */
{
if (e->e_xfp == NULL)
return;
{
if (e->e_xfp == NULL)
return;
- (void) fclose(e->e_xfp);
+ (void) xfclose(e->e_xfp, "closexscript", e->e_id);
rewrite(pvp, 3);
rewrite(pvp, 1);
rewrite(pvp, 4);
rewrite(pvp, 3);
rewrite(pvp, 1);
rewrite(pvp, 4);
- cataddr(pvp, buf, sizeof buf, '\0');
- e->e_sender = e->e_returnpath = newstr(buf);
- define('f', e->e_sender, e);
+ define('f', e->e_from.q_paddr, e);
/* save the domain spec if this mailer wants it */
if (e->e_from.q_mailer != NULL &&
/* save the domain spec if this mailer wants it */
if (e->e_from.q_mailer != NULL &&
-static char sccsid[] = "@(#)mci.c 6.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)mci.c 6.6 (Berkeley) %G%";
#endif /* not lint */
#include "sendmail.h"
#endif /* not lint */
#include "sendmail.h"
else
{
if (mci->mci_in != NULL)
else
{
if (mci->mci_in != NULL)
+ xfclose(mci->mci_in, "mci_uncache", "mci_in");
if (mci->mci_out != NULL)
if (mci->mci_out != NULL)
+ xfclose(mci->mci_out, "mci_uncache", "mci_out");
mci->mci_in = mci->mci_out = NULL;
mci->mci_state = MCIS_CLOSED;
mci->mci_exitstat = EX_OK;
mci->mci_in = mci->mci_out = NULL;
mci->mci_state = MCIS_CLOSED;
mci->mci_exitstat = EX_OK;
-static char sccsid[] = "@(#)parseaddr.c 6.27 (Berkeley) %G%";
+static char sccsid[] = "@(#)parseaddr.c 6.28 (Berkeley) %G%";
#endif /* not lint */
#include "sendmail.h"
#endif /* not lint */
#include "sendmail.h"
- if (!strcasecmp(*tv, "error"))
+ if (strcasecmp(*tv, "error") == 0)
{
if ((**++tv & 0377) == CANONHOST)
{
{
if ((**++tv & 0377) == CANONHOST)
{
for (mp = Mailer; (m = *mp++) != NULL; )
{
for (mp = Mailer; (m = *mp++) != NULL; )
{
- if (!strcasecmp(m->m_name, *tv))
+ if (strcasecmp(m->m_name, *tv) == 0)
#ifndef lint
#ifdef QUEUE
#ifndef lint
#ifdef QUEUE
-static char sccsid[] = "@(#)queue.c 6.25 (Berkeley) %G% (with queueing)";
+static char sccsid[] = "@(#)queue.c 6.26 (Berkeley) %G% (with queueing)";
-static char sccsid[] = "@(#)queue.c 6.25 (Berkeley) %G% (without queueing)";
+static char sccsid[] = "@(#)queue.c 6.26 (Berkeley) %G% (without queueing)";
#endif
#endif /* not lint */
#endif
#endif /* not lint */
{
syserr("queueup: cannot create %s", e->e_df);
if (!newid)
{
syserr("queueup: cannot create %s", e->e_df);
if (!newid)
+ (void) xfclose(tfp, "queueup tfp", e->e_id);
return;
}
dfp = fdopen(fd, "w");
(*e->e_putbody)(dfp, ProgMailer, e);
return;
}
dfp = fdopen(fd, "w");
(*e->e_putbody)(dfp, ProgMailer, e);
+ (void) xfclose(dfp, "queueup dfp", e->e_id);
e->e_putbody = putbody;
}
e->e_putbody = putbody;
}
lastctladdr = NULL;
for (q = e->e_errorqueue; q != NULL; q = q->q_next)
{
lastctladdr = NULL;
for (q = e->e_errorqueue; q != NULL; q = q->q_next)
{
- if (!bitset(QDONTSEND, q->q_flags))
+ if (!bitset(QDONTSEND|QBADADDR, q->q_flags))
for (q = e->e_sendqueue; q != NULL; q = q->q_next)
{
if (bitset(QQUEUEUP, q->q_flags) ||
for (q = e->e_sendqueue; q != NULL; q = q->q_next)
{
if (bitset(QQUEUEUP, q->q_flags) ||
- (queueall && !bitset(QDONTSEND|QSENT, q->q_flags)))
+ (queueall && !bitset(QDONTSEND|QBADADDR|QSENT, q->q_flags)))
if (rename(tf, qf) < 0)
syserr("cannot rename(%s, %s), df=%s", tf, qf, e->e_df);
if (e->e_lockfp != NULL)
if (rename(tf, qf) < 0)
syserr("cannot rename(%s, %s), df=%s", tf, qf, e->e_df);
if (e->e_lockfp != NULL)
- (void) fclose(e->e_lockfp);
+ (void) xfclose(e->e_lockfp, "queueup lockfp", e->e_id);
e->e_lockfp = tfp;
}
else
e->e_lockfp = tfp;
}
else
{
static char buf[MAXNAME];
static int pid = -1;
{
static char buf[MAXNAME];
static int pid = -1;
- char c1 = 'A';
- char c2 = 'A';
+ static char c1 = 'A';
+ static char c2 = 'A';
unlockqueue(e)
ENVELOPE *e;
{
unlockqueue(e)
ENVELOPE *e;
{
+ if (tTd(51, 4))
+ printf("unlockqueue(%s)\n", e->e_id);
+
/* if there is a lock file in the envelope, close it */
if (e->e_lockfp != NULL)
/* if there is a lock file in the envelope, close it */
if (e->e_lockfp != NULL)
+ xfclose(e->e_lockfp, "unlockqueue", e->e_id);
e->e_lockfp = NULL;
/* remove the transcript */
e->e_lockfp = NULL;
/* remove the transcript */
if (LogLevel > 87)
syslog(LOG_DEBUG, "%s: unlock", e->e_id);
# endif /* LOG */
if (LogLevel > 87)
syslog(LOG_DEBUG, "%s: unlock", e->e_id);
# endif /* LOG */
xunlink(queuename(e, 'x'));
}
xunlink(queuename(e, 'x'));
}
-static char sccsid[] = "@(#)recipient.c 6.26 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c 6.27 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
#endif /* not lint */
# include "sendmail.h"
/* check for direct mailing to restricted mailers */
if (a->q_alias == NULL && m == ProgMailer)
{
/* check for direct mailing to restricted mailers */
if (a->q_alias == NULL && m == ProgMailer)
{
- a->q_flags |= QDONTSEND|QBADADDR;
+ a->q_flags |= QBADADDR;
usrerr("550 Cannot mail directly to programs", m->m_name);
}
usrerr("550 Cannot mail directly to programs", m->m_name);
}
if (tTd(29, 7))
printf("at trylocaluser %s\n", a->q_user);
if (tTd(29, 7))
printf("at trylocaluser %s\n", a->q_user);
- if (bitset(QDONTSEND|QVERIFIED, a->q_flags))
+ if (bitset(QDONTSEND|QBADADDR|QVERIFIED, a->q_flags))
return (a);
if (m == InclMailer)
return (a);
if (m == InclMailer)
a->q_flags |= QDONTSEND;
if (a->q_alias == NULL)
{
a->q_flags |= QDONTSEND;
if (a->q_alias == NULL)
{
- a->q_flags |= QDONTSEND|QBADADDR;
+ a->q_flags |= QBADADDR;
usrerr("550 Cannot mail directly to :include:s");
}
else
usrerr("550 Cannot mail directly to :include:s");
}
else
/* check if writable or creatable */
if (a->q_alias == NULL && !QueueRun)
{
/* check if writable or creatable */
if (a->q_alias == NULL && !QueueRun)
{
- a->q_flags |= QDONTSEND|QBADADDR;
+ a->q_flags |= QBADADDR;
usrerr("550 Cannot mail directly to files");
}
else if ((stat(buf, &stb) >= 0) ? (!writable(&stb)) :
(*p = '\0', safefile(buf, getruid(), S_IWRITE|S_IEXEC) != 0))
{
usrerr("550 Cannot mail directly to files");
}
else if ((stat(buf, &stb) >= 0) ? (!writable(&stb)) :
(*p = '\0', safefile(buf, getruid(), S_IWRITE|S_IEXEC) != 0))
{
- a->q_flags |= QDONTSEND|QBADADDR;
+ a->q_flags |= QBADADDR;
giveresponse(EX_CANTCREAT, m, NULL, e);
}
}
giveresponse(EX_CANTCREAT, m, NULL, e);
}
}
pw = finduser(buf, &fuzzy);
if (pw == NULL)
{
pw = finduser(buf, &fuzzy);
if (pw == NULL)
{
- a->q_flags |= QDONTSEND|QBADADDR;
+ a->q_flags |= QBADADDR;
giveresponse(EX_NOUSER, m, NULL, e);
}
else
giveresponse(EX_NOUSER, m, NULL, e);
}
else
a->q_user = newstr(pw->pw_name);
if (findusercount++ > 3)
{
a->q_user = newstr(pw->pw_name);
if (findusercount++ > 3)
{
- a->q_flags |= QDONTSEND|QBADADDR;
+ a->q_flags |= QBADADDR;
usrerr("554 aliasing/forwarding loop for %s broken",
pw->pw_name);
return (a);
usrerr("554 aliasing/forwarding loop for %s broken",
pw->pw_name);
return (a);
if (bitset(EF_VRFYONLY, e->e_flags))
{
/* don't do any more now */
if (bitset(EF_VRFYONLY, e->e_flags))
{
/* don't do any more now */
+ xfclose(fp, "include", fname);
ctladdr->q_flags |= QDONTSEND;
}
ctladdr->q_flags |= QDONTSEND;
}
+ (void) xfclose(fp, "include", fname);
FileName = oldfilename;
LineNumber = oldlinenumber;
return 0;
FileName = oldfilename;
LineNumber = oldlinenumber;
return 0;
-static char sccsid[] = "@(#)savemail.c 6.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)savemail.c 6.22 (Berkeley) %G%";
#endif /* not lint */
# include <pwd.h>
#endif /* not lint */
# include <pwd.h>
typedef int (*fnptr)();
if (tTd(6, 1))
typedef int (*fnptr)();
if (tTd(6, 1))
- printf("\nsavemail, ErrorMode = %c\n", ErrorMode);
+ {
+ printf("\nsavemail, ErrorMode = %c\n e_from=", ErrorMode);
+ printaddr(&e->e_from, FALSE);
+ }
if (bitset(EF_RESPONSE, e->e_flags))
return;
if (bitset(EF_RESPONSE, e->e_flags))
return;
while (fgets(buf, sizeof buf, fp) != NULL &&
!ferror(stdout))
fputs(buf, stdout);
while (fgets(buf, sizeof buf, fp) != NULL &&
!ferror(stdout))
fputs(buf, stdout);
+ (void) xfclose(fp, "savemail transcript", e->e_id);
}
printf("Original message will be saved in dead.letter.\r\n");
state = ESM_DEADLETTER;
break;
case ESM_MAIL:
}
printf("Original message will be saved in dead.letter.\r\n");
state = ESM_DEADLETTER;
break;
case ESM_MAIL:
/*
** If mailing back, do it.
** Throw away all further output. Don't alias,
/*
** If mailing back, do it.
** Throw away all further output. Don't alias,
** joe@x, which gives a response, etc. Also force
** the mail to be delivered even if a version of
** it has already been sent to the sender.
** joe@x, which gives a response, etc. Also force
** the mail to be delivered even if a version of
** it has already been sent to the sender.
- **
- ** Clever technique for computing rpath from
- ** Eric Wassenaar <e07@nikhef.nl>.
+ if (strcmp(e->e_from.q_paddr, "<>") != 0)
+ (void) sendtolist(e->e_from.q_paddr,
+ (ADDRESS *) NULL,
+ &e->e_errorqueue, e);
+
+ /* deliver a cc: to the postmaster if desired */
+ if (PostMasterCopy != NULL)
+ auto ADDRESS *rlist = NULL;
- if (e->e_returnpath != e->e_sender)
- rpath = e->e_returnpath;
- else
- rpath = e->e_from.q_paddr;
- if (strcmp(rpath, "<>") != 0)
- (void) sendtolist(rpath,
+ (void) sendtolist(PostMasterCopy,
+ &rlist, e);
+ (void) returntosender(e->e_message,
+ rlist, FALSE, e);
+ }
+ q = e->e_errorqueue;
+ if (q == NULL)
+ {
+ /* this is an error-error */
+ state = ESM_POSTMASTER;
+ break;
+ }
+ if (returntosender(e->e_message != NULL ? e->e_message :
+ "Unable to deliver mail",
+ q, (e->e_class >= 0), e) == 0)
+ {
+ state = ESM_DONE;
+ break;
+ }
- /* deliver a cc: to the postmaster if desired */
- if (PostMasterCopy != NULL)
- {
- auto ADDRESS *rlist = NULL;
+ /* didn't work -- return to postmaster */
+ state = ESM_POSTMASTER;
+ break;
- (void) sendtolist(PostMasterCopy,
- (ADDRESS *) NULL,
- &rlist, e);
- (void) returntosender(e->e_message,
- rlist, FALSE, e);
- }
- q = e->e_errorqueue;
- if (q == NULL)
- {
- /* this is an error-error */
- state = ESM_USRTMP;
- break;
- }
- }
- else
+ case ESM_POSTMASTER:
+ /*
+ ** Similar to previous case, but to system postmaster.
+ */
+
+ if (parseaddr("postmaster", q, 0, '\0', NULL, e) == NULL)
- if (parseaddr("postmaster", q, 0, '\0', NULL, e) == NULL)
- {
- syserr("553 cannot parse postmaster!");
- ExitStat = EX_SOFTWARE;
- state = ESM_USRTMP;
- break;
- }
+ syserr("553 cannot parse postmaster!");
+ ExitStat = EX_SOFTWARE;
+ state = ESM_USRTMP;
+ break;
}
if (returntosender(e->e_message != NULL ? e->e_message :
"Unable to deliver mail",
}
if (returntosender(e->e_message != NULL ? e->e_message :
"Unable to deliver mail",
- state = state == ESM_MAIL ? ESM_POSTMASTER : ESM_USRTMP;
+ /* didn't work -- last resort */
+ state = ESM_USRTMP;
break;
case ESM_DEADLETTER:
break;
case ESM_DEADLETTER:
putline("\n", fp, FileMailer);
(void) fflush(fp);
state = ferror(fp) ? ESM_PANIC : ESM_DONE;
putline("\n", fp, FileMailer);
(void) fflush(fp);
state = ferror(fp) ? ESM_PANIC : ESM_DONE;
+ (void) xfclose(fp, "savemail", "/usr/tmp/dead.letter");
char buf[MAXNAME];
extern putheader(), errbody();
register ENVELOPE *ee;
char buf[MAXNAME];
extern putheader(), errbody();
register ENVELOPE *ee;
+ ENVELOPE *oldcur = CurEnv;
extern ENVELOPE *newenvelope();
ENVELOPE errenvelope;
static int returndepth;
extern ENVELOPE *newenvelope();
ENVELOPE errenvelope;
static int returndepth;
- printf("Return To Sender: msg=\"%s\", depth=%d, e=%x,\n",
+ printf("Return To Sender: msg=\"%s\", depth=%d, e=%x, returnq=",
printaddr(returnq, TRUE);
}
printaddr(returnq, TRUE);
}
- define('g', e->e_sender, e);
- define('<', e->e_returnpath, e);
+ define('g', e->e_from.q_paddr, e);
ee = newenvelope(&errenvelope, e);
define('a', "\201b", ee);
ee->e_puthdr = putheader;
ee = newenvelope(&errenvelope, e);
define('a', "\201b", ee);
ee->e_puthdr = putheader;
/* fake up an address header for the from person */
expand("\201n", buf, &buf[sizeof buf - 1], e);
/* fake up an address header for the from person */
expand("\201n", buf, &buf[sizeof buf - 1], e);
- ee->e_sender = newstr(buf);
- if (ConfigLevel >= 4)
- ee->e_returnpath = "<>";
- else
- ee->e_returnpath = ee->e_sender;
- if (parseaddr(buf, &ee->e_from, -1, '\0', NULL, e) == NULL)
+ if (parseaddr(buf, &ee->e_from, 1, '\0', NULL, e) == NULL)
{
syserr("553 Can't parse myself!");
ExitStat = EX_SOFTWARE;
{
syserr("553 Can't parse myself!");
ExitStat = EX_SOFTWARE;
/* restore state */
dropenvelope(ee);
/* restore state */
dropenvelope(ee);
- CurEnv = CurEnv->e_parent;
returndepth--;
/* should check for delivery errors here */
returndepth--;
/* should check for delivery errors here */
char buf[MAXLINE];
char *p;
char buf[MAXLINE];
char *p;
+ if (e->e_parent == NULL)
+ {
+ syserr("errbody: null parent");
+ putline("\n", fp, m);
+ putline(" ----- Original message lost -----\n", fp, m);
+ return;
+ }
+
/*
** Output error message header (if specified and available).
*/
/*
** Output error message header (if specified and available).
*/
if ((xfile = fopen(p, "r")) == NULL)
{
syserr("Cannot open %s", p);
if ((xfile = fopen(p, "r")) == NULL)
{
syserr("Cannot open %s", p);
- fprintf(fp, " ----- Transcript of session is unavailable -----\n");
+ putline(" ----- Transcript of session is unavailable -----\n", fp, m);
- fprintf(fp, " ----- Transcript of session follows -----\n");
+ putline(" ----- Transcript of session follows -----\n", fp, m);
if (e->e_xfp != NULL)
(void) fflush(e->e_xfp);
while (fgets(buf, sizeof buf, xfile) != NULL)
putline(buf, fp, m);
if (e->e_xfp != NULL)
(void) fflush(e->e_xfp);
while (fgets(buf, sizeof buf, xfile) != NULL)
putline(buf, fp, m);
+ (void) xfclose(xfile, "errbody xscript", p);
if (NoReturn)
SendBody = FALSE;
if (NoReturn)
SendBody = FALSE;
- if (e->e_parent->e_dfp != NULL)
+ if (e->e_parent->e_df != NULL)
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)sendmail.h 6.27 (Berkeley) %G%
+ * @(#)sendmail.h 6.28 (Berkeley) %G%
# ifdef _DEFINE
# define EXTERN
# ifndef lint
# ifdef _DEFINE
# define EXTERN
# ifndef lint
-static char SmailSccsId[] = "@(#)sendmail.h 6.27 %G%";
+static char SmailSccsId[] = "@(#)sendmail.h 6.28 %G%";
# endif lint
# else /* _DEFINE */
# define EXTERN extern
# endif lint
# else /* _DEFINE */
# define EXTERN extern
char *e_to; /* the target person */
char *e_receiptto; /* return receipt address */
ADDRESS e_from; /* the person it is from */
char *e_to; /* the target person */
char *e_receiptto; /* return receipt address */
ADDRESS e_from; /* the person it is from */
- char *e_sender; /* string version of from person */
- char *e_returnpath; /* string version of return path */
char **e_fromdomain; /* the domain part of the sender */
ADDRESS *e_returnto; /* place to return the message to */
ADDRESS *e_sendqueue; /* list of message recipients */
char **e_fromdomain; /* the domain part of the sender */
ADDRESS *e_returnto; /* place to return the message to */
ADDRESS *e_sendqueue; /* list of message recipients */
-static char sccsid[] = "@(#)usersmtp.c 6.15 (Berkeley) %G% (with SMTP)";
+static char sccsid[] = "@(#)usersmtp.c 6.16 (Berkeley) %G% (with SMTP)";
-static char sccsid[] = "@(#)usersmtp.c 6.15 (Berkeley) %G% (without SMTP)";
+static char sccsid[] = "@(#)usersmtp.c 6.16 (Berkeley) %G% (without SMTP)";
#endif
#endif /* not lint */
#endif
#endif /* not lint */
mci->mci_state = MCIS_ACTIVE;
mci->mci_state = MCIS_ACTIVE;
- expand("\201<", buf, &buf[sizeof buf - 1], e);
+ if (bitset(EF_RESPONSE, e->e_flags))
+ (void) strcpy(buf, "");
+ else
+ expand("\201g", buf, &buf[sizeof buf - 1], e);
if (e->e_from.q_mailer == LocalMailer ||
!bitnset(M_FROMPATH, m->m_flags))
{
if (e->e_from.q_mailer == LocalMailer ||
!bitnset(M_FROMPATH, m->m_flags))
{
if (mci->mci_state == MCIS_CLOSED)
return (SMTPCLOSING);
if (mci->mci_state == MCIS_CLOSED)
return (SMTPCLOSING);
+ if (mci->mci_out != NULL)
+ fflush(mci->mci_out);
+
/* get the line from the other side */
p = sfgets(SmtpReplyBuffer, sizeof SmtpReplyBuffer, mci->mci_in,
timeout);
/* get the line from the other side */
p = sfgets(SmtpReplyBuffer, sizeof SmtpReplyBuffer, mci->mci_in,
timeout);
VA_START(mci);
(void) vsprintf(SmtpMsgBuffer, f, ap);
VA_END;
VA_START(mci);
(void) vsprintf(SmtpMsgBuffer, f, ap);
VA_END;
if (tTd(18, 1) || Verbose)
nmessage(">>> %s", SmtpMsgBuffer);
if (mci->mci_out != NULL)
if (tTd(18, 1) || Verbose)
nmessage(">>> %s", SmtpMsgBuffer);
if (mci->mci_out != NULL)
fprintf(mci->mci_out, "%s%s", SmtpMsgBuffer,
m == NULL ? "\r\n" : m->m_eol);
fprintf(mci->mci_out, "%s%s", SmtpMsgBuffer,
m == NULL ? "\r\n" : m->m_eol);
+ (void) fflush(mci->mci_out);
+ if (ferror(mci->mci_out))
+ syserr("smtpmessage: ERROR mci_out");
+ }
+ else
+ syserr("smtpmessage: NULL mci_out");
-static char sccsid[] = "@(#)util.c 6.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c 6.12 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
#endif /* not lint */
# include "sendmail.h"
+** XFCLOSE -- close a file, doing logging as appropriate.
+**
+** Parameters:
+** fp -- file pointer for the file to close
+** a, b -- miscellaneous crud to print for debugging
+**
+** Returns:
+** none.
+**
+** Side Effects:
+** fp is closed.
+*/
+
+xfclose(fp, a, b)
+ FILE *fp;
+ char *a, *b;
+{
+ if (tTd(9, 99))
+ printf("xfclose(%x) %s %s\n", fp, a, b);
+ if (fclose(fp) < 0 && tTd(9, 99))
+ printf("xfclose FAILURE: %s\n", errstring(errno));
+}
+\f/*
** SFGETS -- "safe" fgets -- times out and ignores random interrupts.
**
** Parameters:
** SFGETS -- "safe" fgets -- times out and ignores random interrupts.
**
** Parameters: