J option sets "search path" for .forward
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 16 Dec 1992 05:24:11 +0000 (21:24 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 16 Dec 1992 05:24:11 +0000 (21:24 -0800)
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 5.38
SCCS-vsn: usr.sbin/sendmail/src/version.c 5.132
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 5.45
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 5.53
SCCS-vsn: usr.sbin/sendmail/src/alias.c 5.42

usr/src/usr.sbin/sendmail/src/alias.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
usr/src/usr.sbin/sendmail/src/version.c

index 85bb039..72a774a 100644 (file)
@@ -30,12 +30,12 @@ ERROR: DBM is no longer supported -- use NDBM instead.
 
 #ifndef lint
 #ifdef NEWDB
 
 #ifndef lint
 #ifdef NEWDB
-static char sccsid[] = "@(#)alias.c    5.41 (Berkeley) %G% (with NEWDB)";
+static char sccsid[] = "@(#)alias.c    5.42 (Berkeley) %G% (with NEWDB)";
 #else
 #ifdef NDBM
 #else
 #ifdef NDBM
-static char sccsid[] = "@(#)alias.c    5.41 (Berkeley) %G% (with NDBM)";
+static char sccsid[] = "@(#)alias.c    5.42 (Berkeley) %G% (with NDBM)";
 #else
 #else
-static char sccsid[] = "@(#)alias.c    5.41 (Berkeley) %G% (without NDBM)";
+static char sccsid[] = "@(#)alias.c    5.42 (Berkeley) %G% (without NDBM)";
 #endif
 #endif
 #endif /* not lint */
 #endif
 #endif
 #endif /* not lint */
@@ -768,7 +768,8 @@ forward(user, sendq, e)
        ADDRESS **sendq;
        register ENVELOPE *e;
 {
        ADDRESS **sendq;
        register ENVELOPE *e;
 {
-       char buf[60];
+       char *pp;
+       char *ep;
        extern bool safefile();
 
        if (tTd(27, 1))
        extern bool safefile();
 
        if (tTd(27, 1))
@@ -781,8 +782,26 @@ forward(user, sendq, e)
 
        /* good address -- look for .forward file in home */
        define('z', user->q_home, e);
 
        /* good address -- look for .forward file in home */
        define('z', user->q_home, e);
-       expand("\001z/.forward", buf, &buf[sizeof buf - 1], e);
-       include(buf, TRUE, user, sendq, e);
+       define('u', user->q_user, e);
+       define('h', user->q_host, e);
+       if (ForwardPath == NULL)
+               ForwardPath = newstr("\001z/.forward");
+
+       for (pp = ForwardPath; pp != NULL; pp = ep)
+       {
+               char buf[256];
+
+               ep = strchr(pp, ':');
+               if (ep != NULL)
+                       *ep = '\0';
+               expand(pp, buf, &buf[sizeof buf - 1], e);
+               if (ep != NULL)
+                       *ep++ = ':';
+               if (tTd(27, 3))
+                       printf("forward: trying %s\n", buf);
+               if (include(buf, TRUE, user, sendq, e) == 0)
+                       break;
+       }
 }
 \f/*
 **  MAPHOST -- given a host description, produce a mapping.
 }
 \f/*
 **  MAPHOST -- given a host description, produce a mapping.
index 381d62a..2449813 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)readcf.c   5.52 (Berkeley) %G%";
+static char sccsid[] = "@(#)readcf.c   5.53 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -919,6 +919,10 @@ setoption(opt, val, sticky)
                IgnrDot = atobool(val);
                break;
 
                IgnrDot = atobool(val);
                break;
 
+         case 'J':             /* .forward search path */
+               ForwardPath = newstr(val);
+               break;
+
          case 'k':             /* connection cache size */
                MaxMciCache = atoi(val);
                if (MaxMciCache < 0)
          case 'k':             /* connection cache size */
                MaxMciCache = atoi(val);
                if (MaxMciCache < 0)
index a55e452..533ac9f 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)recipient.c        5.37 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c        5.38 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <sys/types.h>
 #endif /* not lint */
 
 # include <sys/types.h>
@@ -357,7 +357,7 @@ recipient(a, sendq, e)
                        else
                        {
                                message(Arpa_Info, "including file %s", &a->q_user[9]);
                        else
                        {
                                message(Arpa_Info, "including file %s", &a->q_user[9]);
-                               include(&a->q_user[9], FALSE, a, sendq, e);
+                               (void) include(&a->q_user[9], FALSE, a, sendq, e);
                        }
                }
                else
                        }
                }
                else
