static char SccsId
[] = "@(#)alias.c 1.8 10/28/80";
** ALIAS -- Compute aliases.
** Scans the file ALIASFILE for a set of aliases.
** If found, it arranges to deliver to them by inserting the
** new names onto the SendQ queue. Uses libdbm database if -DDBM.
** Aliases found on SendQ are removed and put onto
** AliasQ; replacements are added to SendQ. This is
** done until no such replacement occurs.
** MAXRCRSN -- the maximum recursion depth.
** ALIASFILE -- the mail aliases. The format is
** a series of lines of the form:
** alias:name1,name2,name3,...
** where 'alias' expands to all of
** 'name[i]'. Continuations begin with
** ALIASFILE.pag, ALIASFILE.dir: libdbm version
** of alias file. Keys are aliases, datums
** (data?) are name1,name2, ...
** If NoAlias (the "-n" flag) is set, no aliasing is
** It should complain about names that are aliased to
** It is unsophisticated about line overflows.
typedef struct {char *dptr
; int dsize
;} datum
;
printf("--- alias ---\n");
/* open alias file if not already open */
if (Debug
&& (af
= fopen("mailaliases", "r")) != NULL
)
printf(" [using local alias file]\n");
if ((af
= fopen(ALIASFILE
, "r")) == NULL
)
printf("Can't open %s\n", ALIASFILE
);
** If we find any user that any line matches any user, we
** will send to the line rather than to the user.
** We pass through the file several times. Didalias tells
** us if we took some alias on this pass through the file;
** when it goes false at the top of the loop we don't have
** to scan any more. Gotmatch tells the same thing, but
** on a line-by-line basis; it is used for processing
while (fgets(line
, sizeof line
, af
) != NULL
)
/* comments begin with `#' */
/* check for continuation lines */
** Check to see if this pseudonym exists in SendQ.
** Turn the alias into canonical form.
** Then scan SendQ until you do (or do not)
/* Get a canonical form for the alias. */
for (p
= line
; *p
!= '\0' && *p
!= ':' && *p
!= '\n'; p
++)
if (*p
== '\0' || *p
== '\n')
syserr("Bad alias line `%s'", line
);
if (parse(line
, &al
, -1) == NULL
)
/* Scan SendQ for that canonical form. */
for (q
= &SendQ
; (q
= nxtinq(q
)) != NULL
; )
if (sameaddr(&al
, q
, TRUE
))
** Deliver to the target list.
** Remove the alias from the send queue
** and put it on the Alias queue.
printf("%s (%s, %s) aliased to %s (%s,%s,%s)\n",
q
->q_paddr
, q
->q_host
, q
->q_user
,
p
, al
.q_paddr
, al
.q_host
, al
.q_user
);
** We only have to do this once, since anything we alias
** two is being put at the end of the queue we are
for (q2
= nxtinq(&SendQ
); (q
= q2
) != NULL
; )
/* save ptr to next address */
/* only alias local users */
if (q
->q_mailer
!= &Mailer
[0])
/* create a key for fetch */
lhs
.dsize
= strlen(q
->q_user
) + 1;
** Deliver to the target list.
** Remove the alias from the send queue
** and put it on the Alias queue.
printf("%s (%s, %s) aliased to %s\n",
q
->q_paddr
, q
->q_host
, q
->q_user
, p
);
/* if our last entry had an alias, process them */
** FORWARD -- Try to forward mail
** This is similar but not identical to aliasing.
** Currently it is undefined, until the protocol for userinfo
** databases is finalized.
** user -- the name of the user who's mail we
** would like to forward to.
** TRUE -- we have forwarded it somewhere.
** FALSE -- not forwarded; go ahead & deliver.
** New names are added to SendQ.