Article View: comp.mail.misc
Article #5102Re: Getting the most out of pathalias
From: Erik E. Fair
Date: Fri, 06 Jan 1989 08:28
Date: Fri, 06 Jan 1989 08:28
268 lines
7250 bytes
7250 bytes
*** sendmail/src/sendmail.h.orig Wed Jul 23 18:27:00 1986
--- sendmail/src/sendmail.h Thu Feb 26 18:46:07 1987
***************
*** 321,326 ****
--- 325,336 ----
# define HOSTBEGIN '\035' /* hostname lookup begin */
# define HOSTEND '\036' /* hostname lookup end */
+ #if defined(DBM) && defined(UUCPDOMAIN)
+ /* brace characters for uucp name lookup */
+ # define UUCPBEGIN '\016' /* uucpname lookup begin */
+ # define UUCPEND '\017' /* uucpname lookup end */
+ #endif
+
/* \001 is also reserved as the macro expansion character */
/*
** Information about hosts that we have looked up recently.
***************
*** 531,536 ****
--- 543,549 ----
EXTERN char *mxhosts[MAXMXHOSTS+1]; /* for MX RRs */
EXTERN char *TrustedUsers[MAXTRUST+1]; /* list of trusted users */
EXTERN char *UserEnviron[MAXUSERENVIRON+1]; /* saved user environment */
+ EXTERN char *PaliasFile; /* location of pathalias file */
/*
** Trace information
*/
*** sendmail/src/daemon.c.orig Wed Jul 23 18:27:01 1986
--- sendmail/src/daemon.c Wed Mar 18 13:18:36 1987
***************
*** 604,606 ****
--- 607,712 ----
}
#endif DAEMON
+
+ #if defined(DBM) && defined(UUCPDOMAIN)
+ /* XXX */
+ #ifdef sun
+ #undef NULL
+ #endif
+ #include <dbm.h>
+ /* XXX */
+ #ifdef sun
+ #undef NULL
+ #define NULL 0
+ #endif
+
+ /*
+ ** PATHALIAS -- return the shortest path to this host.
+ **
+ ** Parameters:
+ ** hbuf -- a buffer containing a hostname.
+ **
+ ** Returns:
+ ** The shortest known path to this host.
+ **
+ ** Side Effects:
+ ** none.
+ */
+ datum
+ pathalias(hbuf)
+ register char *hbuf;
+ {
+ register char *bptr;
+ register datum hdatum;
+
+ hdatum.dptr = hbuf;
+ hdatum.dsize = strlen(hbuf) + 1;
+ hdatum = fetch(hdatum);
+ if (hdatum.dptr != NULL)
+ if ((bptr = rindex(hdatum.dptr, '%')) == NULL ||
+ *(bptr + 1) != 's')
+ hdatum.dptr = NULL;
+ else if (*(bptr + 2) == '@')
+ /* path!%s@host -> path!host!%s */
+ (void) sprintf(bptr, "%s!%%s", bptr + 3);
+ return hdatum;
+ }
+
+
+ /*
+ ** MAPUUCPHOSTNAME -- turn a hostname into the shortest uucp path
+ **
+ ** Parameters:
+ ** hbuf -- a buffer containing a hostname.
+ ** hbsize -- the size of hbuf.
+ **
+ ** Returns:
+ ** none.
+ **
+ ** Side Effects:
+ ** Looks up the host specified in hbuf. Replace it
+ ** with the shortest uucp path to that host.
+ */
+ mapuucpname(hbuf, hbsize)
+ register char *hbuf;
+ register int hbsize;
+ {
+ register char *bptr;
+ register datum hdatum;
+ register bool mapped = FALSE;
+
+ makelower(hbuf);
+ hdatum = pathalias(hbuf);
+ if (hdatum.dptr != NULL && hdatum.dsize <= hbsize) {
+ (void) strcpy(hbuf, hdatum.dptr);
+ return;
+ }
+ if ((bptr = rindex(hbuf, '.')) == NULL)
+ return;
+ if (strncmp(bptr, ".uucp", sizeof ".uucp") == 0) {
+ /* try host with .uucp removed */
+ *bptr = '\0';
+ hdatum = pathalias(hbuf);
+ *bptr = '.';
+ if (hdatum.dptr != NULL && hdatum.dsize <= hbsize)
+ (void) strcpy(hbuf, hdatum.dptr);
+ }
+ else
+ {
+ /* keep removing left-most subdomain until a match is found */
+ for (bptr = hbuf;
+ !mapped && (bptr = index(++bptr, '.')) != NULL;
+ mapped = hdatum.dptr != NULL &&
+ hdatum.dsize + strlen(hbuf) + 1 <= hbsize)
+ hdatum = pathalias(bptr);
+ if (!mapped || (bptr = rindex(hdatum.dptr, '!')) == NULL)
+ return;
+ *bptr = '\0';
+ if ((bptr = malloc(strlen(hbuf) + 1)) != NULL) {
+ (void) strcpy(bptr, hbuf);
+ (void) sprintf(hbuf, "%s!%s!%%s", hdatum.dptr, bptr);
+ (void) free(bptr);
+ }
+ }
+ }
+ #endif
*** sendmail/src/main.c.orig Thu Jan 30 14:03:53 1986
--- sendmail/src/main.c Mon Jan 26 14:33:20 1987
***************
*** 808,813 ****
--- 812,822 ----
/* and finally the hostname lookup characters */
'[', HOSTBEGIN, ']', HOSTEND,
+ #if defined(DBM) && defined(UUCPDOMAIN)
+ /* and the uucpname lookup characters */
+ '{', UUCPBEGIN, '}', UUCPEND,
+
+ #endif
'\0'
};
*** sendmail/src/parseaddr.c.orig Wed Apr 2 19:04:03 1986
--- sendmail/src/parseaddr.c Wed Mar 18 12:10:50 1987
***************
*** 741,747 ****
--- 741,751 ----
char pvpbuf[PSBUFSIZE];
extern char *DelimChar;
+ #if defined(DBM) && defined(UUCPDOMAIN)
+ if (**rvp != HOSTBEGIN && **rvp != UUCPBEGIN)
+ #else
if (**rvp != HOSTBEGIN)
+ #endif
continue;
/*
***************
*** 753,759 ****
--- 757,769 ----
hbrvp = rvp;
/* extract the match part */
+ #if defined(DBM) && defined(UUCPDOMAIN)
+ while (*++rvp != NULL &&
+ (**rvp != HOSTEND && **hbrvp == HOSTBEGIN ||
+ **rvp != UUCPEND && **hbrvp == UUCPBEGIN))
+ #else
while (*++rvp != NULL && **rvp != HOSTEND)
+ #endif
continue;
if (*rvp != NULL)
*rvp++ = NULL;
***************
*** 764,770 ****
--- 774,801 ----
/* look it up */
cataddr(++hbrvp, buf, sizeof buf);
+ #if defined(DBM) && defined(UUCPDOMAIN)
+ if (**(hbrvp - 1) == HOSTBEGIN)
+ maphostname(buf, sizeof buf);
+ else
+ {
+ #ifdef sun
+ (void) dbmclose();
+ #endif
+ if (dbminit(PaliasFile) == 0)
+ #ifdef sun
+ {
+ #endif
+ mapuucpname(buf, sizeof buf);
+ #ifdef sun
+ (void) dbmclose();
+ }
+ #endif
+ (void) dbminit(AliasFile);
+ }
+ #else
maphostname(buf, sizeof buf);
+ #endif
/* scan the new host name */
olddelimchar = DelimChar;
*** sendmail/src/alias.c.orig Thu Apr 17 23:18:56 1986
--- sendmail/src/alias.c Mon Jan 26 14:26:42 1987
***************
*** 92,97 ****
--- 92,100 ----
p = aliaslookup(a->q_user);
if (p == NULL)
return;
+ #if defined(DBM) && defined(UUCPDOMAIN)
+ p = newstr(p);
+ #endif
/*
** Match on Alias.
*** sendmail/src/Makefile.orig Wed Jul 23 18:29:21 1986
--- sendmail/src/Makefile Sat Feb 14 13:23:50 1987
***************
*** 36,42 ****
CHMOD= chmod
O= -O
COPTS=
! CCONFIG=-I../include -DVMUNIX -DMXDOMAIN -DOLDJEEVES
CFLAGS= $O $(COPTS) $(CCONFIG)
ASMSED= ../include/asm.sed
AR= -ar
--- 36,42 ----
CHMOD= chmod
O= -O
COPTS=
! CCONFIG=-I../include -DVMUNIX -DMXDOMAIN -DOLDJEEVES -DUUCPDOMAIN
CFLAGS= $O $(COPTS) $(CCONFIG)
ASMSED= ../include/asm.sed
AR= -ar
*** sendmail/src/readcf.c.orig Sat Jan 11 03:18:47 1986
--- sendmail/src/readcf.c Thu Feb 26 18:41:55 1987
***************
*** 913,918 ****
--- 913,925 ----
WkTimeFact = atoi(val);
break;
+ case 'p': /* pathalias file */
+ if (val[0] == '\0')
+ PaliasFile = "palias";
+ else
+ PaliasFile = newstr(val);
+ break;
+
default:
break;
}
Technical Details
Message-ID:
<23433@apple.Apple.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!tut.cis.ohio-state.edu!rutgers!apple!fairReferences:
<601@ur-cc.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!tut.cis.ohio-state.edu!rutgers!apple!fair From: fair@Apple.COM (Erik E. Fair) Newsgroups: comp.mail.misc Subject: Re: Getting the most out of pathalias Summary: sendmail source diffs (part 3 of 4) Message-ID: <23433@apple.Apple.COM> Date: 6 Jan 89 08:28:22 GMT References: <601@ur-cc.UUCP> Organization: USENET Protocol Police, Western Gateway Division Lines: 268