@@ -647,7 +647,7 @@ writable(s)
 **                     to put these addresses in.
 **
 **     Returns:
 **                     to put these addresses in.
 **
 **     Returns:
-**             none.
+**             open error status
 **
 **     Side Effects:
 **             reads the :include: file and sends to everyone
 **
 **     Side Effects:
 **             reads the :include: file and sends to everyone
@@ -656,6 +656,7 @@ writable(s)
 
 static jmp_buf CtxIncludeTimeout;
 
 
 static jmp_buf CtxIncludeTimeout;
 
+int
 include(fname, forwarding, ctladdr, sendq, e)
        char *fname;
        bool forwarding;
 include(fname, forwarding, ctladdr, sendq, e)
        char *fname;
        bool forwarding;
@@ -681,7 +682,7 @@ include(fname, forwarding, ctladdr, sendq, e)
                ctladdr->q_flags |= QQUEUEUP|QDONTSEND;
                errno = 0;
                usrerr("451 open timeout on %s", fname);
                ctladdr->q_flags |= QQUEUEUP|QDONTSEND;
                errno = 0;
                usrerr("451 open timeout on %s", fname);
-               return;
+               return ETIMEDOUT;
        }
        ev = setevent((time_t) 60, includetimeout, 0);
 
        }
        ev = setevent((time_t) 60, includetimeout, 0);
 
@@ -690,14 +691,16 @@ include(fname, forwarding, ctladdr, sendq, e)
        {
                /* don't use this .forward file */
                clrevent(ev);
        {
                /* don't use this .forward file */
                clrevent(ev);
-               return;
+               return EPERM;
        }
 
        fp = fopen(fname, "r");
        if (fp == NULL)
        {
        }
 
        fp = fopen(fname, "r");
        if (fp == NULL)
        {
+               int ret = errno;
+
                usrerr("Cannot open %s", fname);
                usrerr("Cannot open %s", fname);
-               return;
+               return ret;
        }
 
        if (getctladdr(ctladdr) == NULL)
        }
 
        if (getctladdr(ctladdr) == NULL)
@@ -734,6 +737,7 @@ include(fname, forwarding, ctladdr, sendq, e)
        (void) fclose(fp);
        FileName = oldfilename;
        LineNumber = oldlinenumber;
        (void) fclose(fp);
        FileName = oldfilename;
        LineNumber = oldlinenumber;
+       return 0;
 }
 
 static
 }
 
 static
index d131d26..dfb40d3 100644 (file)
@@ -5,7 +5,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)sendmail.h  5.44 (Berkeley) %G%
+ *     @(#)sendmail.h  5.45 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -15,7 +15,7 @@
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
-static char SmailSccsId[] =    "@(#)sendmail.h 5.44            %G%";
+static char SmailSccsId[] =    "@(#)sendmail.h 5.45            %G%";
 # endif lint
 # else /*  _DEFINE */
 # define EXTERN extern
 # endif lint
 # else /*  _DEFINE */
 # define EXTERN extern
@@ -635,6 +635,7 @@ EXTERN char *TimeZoneSpec;  /* override time zone specification */
 EXTERN bool    MatchGecos;     /* look for user names in gecos field */
 EXTERN int     MaxMciCache;    /* maximum entries in MCI cache */
 EXTERN time_t  MciCacheTimeout;        /* maximum idle time on connections */
 EXTERN bool    MatchGecos;     /* look for user names in gecos field */
 EXTERN int     MaxMciCache;    /* maximum entries in MCI cache */
 EXTERN time_t  MciCacheTimeout;        /* maximum idle time on connections */
+EXTERN char    *ForwardPath;   /* path to search for .forward files */
 \f/*
 **  Trace information
 */
 \f/*
 **  Trace information
 */
index c1ba853..4989f62 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)version.c  5.131 (Berkeley) %G%";
+static char sccsid[] = "@(#)version.c  5.132 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-char   Version[] = "5.131";
+char   Version[] = "5.132";