Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!pasteur!ucbvax!ucsd!ucsdhub!hp-sdd!ncr-sd!ncrlnk!ncrpcd!wright!jsloan@wright.UUCP From: jsloan@wright.UUCP (John Sloan) Newsgroups: comp.mail.uucp Subject: Re: Sendmail and pathalias Message-ID: <286@thor.wright.EDU> Date: 26 Aug 88 12:27:01 GMT References: <13206@mimsy.UUCP> Sender: news@wright.EDU Reply-To: jsloan@wright.UUCP Lines: 394 From article <13206@mimsy.UUCP>, by chris@mimsy.UUCP (Chris Torek): : > have sendmail `deliver' everything to a program that does the routing, > then hands the message back to sendmail for *real* delivery. You have > to pick some `unlikely' string to distinguish between first-time > addresses and routed addresses (`host.ROUTING-TRASH'? :-) ). This is a kludge, but it works, and it works well if you're a binary only site. We have been using a program, "dnagent", since December of '86 that does just this. We recently replaced uumail with smail, and we hope to replace dnagent's functionality with smail sometime RSN, but for now it solves our problems. Dnagent appears to be a mailer to Sendmail. It receives a message, takes the recepient address, rewrites the envelope based on what it finds in a dbm database that is maintained with a combination of cron'ed scripts and manual intervention, and resubmits it to Sendmail. We were having it do translation of @ addresses into paths, but it turned out easier to let uumail/smail to that instead. Dnagent's not perfect but it solved our problems with routing domain-style addresses between CSNET, UUCP, and local machines. I'll include the man page here. DNAGENT(8) MAINTENANCE COMMANDS DNAGENT(8) NAME dnagent - RFC920 domain network mailer agent for Sendmail SYNOPSIS dnagent -b [ -l ] [ -ddb ] dnagent -a [ -l ] [ -ddb ] dnagent -l [ -ddb ] dnagent [ -x ] [ -f from ] [ -v ] [ -Ccf ] [ -ddb ] -u address [ address ...] mailagent [ arguments ] DESCRIPTION The Domain-Network Agent is an middle-end to the Sendmail program. When Sendmail identifies a host or organization domain which it cannot resolve internally, it delivers the message to the Dnagent mailer. Dnagent resolves destination addresses by querying a DBM database containing rewrite strings for a key which matches the host-domain portion of the address. If a match cannot be found, Dnagent retries the query with the next higher order portion of the domain (if one exists), scanning from left to right. If a match cannot be found before the address is exhausted, Dnagent can fetch a default rewrite string from the database. This rewrite string is applied only to the destination address(es) on the outer envelope as specified by Sendmail as arguments on the command line when it forks and executes the Dnagent mailer. Addresses in the RFC822 compliant headers in the text of the message are passed through undis- turbed. Rewrite strings may contain macros which are expanded to be the user portion of the address, the domain portion, that part of the domain which matched a key, and conditional expansions which depend upon whether the full domain and the matched key are the same. Once the addresses are rewritten, Dnagent resubmits the mes- sage, with the new outer envelope, to Sendmail for further processing. Several iterations may be made until Sendmail recognizes an address which it can resolve. The number of iterations can be tuned by adding additional rulesets to the Sendmail configuration file, or by making the rewrite strings in the Dnagent database more explicit. When different switches are applied to the Dnagent mailer, the same program may build, append, and dump the database. The database entries are derived from several sources: tables available from the CSNET Info Server, the USENET Pathalias database, and local entries. Sun Release 3.4 Last change: Thu Feb 4 10:26:32 EST 1988 1 DNAGENT(8) MAINTENANCE COMMANDS DNAGENT(8) A debugging mailer, Mailagent, is also included. Mailagent simply echoes all of its command line arguments and standard input to standard error. It is useful for debugging new mailers or examing the behavior of Sendmail. Both Dnagent and Mailagent have been in use as production software for nearly a year as of this writing. Options -b Read standard input for domain-rewrite string pairs and (re)build a new Dnagent database. -a Read standard input for domain-rewrite string pairs and add to an existing Dnagent database. -l List the contents of an existing Dnagent database to standard output. This can be combined with the -b or -a options. -u recepient [ recepient ... ] Read a message on standard input and submit to Sendmail to mail to a list of recepients, where each recepient is an address of the form user@domain. This is the form of the command that is used in the Sendmail mailer definition. -ddatabase Specify an alternative Dnagent database named database. The root name of the default database is /usr/spool/sites/dnagent. -x Use debug mode, tracing the parsing of each domain and dumping the resulting Sendmail command to standard out- put instead of executing it. -f sender Specify the from address as sender (passed along to Sendmail). -v Specify verbose mode on mail delivery (passed along to Sendmail). This is useful in debugging. -Cconfiguration Specify an alternative Sendmail configuration file to use (passed along to Sendmail). -oddeliverymode Spefify an alternative delivery mode (passed to Send- mail). This allows you to, for example, run all pri- mary mail delivery immediately, but to delay processing of Dnagent output until a Sendmail queue run. Sun Release 3.4 Last change: Thu Feb 4 10:26:32 EST 1988 2 DNAGENT(8) MAINTENANCE COMMANDS DNAGENT(8) Input Format Input to the build function of Dnagent consists of lines each containing a domain and rewrite string pair seperated by white space. The rewrite string is in printf format, with the addition of special string substitution parameters shown below. A domain does not include a leading period (unlike pathalias). A rewrite string can be any legal string that does not con- tain any printf control strings. For example, if you want to include a percent sign in your output address, you must dou- ble it ("%%"), just as you would in a printf string. The rewrite string may contain the following parameters, which will be filled in at run time with the appropriate informa- tion gleaned from the recepient address. $u User portion of the address. $d Domain portion of the address. $m Trailing portion of the domain that matched in the database. $% Same as "%$d" if $d!=$m, "" otherwise. $! Same as "$d!" if $d!=$m, "" otherwise. Example Input edu $u%%$d@CSNet-Relay.CSNET cs.wright.edu $u vlsi.ceg.wright.edu $u@poly.LOCAL cbosgd.att.com cbosgd!$!$u arthur.cs.purdue.edu cbosgd!ihnp4!purdue!$!$u asc.purdue.edu $u%%$d@CSNet-Relay.CSNET purdue.edu $u%%$d@CSNet-Relay.CSNET Sample Invocations dnagent -v -x -u jsloan@spots.wright.edu < /dev/null Test an address for resolution using debug and verbose mode. dnagent -b Build a Dnagent database from a list of domain-rewrite string pairs read from standard input. dnagent -l -d/usr/local/lib/dnagent Dump a Dnagent database to standard output, using a database different from the default. dnagent -C/usr/lib/test.cf -u jsloan@spots.wright.edu Resolve an address and pass along to Sendmail using a different configuration file from the default. Sun Release 3.4 Last change: Thu Feb 4 10:26:32 EST 1988 3 DNAGENT(8) MAINTENANCE COMMANDS DNAGENT(8) Sendmail Examples Here are some sample Sendmail classes, rules, and mailer definitions for Dnagent and Mailagent. For more complete examples, see the Wright State University SPOTS Sendmail Kit. # define top-level domains CICOM EDU GOV MIL NET ORG AU IL FR JP KR NL SE UK US # resolve RFC920 addresses in ruleset zero to Dnagent R$*<@$*$=I> $#dnagent$@$2$3$:$1@$2$3 user@domain.top # resolve test addresses in ruleset zero to Mailagent R$*<@$*TEST> $#test$@$2$:$1@$2 user@any.TEST # define Dnagent mailer Mdnagent, P=/usr/local/mail/dnagent, F=nsmDFef, A=dnagent -v -u $u # define Mailagent mailer Mtest, P=/usr/local/mail/mailagent, F=FDMxPf, A=email -g $g -f $f -x $x -h $h -u $u -q $q -j $j Background The domainization of the Internet specified in RFC920 has inspired other networks, such as CSNET and USENET, to adopt the same addressing standard. Internet sites have (nearly) real-time access to systems which support the RFC920 name server function. Sites on these other, affiliated, networks rely on source routing for the delivery of domain-addressed mail. Unfortunately this scheme poses problems for non- Internet sites using 4.2BSD Sendmail, the Berkeley mail routing mechanism, and which connect to more than one net- work (for example, CSNET/Phonenet and USENET). o Vanilla 4.2BSD Sendmail does not provide a table lookup scheme for RFC920-compliant domains in addresses. o Binary licensees may not be able to modify Sendmail to implement such a facility. Source licensees may lack the expertise to do so. o Tables of host names used in Sendmail to provide user- friendly resolution of simple addresses become large and cumbersome as networks such as CSNET, USENET, BIT- NET, etc. continue to grow. These tables are kept memory resident, so that Sendmail requires more and more virtual address space as it runs slower and slower. o Addition or modification of host entries is a poten- tially lengthy process, as the configuration must be Sun Release 3.4 Last change: Thu Feb 4 10:26:32 EST 1988 4 DNAGENT(8) MAINTENANCE COMMANDS DNAGENT(8) thawed and refrozen and the Sendmail daemon restarted. o Bouncing all unresolved messages to the CSNET relay may result in extra hops, even when the destination machine is a nearby USENET site. o Bouncing all unresolved messages to a USENET backbone site may result in extra hops until it reaches a USENET machine on the Internet. Some (most) USENET sites may not understand RFC920-compliant addresses. o While explicit resolution of domains may be possible in the Sendmail rulesets, as is done in the JANET Sendmail kit, such a solution can be unwieldy and could exhaust various resources. o While the resolution of domains through software replacing the normal mail utilities is possible, as is done in the smail program, such solutions often circum- vent the logic in the Sendmail configuration file, where much of the strategic decisions regarding routing may be made, and they are often specific to a particu- lar networking protocol, and so are not of as much use for sites with a variety of local area and wide area networks. (We may note that we have used smail quite successfully on machines which do not have Sendmail, and/or which are peripheral to our main campus mail relay). While better software will surely come along with time, non-Internet sites need a temporary, interim solution. Dnagent is an attempt at such a solution. Advantages o It requires no source changes other than to the Send- mail configuration file (which is distributed as source). o It allows domains to be mapped to arbitrary machines on either wide or local area networks. The mapping is more easily maintained than would be possible with a Sendmail-only solution. o It does not disturb the RFC920-compliant addresses in the message headers. o The Sendmail configuration file can be significantly shorter, usually resulting in a faster parsing of addresses. Disadvantages o Mail delivery can be slow, especially if several Sun Release 3.4 Last change: Thu Feb 4 10:26:32 EST 1988 5 DNAGENT(8) MAINTENANCE COMMANDS DNAGENT(8) iterations are necessary. Since Dnagent is not closely integrated into Sendmail, system overhead can be rela- tively high. o It is one more program and database that the system support staff must understand and manage. o Parsing and rewriting addresses in the message headers based on information in the database, either by Dnagent or Sendmail, is not an option. This could cause prob- lems with older mailers which require a UUCP flavored From_ line. Acknowledgements Dnagent was inspired by alias.c and newaliases.c by Eric Allman (Britton-Lee Inc.), opath.c by Eric Roskosm (Perkin- Elmer Corp.), and getpath.c and uumail.c by Stan Barber (Baylor College of Medicine). No code borrowed, but a lot of good ideas used. FILES /usr/spool/sites/dnagent.dir default Dnagent DBM database /usr/spool/sites/dnagent.pag default Dnagent DBM database SEE ALSO pathalias(1l), sendmail(8), uumail(8l) AUTHOR John Sloan , The SPOTS Group, Department of Computer Science and Engineering, Wright State University Research Building, 3171 Research Blvd., Ketter- ing, Ohio, 45420 John Sloan +1 513 259 1384 Wright State University Research Center jsloan%wright.edu@csnet-relay 3171 Research Blvd., Kettering, OH 45420 ..!ucsd!ncr-sd!ncrlnk!ncrpcd!wright!jsloan ...!osu-cis!wright!jsloan Logical Disclaimer: belong(opinions,jsloan). belong(opinions,_):-!,fail.