abortive attempt to install a name server.... sigh.
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 18 Jun 1984 07:18:47 +0000 (23:18 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 18 Jun 1984 07:18:47 +0000 (23:18 -0800)
SCCS-vsn: usr.sbin/sendmail/src/headers.c 4.4.1.1
SCCS-vsn: usr.sbin/sendmail/src/main.c 4.9.1.1
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 4.4.1.1
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 4.3.1.1
SCCS-vsn: usr.sbin/sendmail/src/alias.c 4.4.1.1
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 4.6.1.1
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 4.4.1.1

usr/src/usr.sbin/sendmail/src/alias.c
usr/src/usr.sbin/sendmail/src/headers.c
usr/src/usr.sbin/sendmail/src/main.c
usr/src/usr.sbin/sendmail/src/parseaddr.c
usr/src/usr.sbin/sendmail/src/readcf.c
usr/src/usr.sbin/sendmail/src/recipient.c
usr/src/usr.sbin/sendmail/src/sendmail.h

index 05ac9ad..e2ce709 100644 (file)
@@ -5,9 +5,9 @@
 # include "sendmail.h"
 
 # ifdef DBM
 # include "sendmail.h"
 
 # ifdef DBM
-SCCSID(@(#)alias.c     4.4             %G%     (with DBM));
+SCCSID(@(#)alias.c     4.4.1.1         %G%     (with DBM));
 # else DBM
 # else DBM
-SCCSID(@(#)alias.c     4.4             %G%     (without DBM));
+SCCSID(@(#)alias.c     4.4.1.1         %G%     (without DBM));
 # endif DBM
 
 /*
 # endif DBM
 
 /*
@@ -285,6 +285,7 @@ readaliases(aliasfile, init)
 {
        register char *p;
        char *p2;
 {
        register char *p;
        char *p2;
+       char *lhs;
        char *rhs;
        bool skipping;
        int naliases, bytes, longest;
        char *rhs;
        bool skipping;
        int naliases, bytes, longest;
@@ -336,26 +337,45 @@ readaliases(aliasfile, init)
 
                /*
                **  Process the LHS
 
                /*
                **  Process the LHS
+               **
                **      Find the final colon, and parse the address.
                **      Find the final colon, and parse the address.
-               **      It should resolve to a local name -- this will
-               **      be checked later (we want to optionally do
-               **      parsing of the RHS first to maximize error
-               **      detection).
+               **      It should resolve to a local name.
+               **
+               **      Alternatively, it can be "@hostname" for host
+               **      aliases -- all we do here is map case.  Hostname
+               **      need not be a single token.
                */
 
                for (p = line; *p != '\0' && *p != ':' && *p != '\n'; p++)
                        continue;
                */
 
                for (p = line; *p != '\0' && *p != ':' && *p != '\n'; p++)
                        continue;
-               if (*p++ != ':')
+               if (*p != ':')
                {
                        syserr("%s, line %d: syntax error", aliasfile, lineno);
                        continue;
                }
                {
                        syserr("%s, line %d: syntax error", aliasfile, lineno);
                        continue;
                }
-               if (parseaddr(line, &al, 1, ':') == NULL)
+               *p++ = '\0';
+               if (line[0] == '@')
                {
                {
-                       syserr("illegal alias name");
-                       continue;
+                       /* a host alias */
+                       makelower(line);
+                       lhs = line;
+               }
+               else
+               {
+                       /* a user alias */
+                       if (parseaddr(line, &al, 1, ':') == NULL)
+                       {
+                               syserr("illegal alias name");
+                               continue;
+                       }
+                       loweraddr(&al);
+                       if (al.q_mailer != LocalMailer)
+                       {
+                               syserr("cannot alias non-local names");
+                               continue;
+                       }
+                       lhs = al.q_user;
                }
                }
-               loweraddr(&al);
 
                /*
                **  Process the RHS.
 
                /*
                **  Process the RHS.
@@ -438,17 +458,12 @@ readaliases(aliasfile, init)
                                break;
                        LineNumber++;
                }
                                break;
                        LineNumber++;
                }
-               if (al.q_mailer != LocalMailer)
-               {
-                       syserr("cannot alias non-local names");
-                       continue;
-               }
 
                /*
                **  Insert alias into symbol table or DBM file
                */
 
 
                /*
                **  Insert alias into symbol table or DBM file
                */
 
-               lhssize = strlen(al.q_user) + 1;
+               lhssize = strlen(lhs) + 1;
                rhssize = strlen(rhs) + 1;
 
 # ifdef DBM
                rhssize = strlen(rhs) + 1;
 
 # ifdef DBM
@@ -529,3 +544,86 @@ forward(user, sendq)
        /* we do have an address to forward to -- do it */
        include(buf, "forwarding", user, sendq);
 }
        /* we do have an address to forward to -- do it */
        include(buf, "forwarding", user, sendq);
 }
+\f/*
+**  MAPHOST -- given a host description, produce a mapping.
+**
+**     This is done by looking up the name in the alias file,
+**     preceeded by an "@".  This can be used for UUCP mapping.
+**     For example, a call with {blia, ., UUCP} as arguments
+**     might return {ucsfcgl, !, blia, ., UUCP} as the result.
+**
+**     We first break the input into three parts -- before the
+**     lookup, the lookup itself, and after the lookup.  We
+**     then do the lookup, concatenate them together, and rescan
+**     the result.
+**
+**     Parameters:
+**             pvp -- the parameter vector to map.
+**
+**     Returns:
+**             The result of the mapping.  If nothing found, it
+**             should just concatenate the three parts together and
+**             return that.
+**
+**     Side Effects:
+**             none.
+*/
+
+char **
+maphost(pvp)
+       char **pvp;
+{
+       register char **avp;
+       register char **bvp;
+       char *p;
+       char buf1[MAXNAME];
+       char buf2[MAXNAME];
+       char buf3[MAXNAME];
+       extern char **prescan();
+
+       /*
+       **  Extract the three parts of the input as strings.
+       */
+
+       /* find the part before the lookup */
+       for (bvp = pvp; *bvp != NULL && **bvp != MATCHLOOKUP; bvp++)
+               continue;
+       if (*bvp == NULL)
+               return (pvp);
+       p = *bvp;
+       *bvp = NULL;
+       cataddr(pvp, buf1, sizeof buf1);
+       *bvp++ = p;
+
+       /* find the rest of the lookup */
+       for (avp = bvp; *pvp != NULL && **bvp != MATCHELOOKUP; bvp++)
+               continue;
+       if (*bvp == NULL)
+               return (pvp);
+       p = *bvp;
+       *bvp = NULL;
+       cataddr(avp, buf2, sizeof buf2);
+       *bvp++ = p;
+
+       /* save the part after the lookup */
+       cataddr(bvp, buf3, sizeof buf3);
+
+       /*
+       **  Now look up the middle part.
+       */
+
+       p = aliaslookup(buf2);
+       if (p != NULL)
+               strcpy(buf2, p);
+
+       /*
+       **  Put the three parts back together and break into tokens.
+       */
+
+       strcat(buf1, buf2);
+       strcat(buf1, buf3);
+       avp = prescan(buf1, '\0');
+
+       /* return this mapping */
+       return (avp);
+}
index ea0b17a..fc4cd4a 100644 (file)
@@ -1,7 +1,7 @@
 # include <errno.h>
 # include "sendmail.h"
 
 # include <errno.h>
 # include "sendmail.h"
 
-SCCSID(@(#)headers.c   4.4             %G%);
+SCCSID(@(#)headers.c   4.4.1.1         %G%);
 
 /*
 **  CHOMPHEADER -- process and save a header line.
 
 /*
 **  CHOMPHEADER -- process and save a header line.
index 2c38868..ffe56ca 100644 (file)
@@ -4,7 +4,7 @@
 # include "sendmail.h"
 # include <sys/file.h>
 
 # include "sendmail.h"
 # include <sys/file.h>
 
-SCCSID(@(#)main.c      4.9             %G%);
+SCCSID(@(#)main.c      4.9.1.1         %G%);
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
@@ -717,6 +717,7 @@ struct metamac      MetaMacros[] =
 
        /* these are RHS metasymbols */
        '#', CANONNET,  '@', CANONHOST, ':', CANONUSER, '>', CALLSUBR,
 
        /* these are RHS metasymbols */
        '#', CANONNET,  '@', CANONHOST, ':', CANONUSER, '>', CALLSUBR,
+       '{', MATCHLOOKUP,               '}', MATCHELOOKUP,
 
        /* and finally the conditional operations */
        '?', CONDIF,    '|', CONDELSE,  '.', CONDFI,
 
        /* and finally the conditional operations */
        '?', CONDIF,    '|', CONDELSE,  '.', CONDFI,
index d2381c6..1095991 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-SCCSID(@(#)parseaddr.c 4.6             %G%);
+SCCSID(@(#)parseaddr.c 4.6.1.1         %G%);
 
 /*
 **  PARSEADDR -- Parse an address
 
 /*
 **  PARSEADDR -- Parse an address
@@ -496,6 +496,8 @@ rewrite(pvp, ruleset)
        register char **rvp;            /* rewrite vector pointer */
        register struct match *mlp;     /* cur ptr into mlist */
        register struct rewrite *rwr;   /* pointer to current rewrite rule */
        register char **rvp;            /* rewrite vector pointer */
        register struct match *mlp;     /* cur ptr into mlist */
        register struct rewrite *rwr;   /* pointer to current rewrite rule */
+       int subr;                       /* subroutine number if >= 0 */
+       bool dolookup;                  /* do host aliasing */
        struct match mlist[MAXMATCH];   /* stores match on LHS */
        char *npvp[MAXATOM+1];          /* temporary space for rebuild */
        extern bool sameword();
        struct match mlist[MAXMATCH];   /* stores match on LHS */
        char *npvp[MAXATOM+1];          /* temporary space for rebuild */
        extern bool sameword();
@@ -663,16 +665,24 @@ rewrite(pvp, ruleset)
                        rwr = NULL;
 
                /* substitute */
                        rwr = NULL;
 
                /* substitute */
+               dolookup = FALSE;
                for (avp = npvp; *rvp != NULL; rvp++)
                {
                        register struct match *m;
                        register char **pp;
 
                        rp = *rvp;
                for (avp = npvp; *rvp != NULL; rvp++)
                {
                        register struct match *m;
                        register char **pp;
 
                        rp = *rvp;
+
+                       /* check to see if we should do a lookup */
+                       if (*rp == MATCHLOOKUP)
+                               dolookup = TRUE;
+
+                       /* see if there is substitution here */
                        if (*rp != MATCHREPL)
                        {
                                if (avp >= &npvp[MAXATOM])
                                {
                        if (*rp != MATCHREPL)
                        {
                                if (avp >= &npvp[MAXATOM])
                                {
+                                 toolong:
                                        syserr("rewrite: expansion too long");
                                        return;
                                }
                                        syserr("rewrite: expansion too long");
                                        return;
                                }
@@ -700,29 +710,62 @@ rewrite(pvp, ruleset)
                        while (pp <= m->last)
                        {
                                if (avp >= &npvp[MAXATOM])
                        while (pp <= m->last)
                        {
                                if (avp >= &npvp[MAXATOM])
-                               {
-                                       syserr("rewrite: expansion too long");
-                                       return;
-                               }
+                                       goto toolong;
                                *avp++ = *pp++;
                        }
                }
                *avp++ = NULL;
                                *avp++ = *pp++;
                        }
                }
                *avp++ = NULL;
-               if (**npvp == CALLSUBR)
+
+               /*
+               **  Do hostname lookup if requested.
+               */
+
+               if (dolookup)
                {
                {
-                       bmove((char *) &npvp[2], (char *) pvp,
-                               (avp - npvp - 2) * sizeof *avp);
-# ifdef DEBUG
-                       if (tTd(21, 3))
-                               printf("-----callsubr %s\n", npvp[1]);
-# endif DEBUG
-                       rewrite(pvp, atoi(npvp[1]));
+                       extern char **maphost();
+
+                       rvp = maphost(npvp);
                }
                else
                }
                else
+                       rvp = npvp;
+
+               /*
+               **  See if this is a subroutine call.
+               */
+
+               if (**rvp == CALLSUBR)
                {
                {
-                       bmove((char *) npvp, (char *) pvp,
-                               (avp - npvp) * sizeof *avp);
+                       subr = atoi(*++rvp);
+                       rvp++;
                }
                }
+               else
+                       subr = -1;
+
+               /*
+               **  Copy result back to original string.
+               */
+
+               for (avp = pvp; *rvp != NULL; rvp++)
+                       *avp++ = *rvp;
+               *avp = NULL;
+
+               /*
+               **  If this specified a subroutine, call it.
+               */
+
+               if (subr >= 0)
+               {
+# ifdef DEBUG
+                       if (tTd(21, 3))
+                               printf("-----callsubr %s\n", subr);
+# endif DEBUG
+                       rewrite(pvp, subr);
+               }
+
+               /*
+               **  Done with rewriting this pass.
+               */
+
 # ifdef DEBUG
                if (tTd(21, 4))
                {
 # ifdef DEBUG
                if (tTd(21, 4))
                {
index 821a5d1..2adcdd6 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-SCCSID(@(#)readcf.c    4.4             %G%);
+SCCSID(@(#)readcf.c    4.4.1.1         %G%);
 
 /*
 **  READCF -- read control file.
 
 /*
 **  READCF -- read control file.
index 062576f..a598925 100644 (file)
@@ -2,7 +2,7 @@
 # include "sendmail.h"
 # include <sys/stat.h>
 
 # include "sendmail.h"
 # include <sys/stat.h>
 
-SCCSID(@(#)recipient.c 4.3             %G%);
+SCCSID(@(#)recipient.c 4.3.1.1         %G%);
 
 /*
 **  SENDTOLIST -- Designate a send list.
 
 /*
 **  SENDTOLIST -- Designate a send list.
index 8a74b15..38eaf95 100644 (file)
@@ -7,7 +7,7 @@
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
-static char SmailSccsId[] =    "@(#)sendmail.h 4.4             %G%";
+static char SmailSccsId[] =    "@(#)sendmail.h 4.4.1.1         %G%";
 # endif lint
 # else  _DEFINE
 # define EXTERN extern
 # endif lint
 # else  _DEFINE
 # define EXTERN extern
@@ -295,6 +295,8 @@ EXTERN struct rewrite       *RewriteRules[MAXRWSETS];
 # define MATCHCLASS    '\023'  /* match one token in a class */
 # define MATCHNCLASS   '\034'  /* match anything not in class */
 # define MATCHREPL     '\024'  /* replacement on RHS for above */
 # define MATCHCLASS    '\023'  /* match one token in a class */
 # define MATCHNCLASS   '\034'  /* match anything not in class */
 # define MATCHREPL     '\024'  /* replacement on RHS for above */
+# define MATCHLOOKUP   '\035'  /* look up and replace a sequence */
+# define MATCHELOOKUP  '\036'  /* end of the sequence */
 
 /* right hand side items */
 # define CANONNET      '\025'  /* canonical net, next token */
 
 /* right hand side items */
 # define CANONNET      '\025'  /* canonical net, next token */