# include <pwd.h>
# include "dlvrmail.h"
-static char SccsId[] = "@(#)alias.c 1.4 %G%";
+static char SccsId[] = "@(#)alias.c 1.5 %G%";
/*
** ALIAS -- Compute aliases.
**
** Defined Constants:
** MAXRCRSN -- the maximum recursion depth.
-** ALIASFILE -- the pathname of the alias file.
**
** Called By:
** main
*/
-# define ALIASFILE "/usr/lib/mailaliases"
# define MAXRCRSN 10
#ifdef DBM
typedef struct {char *dptr; int dsize;} datum;
datum lhs, rhs;
-datum fetch();
+extern datum fetch();
#endif DBM
alias()
}
if (q != NULL)
{
-#else DBM
- /*
- ** Scan SendQ
- ** We pass through the queue several times. Didalias tells
- ** us if we took some alias on this pass through the queue;
- ** when it goes false at the top of the loop we don't have
- ** to scan any more.
- */
-
- do
- {
- didalias = FALSE;
- /* Scan SendQ for that canonical form. */
- for (q = &SendQ; (q = nxtinq(q)) != NULL; )
- {
- lhs.dptr = q -> q_paddr;
- lhs.dsize = strlen(lhs.dptr)+1;
- rhs = fetch(lhs);
- p = rhs.dptr;
- if (p != NULL)
- {
-#endif
/*
** Match on Alias.
** Deliver to the target list.
}
}
} while (didalias);
-#ifndef DBM
fclose(af);
-#endif
+#else DBM
+ /*
+ ** Scan SendQ
+ ** We only have to do this once, since anything we alias
+ ** two is being put at the end of the queue we are
+ ** scanning.
+ */
+
+ for (q = &SendQ; (q = nxtinq(q)) != NULL; )
+ {
+ /* only alias local users */
+ if (q->q_mailer != &Mailer[0])
+ continue;
+
+ /* create a key for fetch */
+ lhs.dptr = q->q_user;
+ lhs.dsize = strlen(q->q_user) + 1;
+ lhs.dptr = line;
+ rhs = fetch(lhs);
+
+ /* find this alias? */
+ p = rhs.dptr;
+ if (p == NULL)
+ continue;
+
+ /*
+ ** Match on Alias.
+ ** Deliver to the target list.
+ ** Remove the alias from the send queue
+ ** and put it on the Alias queue.
+ */
+
+# ifdef DEBUG
+ if (Debug)
+ printf("%s (%s, %s) aliased to %s\n",
+ q->q_paddr, q->q_host, q->q_user, p);
+# endif
+ tkoffq(q, &SendQ);
+ putonq(q, &AliasQ);
+ sendto(p, 1);
+ }
+#endif DBM
}
\f/*
** FORWARD -- Try to forward mail
# include <log.h>
# endif LOG
-static char SccsId[] = "@(#)deliver.c 1.6 %G%";
+static char SccsId[] = "@(#)deliver.c 1.7 %G%";
/*
** DELIVER -- Deliver a message to a particular address.
m = to->q_mailer;
user = to->q_user;
host = to->q_host;
- Error = 0;
+ Errors = 0;
errno = 0;
# ifdef DEBUG
if (Debug)
** none.
**
** Side Effects:
-** Error may be set.
+** Errors may be incremented.
** ExitStat may be set.
**
** Called By:
statmsg = "ok";
else
{
- Error++;
+ Errors++;
if (statmsg == NULL && m->m_badstat != 0)
{
stat = m->m_badstat;
printf("recipient(%s)\n", To);
# endif DEBUG
- /*
- ** Don't go to the net if already on the target host.
- ** This is important on the berkeley network, since
- ** it get confused if we ask to send to ourselves.
- ** For nets like the ARPANET, we probably will have
- ** the local list set to NULL to simplify testing.
- ** The canonical representation of the name is also set
- ** to be just the local name so the duplicate letter
- ** suppression algorithm will work.
- */
-
- if ((pvp = m->m_local) != NULL)
- {
- while (*pvp != NULL)
- {
- if (strcmp(*pvp++, a->q_host) == 0)
- {
- a->q_mailer = m = &Mailer[0];
- break;
- }
- }
- }
-
/*
** Look up this person in the recipient list. If they
** are there already, return, otherwise continue.
# include <log.h>
# endif LOG
-static char SccsId[] = "@(#)err.c 1.3 %G%";
+static char SccsId[] = "@(#)err.c 1.4 %G%";
/*
-** ERR -- Print error message.
+** SYSERR -- Print error message.
**
** Prints an error message via printf to the diagnostic
** output. If LOG is defined, it logs it also.
** -1 always
**
** Side Effects:
-** Sets Error.
-** Sets ExitStat.
+** increments Errors.
+** sets ExitStat.
*/
/*VARARGS1*/
sprintf(p, ": error %d", errno);
}
printf("delivermail: %s\n", errbuf);
- Error++;
+ Errors++;
/* determine exit status if not already set */
if (ExitStat == EX_OK)
** -1
**
** Side Effects:
-** sets Error.
+** increments Errors.
*/
/*VARARGS1*/
if (SuprErrs)
return;
- Error++;
+ Errors++;
if (To != NULL)
printf("%s... ", To);
printf(fmt, a, b, c, d, e);
# include <log.h>
# endif LOG
-static char SccsId[] = "@(#)main.c 1.10 %G%";
+static char SccsId[] = "@(#)main.c 1.11 %G%";
/*
** DELIVERMAIL -- Deliver mail to a set of destinations
bool MeToo; /* send to the sender also if in a group expansion */
bool SaveFrom; /* save From lines on the front of messages */
bool IgnrDot; /* if set, ignore dot when collecting mail */
-bool Error; /* set if errors */
bool SuprErrs; /* supress errors if set */
+int Errors; /* count of errors */
char InFileName[] = "/tmp/mailtXXXXXX";
char Transcript[] = "/tmp/mailxXXXXXX";
addrq From; /* the from person */
}
/* if we have had errors sofar, drop out now */
- if (Error && ExitStat == EX_OK)
+ if (Errors > 0 && ExitStat == EX_OK)
ExitStat = EX_USAGE;
if (ExitStat != EX_OK)
finis();
# include <ctype.h>
# include "dlvrmail.h"
-static char SccsId[] = "@(#)parseaddr.c 1.4 %G%";
+static char SccsId[] = "@(#)parseaddr.c 1.5 %G%";
/*
** PARSE -- Parse an address
bool got_one;
extern char *prescan();
extern char *xalloc();
+ char **pvp;
/*
** Initialize and prescan address.
a->q_host = buf;
a->q_user = q;
}
+
+ /*
+ ** Don't go to the net if already on the target host.
+ ** This is important on the berkeley network, since
+ ** it get confused if we ask to send to ourselves.
+ ** For nets like the ARPANET, we probably will have
+ ** the local list set to NULL to simplify testing.
+ ** The canonical representation of the name is also set
+ ** to be just the local name so the duplicate letter
+ ** suppression algorithm will work.
+ */
+
+ if ((pvp = a->q_mailer->m_local) != NULL)
+ {
+ while (*pvp != NULL)
+ {
+ auto char buf2[MAXNAME];
+
+ strcpy(buf2, a->q_host);
+ if (!flagset(P_HST_UPPER, t->p_flags))
+ makelower(buf2);
+ if (strcmp(*pvp++, buf2) == 0)
+ {
+ strcpy(buf2, a->q_user);
+ p = a->q_paddr;
+ if (parse(buf2, a, -1) == NULL)
+ {
+ To = addr;
+ return (NULL);
+ }
+ To = a->q_paddr = p;
+ break;
+ }
+ }
+ }
+
+ /* make copies if specified */
if (copyf >= 0)
{
p = xalloc((unsigned) strlen(a->q_host) + 1);
**
** Most of these are actually allocated in globals.c
**
-** @(#)sendmail.h 1.5 %G%
+** @(#)sendmail.h 1.6 %G%
*/
# define MAXFIELD 2500 /* maximum total length of a header field */
# define MAXPV 15 /* maximum # of parms to mailers */
# define MAXHOP 30 /* maximum value of HopCount */
+# define ALIASFILE "/usr/lib/aliases" /* location of alias file */
extern bool NoAlias; /* if set, don't do any aliasing */
extern bool ForceMail; /* if set, mail even if already got a copy */
extern bool MeToo; /* send to the sender also */
-extern bool Error; /* set if errors */
extern bool UseMsgId; /* put msg-id's in all msgs [conf.c] */
extern bool IgnrDot; /* don't let dot end messages */
extern bool SaveFrom; /* save leading "From" lines */
+extern int Errors; /* set if errors */
extern int ExitStat; /* exit status code */
extern char InFileName[]; /* input file name */
extern char Transcript[]; /* the transcript file name */
-char Version[] = "@(#)Delivermail version 1.6 of %G%";
+char Version[] = "@(#)Delivermail version 1.7 of %G%";