|
The Alias File in JNOS
|
|||||||||||||
|
Commentary : One of the original objectives of porting JNOS to Linux was to isolate the networked application from the host OS, thus promoting security. While this is certainly desirable, it often seems ironic that JNOS would be prevented from accessing the full power of a network oriented OS where "strategic alliances" could dramatically expand its capability. As it stands, there are only a few unconventional "avenues" into the JNOS application, and one of them happens to be through the alias file. |
How do you put the alias file to work on your system; and what different kinds of jobs can it do? We'll take a look at how you can expand a typical alias, an exisiting local mailbox user or a non-existent aliased name, into a full email internet address or another local mailbox name. We'll see how you can set up a mailing list. We'll also take a look at redirecting incoming mail to the Linux OS mail system and possibly redirecting it, or a copy, yet again to another machine on a LAN, or forwarding a modified version of the original document to another destination using procmail...
Of course, many of these operations could be implemented using the rewrite file, but the alias file can keep things simple, and has the added capability of being able to be queried from a telnet session on port 25 since it is so tightly coupled to the smtp server...
- Expanding a "Nickname" or a First Name or a Callsign
All hams are known by their callsigns, but often operators are more easily recognized by their first names or other more personal "handles." Suppose operator KA1TUK is named "Larry." The entry in the alias file to reach Larry via smtp mail would be:
- Larry ka1tuk@ka1tuk.ampr.org
...where the name Larry, the alias database key, would begin in the first column and the actual email address, the content field, would be separated by exactly one space. (A tab is OK here too.) Note that the alias key cannot contain the "@" symbol, implying that the name Larry is a local user, or is associated with a local user's mailbox. For example, you could have just as easily used ka1tuk as the alias key, which in this case is actually Larry's local mailbox on the JNOS system. (But, there may not be a mailbox named Larry... so used as above, it is a true alias, a symbolic reference to a real object.)
Now from the JNOS BBS, you only need to enter "sp Larry" to begin your email session. Just before your document is placed in the outgoing queue, the "swap" is made substituting the full address for "Larry."- Setting up a Mailing List
Suppose you routinely send out documents or information to a group of users. Can you instruct the alias file how to do that? And of course, you can. The alias key would be the name of your list, such as: wxgroup, followed by a listing of hams who like to hear about local weather alerts. The entry might look like this:
- wxgroup ham1@ham1 ham2@ham2 ham3@ham3
...where hamx@hamx would be real callsigns each separated by exactly one space as above. Note, if the list is long, you may begin another line below, but it must begin with a space in column one to indicate that this data string is being continued and is to be read as all one item. (Note, you can get away with just the domain callsign names if your domain suffix is set to ".ampr.org." which will append this to the end of the callsign creating an FQDN, a fully qualified domain name.)
And again, as above, you would begin a mail session with "sp wxgroup" to send a copy to each of the recipients. If you look in the mail send queue from the JNOS command console, using "sm li" you will see each one listed and waiting to go...
If you wish a copy of this transaction, you may append a local mail account name such as: outtray, outbound, sent-mail, or even archive to the above mailing list entry in the alias file. This account will store a copy of each email sent out on that mailing list. (If that seems excessive, you can alternatively just include your own smtp email address, you@here, and this should give you a single copy as though you were only another user in the list, reducing needless duplication.)- Forwarding Incoming Mail
So far this alias file seems very straightforward and benign, but now the fun begins! Whenever the possibility of forwarding arises, things can quickly spin out of control! However, if managed carefully, this function presents welcome opportunities to the system administrator. Remember, the alias file is one way to keep things simple. It may not be as "fancy" or as powerful as the re-write file, but it is probably much easier to read and therefor to maintain.
A simple, and sometimes very useful, example of a forward might be this:
- sysop root@jnoshost.ampr.org
...where jnoshost.ampr.org is the name of the machine on which you are running your JNOS application. Any mail addressed to sysop, and delivered to this JNOS mailbox first, will now be forwarded to the root account on the Linux host machine. There will be no trace of it left in the JNOS mail area. It will have moved on to the Linux side, the root account or some other account of your choosing on Linux. (You may not want to send it to root, but perhaps a callsign account like ka1fsb, or a parallel sysop account.)
If you run a LAN and have your JNOS machine attached to your desktop or laptop, you may include that address as well:
- sysop root@jnoshost.ampr.org root@laptop.ampr.org
Now when someone writes to sysop, two copies of this letter will be forwarded and stored on Linux machines: one on the JNOS host and one on the laptop machine. If you have "biff" on, which toots when mail arrives, you will hear the closer of these machines alerting you to mail delivery.
What if you wanted to retain a copy on the JNOS system. According to the manual, you may duplicate the key, the local sysop account name here or any real user mailbox name, anywhere in the data field:
- sysop root@jnoshost.ampr.org root@laptop.ampr.org sysop
Since this file is only read once, there should be no mail loops. A mail loop, as you know, just keeps sending the mail in circles infinitely. (A better choice might be a local account named "archive" which would store a copy of all mail forwarded by the alias file when sent to that local mailbox account.- Combining the Alias File with Procmail
As seen in the above example, it is easy to forward JNOS mail to the Linux OS mail system. And here is where the full power of Linux may be brought to bare via procmail. Procmail works with sendmail to coordinate the delivery of incoming mail, which may include additional internet forwarding. So the alias file can be a bridge to the "outside" world!
Below is an excerpt from my .procmailrc file on the host bambi.ampr.org in the /root directory. The JNOS alias file is set to forward all mail for ka1fsb to root@bambi.ampr.org:
- ka1fsb root@bambi.ampr.org
Whenever there is mail arriving at the JNOS machine for ka1fsb, it gets forwarded to the root account on bambi. The .procmailrc control file for procmail redirects mail "^From" certain senders and deposits all others in the Linux mailbox ka1fsb on bambi. In most cases, files that are forwarded are also kept on bambi as backups.
# 10-07-02 # /root/.procmailrc on bambi.ampr.org # -------------------------------------------------------------- # Filter and distribute... # This is for the bambi and JNOS machines, generally no spam! # Now forwards some of the hams to .10 machine # -------------------------------------------------------------- MAILDIR=$HOME/Mail DEFAULT=$MAILDIR/mbox SENDMAIL=/usr/bin/sendmail #----- Start of "known" users... :0 * ^From.*wa8rsa { :0 c | formail -A"X-Return-To: dave@some_smtp_address.net" | \ $SENDMAIL -t root@ka1fsb-10.ampr.org :0 wa8rsa } :0 * ^From.*ka1tuk ka1tuk :0 * ^From.*w1gmf { :0 c | $SENDMAIL -t root@ka1fsb-10.ampr.org :0 w1gmf } :0 * ^From.*ve1ama { :0 c | formail -A"X-Return-To: ve1ama@rac.ca" | \ $SENDMAIL -t root@ka1fsb-10.ampr.org :0 ve1ama } #----- End of "known" users... :0: * ^TOka1fsb ka1fsb :0: * ^TOroot root :0: * ^TOsysop sysop :0: * ^FROM_DAEMON postmasterLet's take a closer look at this .procmailrc file. You have no doubt seen other versions of this runtime config since it is my opinion that procmail is one of the best kept secrets out there and a fabulous program!
Anyway, what may appear new or unfamiliar is the compound statements, between the curly braces, for some of the "^From" senders. Anything following a ":0" is a command for procmail. The first of these, ":0 c", uses formail to add a line to the header portion of the email and then uses sendmail to actually send out this modified copy, the "c" in the command line. So for wa8rsa, for example, the first command inserts a special line in the mail header, which tells another procmail program running on ka1fsb-10.ampr.org, to use this address for an auto-responder when activated. These two commands are joined by the pipe "|" symbol to feed inputs with previous outputs. The last action is taken by sendmail as it forwards the modified piece of mail to the desktop machine, ka1fsb-10.ampr.org.
The second command (:0) places this document in the /root/Mail procmail area as a backup. (This original remains unchanged since no formail commands were applied to it.)
Not all email transactions need to be this "involved." The instructions for w1gmf just send an unmodified copy to the desktop, ka1fsb-10 machine, and then place the original in the bambi procmail area, w1gmf.
If none of the specified "^Froms" is detected, then the document falls through to the ^TOka1fsb match parameters which stores it in the /Mail area for ka1fsb. It should be noted that when procmail finds a match and makes the intercept, it exits the program at that point and does no further processing...
If you know about procmail already, then all you need is the alias file to make that "link" from JNOS to procmail and the linux OS. If you are not a procmail "fan" yet, then here is the opportunity to expand your mail horizons combining the best of JNOS with the best of Linux!- Combining the Alias File with the Rewrite File
You may also use the alias file in conjunction with the rewrite file. The classic example is the one concerning tcpip bulletins:
- tcpip@* tcpip
...where all tcpip emails become redirected to just tcpip, a real local mailbox account/name. By setting up an entry in the alias file for ka1tuk, for example, we can send a copy along to that operator:
- tcpip ka1tuk@ka1tuk tcpip
... and keep a copy locally for ourselves too. (Remember the priority of operations: the rewite file goes first, then the alias file via the smtp server.)
This is just a very simple example, but illustrates the versatility of combining the alias file with other subsystems on JNOS.
Perhaps a more interesting example can be drawn from the mailing list above. The line below "remaps" all incoming wxgroup (smtp) email to a local account, wxgroup, which in turn will then be forwarded on the wxgroup mailing list, also defined and stored locally...
- wxgroup@* wxgroup
So if someone else, from a remote machine, sent a weather report to your wxgroup mailing list, your machine would treat it as though you had initiated it and send as usual to all on that list. The mail header block would contain several "received" headers, noting the original sender and then your receipt and forward to the group. The command from the remote JNOS BBS might be:
- sp wxgroup@somejnos.ampr.org
... where the somejnos here would be your JNOS machine/station, the one maintaining this mailing list, such as wxgroup@ka1fsb.ampr.org.- Peeking into the Alias File
It is possible to either remotely or locally query an alias file via the smtp server and telnet. Since you aready know your own file contents, it would probably be more fun to look into someone else's alias listings.
So here is how to do that:
- telnet ka1tuk 25
...where 25 is the well-known port number for the smtp server. The server will return with a "ready" response:
- 220 ka1tuk SMTP ready
... and now all you need to do is to enter an alias name, such as, the wxgroup and you will see the callsigns on that list:
- expn wxgroup
Of course, you must know the aliases before hand to expand them. There is no way to query for these unless they have been published in a publically accessible file on the JNOS system. But, this method can be used as a proof that the alias file and the smtp server are "talking" to each other...- A Syntactical Overview of the Alias File
Since there are many data combinations for the alias file, here is a summary of the possible entries:
The Alias File Layout & Data Types A Data Record: <Alias Name> <Tab or space> <Address [<address list>]>\n or \r\n Aliases
An actual local mailbox user name or mail account, followed by either a space or a tab.
For example:
- ka1tuk
- tcpip-mail
- wxgroup
Addresses
A single entry: an smtp email address (with the "@") or, a series of smtp addresses, or an actual local mailbox name (or a JNOS user) usually separated by a single space between each entrant if more than one.
Any combination of valid reachable email addresses, or local mailboxes: including user callsigns, user names, or topical (bulletin) email accounts.
If a long list, begin next line(s) with a leading single space or tab...)Or, an alias name which is not
an actual mailbox, but "points to"
an actual local mailbox, also followed
by a space or a tab.
For example:(See sample file below.)
- Larry
- tcpip-mail-dist
- wxgroup-dist
Here is a composite made from actual alias files supplemented with illustrative entries:
Larry ka1tuk@ka1tuk.ampr.org
tcpip-mail-dist aa1aa@aa1aa ab1ab@ab1ab ac1ac@ac1ac tcpip-mail
wxgroup-dist aa1aa@aa1aa ab1ab@ab1ab
ac1ac@ac1ac wxgroup
ka1fsb root@bambi.ampr.org
sysop root@bambi.ampr.org
tcpip ka1tuk@ka1tuk tcpip
(The two local mail accounts tcpip-mail and wxgroup would receive a copy of each mailing list, that is, an individual copy for each destination.)- Conclusions...
Whether you use the alias file to just expand user names and callsigns, or to bridge into the operating system and beyond, you will certainly find this little file to be a welcome addition to your network arsenal! It's one of those small, nice touches that can make a very big difference!