[mod.sources] Addition to Msg distribution...

sources-request@panda.UUCP (03/15/86)

Mod.sources:  Volume 4, Issue 34
Submitted by: hplabs!hpcnou!dat (Dave Taylor)


Oops! I forgot this;

[save as doc/Alias.guide.  Format with "mm" ]

'
'  A guide to the MSG alias system and so on.
'  format with 'nroff -mm Alias.guide > Alias.format'
'  or something similar.
'  (C) Copyright 1986 Dave Taylor
'
'  reachable at ..hpfcla!d_taylor
'  or HP - CNO, 3404 E. Harmony Rd, Fort Collins, CO, 80525
'  (303) 229-2419
'
'  Last modification: March 3rd, 1986
'
.SA 1
.nr Hy 1
.nr Pt 1
.PH ""
.PF "''Page \\\\nP'"
.HM 1 1
.ce 3
A Users Guide to the 
MSG Alias System
.sp
.ce 999
(C) Copyright 1986, by
Dave Taylor
.sp
\*(DT
.ce 0
.sp
.P
This document is intended as a supplement to the \fBMsg Users Guide\fR
and is only of interest to those users desiring more knowledge
about how aliases work and how to create strange and exciting
aliases for their systems (alright, so it's not \fIthat\fR exciting!)
.sp
.P
This document is broken up into the following sections;
user aliases,
group aliases,
system aliases,
editing and installing new aliases,
the machine routing database,
and general warnings and other chitchat.
.sp
.H 1 "User Aliases"
The most simple sort of aliases in the \fBMsg\fR system are individual
user aliases.  These are made up of three parts;
.nf

	<aliasname list> : <username> : <address>

.fi
Where the \fIalias list\fR is either a single aliasname*
.FS *
Please see the appendix for a full definition of what exactly an
aliasname consists of.
.FE
or a list of aliasnames separated by commas.
.P
\fIUsername\fR is currently a comment field, and is used to indicate
the full "real name" that the alias is for.  For example, if you had
an alias for "dat" to get to me, the \fIusername\fR field would
contain "Dave Taylor" or perhaps "Dave Taylor, HP" or some other
permutation of that.  In a future release of the mailer, the alias
system will know about this field and include it in outgoing messages
AND as a supplement to the usual list of aliasnames. 
.P
\fIAddress\fR is either the users full electronic mail address or, if
the machine routing database is installed, the minimum address needed
to specify the destination.  For example, say our routing database
contained information on how to get to machine "hp-sdd" and I wanted
to have an address for my friend Ken there - I could have his address
specified as simply "ken@hp-sdd" (or alternatively "hp-sdd!ken" since
the two are functionally equivalent).
.sp
.P 0
Let's get on to some examples, shall we?
.sp
Consider this excerpt from my own \fB.alias_text\fR file;
.nf

 wunder,walt   : Walt Underwood  : wunder@hpcea
 laubach       : Mark Laubach    : laubach@hpcea
 mary          : Mary Hsia-Coron : hsia@hpindla
 decot         : Dave Decot      : decot@hpda
 	
 jeff	       : Jeff Wu         : hpcnoe!j_wu
 dave	       : Dave Barrett    : hpcnof!d_barrett

.fi
Note that the alias for Walt Underwood has two aliasnames associated
with it, "wunder" and "walt".  Also notice that the first four aliases
use the ARPA style naming convention (user@machine) but the last two
use the UUCP style convention (machine!user).  In this context it is
independent.
.P
The only time when it \fIdoes\fR make a difference which notation you
use is if you have to specify more than the machine that the user is
receiving mail on.  That is, say we have a friend who receives mail at
a machine called "twinkie" and our best connection is through Georgia
Tech...Then our alias for them could be;
.nf

  buddy         : Our friend      : gatech!twinkie!buddy

or

  buddy2        : Our friend      : gatech!buddy@twinkie

.fi
but not;
.nf

  buddy         : Our friend      : buddy@twinkie@gatech

.fi
(however, buddy%twinkie@gatech \fIwill\fR also work, but that's far
too bizarre a notation to be recommended!!) (besides there's no
guarantee that "gatech" will like it, nor the "buddy2" alias above!)
.P
Anyway, suffice to say that if you must specify any sort of route
that you should use the uucp notation as much as possible to ensure
that the \fBMsg\fR system expands the correct machine name.
.sp
.H 1 "Group Aliases"
After the confusion of user aliases, group aliases are even more 
fun!  For the most part the notation is very similar;
.nf

	<aliasname list> : <groupname> : <list of people>

.fi
Where \fIaliasname list\fR and \fIgroupname\fR are exactly equivalent
to the corresponding fields in user aliases.
.P
The interesting part is the \fIlist of people\fR field!  This
field is actually in the same notation as the aliasname list,
so it's not quite as strange as I've lead you to believe.
It's best to illustrate by example;
.nf

friends, mypals, gang : The Gang of Six : joe, larry, mary, joanna,
					  nancy, michael

.fi
(Notice that you can continue onto as many lines as you'd like so
long as each additional line start with either a SPACE or a TAB
character)
.P
The significant limitation with group aliases is that each of the
people in the list must be a \fBpreviously defined aliasname in either the
existing alias file or the system alias file\fR or a valid destination
on the current machine.
.P
What does this mean?  This means that the following excerpt from an
alias file;
.nf

hawaii : The Hawaiian Twins : joe@RIT-CS.ARPA, maoa
maoa   : Maoa Lichtenski Jr : maoa@Hawaii.cs.uh.ARPA

.fi
will fail for two reasons - not only does the group \fIlist of people\fR
contain a complex address, but it also contains an aliasname that is 
defined \fIlater\fR in the \fB.alias_text\fR file!  ** BEWARE!!! **
.P
The correct way to have the previous alias in the file is to have it like;  
.nf

joe    : Joe Lichtenski     : joe@RIT-CS
maoa   : Maoa Lichtenski Jr : maoa@Hawaii
hawaii : The Hawaiian Twins : joe, maoa

.fi
which will then work correctly.
.P 0
This isn't too hard now, is it?
.sp
Fortunately, while this seems pretty tough, if you run the \fBnewalias\fR
command to install your new aliases, it will give you nice meaningful
error messages that will help you fix the list up correctly!
.sp
.H 1 "System Aliases"
System aliases are functionally equivalent to the individual \fBMsg\fR 
alias lists each \fBMsg\fR user has (both user aliases and group aliases) 
but are "read only" for everyone but the \fBMsg\fR administrator.  The 
format of the file is identical to the users file, and the only difference is
that this file is expected to be located in the directory that contains
the "system_hash_file" and "system_data_file" files (see the
\fBMsg Configuration Guide\fR for more details on these variables).
.P
Simply create a \fB.alias_text\fR file in the specific directory
as you would a normal file, and install it the same way (see the
following section for more details on that).  
.P
Voila!!
.sp
.H 1 "Editing and Installing New Aliases"
To install new aliases, you need merely to create, or modify,
your \fB.alias_text\fR file in your home directory until you're
satisfied with it and it meets the requirements stated above.
You can then try to install it with the command;
.nf

	$ \fBnewalias\fR

.fi
which will either report back the number of aliases installed into 
the system or will report errors indicative of the changes that
the program expects before it can accept the alias list.
.P
Note that blank lines are no problem and that comments are not only
allowed but actually encouraged, and must have \fB#\fR as the first
character of each comment line.
.sp
Finally, if you find that you're hitting the "Too many aliases" error, 
then you'll need to reconfigure the entire \fBMsg\fR system (again,
see the \fBMsg Configuration Guide\fR especially the discussion on
"MAX_UALIASES" and "MAX_SALIASES" therein).
.sp
.H 1 "The Hostname Routing Database"
Floating about on the various networks is a rather nifty program by
a number of people, including Peter Honeyman and Steve Bellovin, 
called "pathalias".  What this incredibly handy program does is 
take the strange postings in groups like "mod.map" and massage
them into a file of the form;
.nf

  <hostname>	<address>

.fi
which is then sorted alphabetically and stored in the file
pointed to by "pathfile" (guess where to look for more information!)
for \fBMsg\fR to use.
.P
If you don't have the program, or don't want to use it, you can 
simulate this file by listing machines in the same format.  The
exact format expected is;
.nf

  <hostname><tab><machine-address>

.fi
where hostname is a limited identifier (no special characters) and
machine-address MUST contain the sequence "%s" (and consequently
any other percent signs that appear in the address must be paired)
so that the call in the program "sprintf(buffer, machine-address, username)"
will generate a valid return address.
.P 0
By way of example, here are a few entries from my own file;
.nf

 HPL	    hplabs!%s
 PARC	    hplabs!%s@Xerox.PA.COM
 amc-hq	    hplabs!%s@AMC-HQ.ARPA
 imsss	    hplabs!%s%%IMSSS@SU-AI.ARPA
 infopro    hpfcla!ihnp4!astrovax!infopro!%s
 interleaf  hpfcdc!hpda!sun!interleaf!%s
 jpl-vax    hplabs!%s@jpl-vax

.fi
As you can see, the addresses can get pretty complicated!!  In fact
it's due purely to the complication that a database file of this
sort can be so wonderful!!
.sp
If you'd like further information on the pathalias program, try
keeping track of the entries in "mod.sources" - it's posted about
once a year or so...
.sp
.H 1 "Other Stuff not Covered Yet"
Probably the biggest question you have in your mind right now is
"But how the heck does this relate to the 'ole \fBmailx\fR
aliases and the snazzo \fBsendmail\fR alias system??"  Well,
rest assured, \fBsendmail\fR fans, that if you REALLY want to have
your aliases down in the transport you can.  No problem.  All you'll
need to do is to turn off the address validation routine in \fBMsg\fR
by defining the "NOCHECK_VALIDNAME" definition (I'm not even going to 
bother to tell you where to look for this one!!).
.P
For those \fBmailx\fR fanatics out there, you can translate your 
aliases into the format that \fBMsg\fR wants by running them
through the \fBawk\fR script listed in Appendix Two.
.sp
.P
Finally, if you have any problems or questions, try looking in 
the \fBnewalias\fR manual entry, or dropping me a line at the
"usual" email address (ask your administrator!).
.SK
.ce 99
Appendix One

A BNF of the Alias File Grammar
.ce 0
.sp 2
In this listing, items in <> brackets are non-terminals, items in {}
are optional, and items in \fBbold face\fR are terminals.
.sp 2
.nf

<alias_file>  ::=  <line> { <alias_file> }

<line>	      ::=  <comment> | <empty> | <alias>

<comment>     ::=  .. any sequence of characters starting with '#' ..

<empty>	      ::=  .. an empty line ..

<alias>	      ::=  <user alias> | <group alias>

<user alias>  ::=  <aliaslist> \fB:\fR { <comment> \fB:\fR } 
		   {<whitespace>} <address>

<group alias> ::=  <aliaslist> \fB:\fR { <comment> \fB:\fR } 
		   {<whitespace>} <list of addresses>

<aliaslist>   ::=  <aliasname> { \fB,\fR <aliaslist> }

<aliasname>   ::=  <alpha-char> { <sequence-of-chars> }

<comment>     ::=  .. anything other than ":" ..

<address>     ::=  <username> | <arpa-address> | <uucp-address> | 
		   <complex-address>

<list-of-addresses> ::= <aliasname> { \fB,\fR <whitespace> } 
			{ <list-of-addresses> }

<username>    ::=  .. any valid mailbox name on the system ..

<arpa-address> ::= <username> ( \fB@\fR <hostname> | <postfix> )

<hostname>    ::=  .. any legal host machine name ..

<uucp-address> ::= <hostname> \fB!\fR <username>

<complex-address> ::= <prefix> ( <uucp-address> | <arpa-address> )

<prefix>      ::= <hostname> \fB!\fR { <prefix> }

<postfix>     ::= \fB%\fR <hostname> { <postfix> } \fB@\fR 
		  <hostname>

<sequence-of-chars> ::= .. any characters other than space, tab, 
		           return, or colon ..

<whitespace> ::= .. space, tab or newline followed by space or tab ..

.fi
.SK
.ce 99
Appendix Two

An AWK Script for 
Translating Aliases from a
".mailrc" Format to a
Msg Format
.ce 0
.sp 2
.nf
.ce
-------------------------------------------------------------------

BEGIN { 
	print "# MSG alias_text file, from a .mailrc file..." 
	print ""
      }

next_line == 1 { 

	next_line = 0;
        group = ""
	for (i = 1; i <= NF; i++) {
	  if (i == NF && $i == "\\\\") sep = ""
	  else                       sep = ", "
	
	  if ($i == "\\\\") {
	    group = sprintf("%s,", group)
	    next_line = 1;
	  }
	  else if (length(group) > 0)
	    group = sprintf("%s%s%s", group, sep, $i);
	  else
	    group = $i;
	  }
	  print "\\t" group

	}

$1 ~ /[Aa]lias|[Gg]roup/ { 

	if ( NF == 3)
	  print $2 " : user alias : " $3;
	else {
	  group = ""
	  for (i = 3; i <= NF; i++) {
	    if (i == NF && $i == "\\\\") sep = ""
	    else        sep = ", "
	
	    if ($i == "\\\\") {
 	      group = sprintf("%s,", group)
 	      next_line = 1;
	    }
	    else if (length(group) > 0) 
 	      group = sprintf("%s%s%s", group, sep, $i);
	    else
 	      group = $i;
	    }
	    print $2 " : group alias : " group;
	  }
 	}

.ce
-------------------------------------------------------------------
.fi
.P
Note: this script is contained in the release under the name 
"mailrc.awk" in the utilities directory "utils".