Table of Contents

NAME

aliasd.pl - alias daemon

SYNOPSIS

aliasd.pl [-L facility][-R re] aliases

DESCRIPTION

This script is intended to be the recipient of mail messages. Its joy in life is to maintain a global alias database aliases for users at a site.

As users move from machine to machine they should send mail to aliasd@mailhost to update their mail aliases. Multiple commands can be included in the body of the mail message. One command may be given in the Subject: header, though such commands will fail silently if invalid. The supported commands are:

   'add' "dest" ["fname"]
   'alias' "dest" "alais","alias",...
   'delete' ["alias":]"dest"
   'change' ["alias":]"dest" "newdest"
   'sed' "old" "new"
   'list' "string"
   'help'

Where dest is a fully qualified mail destination as in ``user@host.domain''. fname is a users full name and is used to make several standard aliases. If dest does not contain an @host.domain component then the host.domain from the reply address is used.

For the benefit of users on non-UNIX hosts with tortuous paths to the central mailhost, if dest a string starting with ``$r'' then the reply address will be used. UNIX users could just send add by itself to use the reply address and have the server determine their full name via finger(1).

For the benefit of users with ``user friendly'' mailers that insist on wrapping lines, a line that ends with ``'' is continued on the next line. As in:

   'add' '$replyto' \
   Simon J. \
   Gerraty

The add command will create a number of semi-sensible aliases derrived from the user's full name. If the fname is omitted we try and finger the users host to find out. If we still have no full name, the command fails.

The alias command is much simpler. It simply adds each alias as pointing to dest.

Neither add nor alias will allow aliases to be registered for a destination of ``root'' or other system accounts.

Examples:

   'add' sjg@crufty.net Simon J. Gerraty

Produces the aliases:

sjg:        sjg@crufty.net
s.gerraty:    sjg@crufty.net
s.j.gerraty:    sjg@crufty.net
sgerraty:    sjg@crufty.net
sjgerraty:    sjg@crufty.net
simon.Gerraty:    sjg@crufty.net

Note that the mail system does not place any significance on
case, so everything is converted to lower case to simplify
matching. Assuming sjg@crufty.net was the return address,
the following is equivalent to the above:

   'add' $replyto Simon J. Gerraty

and if crufty.net can be fingered, so is:

   'add'

The command:

   'delete' sjg:

Will remove only the alias that has ``sjg'' on the LHS

   'alias' sjg@else.where sjg,simon

Will now add the aliases:

sjg:    sjg@else.where
simon:    sjg@else.where

   'change' sjg@crufty.net sjg@crufty.net

Will update all the aliases that have ``sjg@crufty.net'' on the RHS.

For the change and delete commands, only existing aliases that exactly match dest are modified or deleted. Use the list command to see what aliases contain string (reply address by default).

The sed command is very dangerous, is not mentioned in the help message and is restricted to the user root. It simply replaces all occurrences of old with new. For example:

   'sed' @oldhost.domain @newhost.domain

Can be used to update all aliases that used to point at oldhost to point to newhost.

Note that this daemon trusts users not to miss behave. It allows almost anyone to issue almost any request, so as to be as flexible as possible. All requests are logged via syslog(3) or logger(1) using facility (mail by default) so that any abuse can be tracked and dealt with appropriately. Generally users should realize that any abuse serves only to shoot themselves or their colleagues in the foot.

Options:
-L facility
Log activity to facility rather than
mail.
-R re
The return mail address of the request must match re. Users from outside the organization can make requests of postmaster for instance.
Installation:

To install aliasd requires an alias of the form:

aliasd:``|/usr/local/bin/aliasd.pl "aliases"''

and a (root) cron job like:

11 * * * * test -s "aliases".old && (cd "alias_dir"; \
           make >/dev/null 2>&1)

The makefile in "alias_dir" should contain something like:

ALIASES=/etc/aliases "aliases"

aliases.db:    aliases
   newaliases

aliases:    $(ALIASES)
   cat $(ALIASES) | grep -v '#' | sort -u > $@
   @test -s "aliases".old && mv "aliases".old "aliases".last

All the above relies on the fact that aliasd saves the previous incarnation of its aliases file in aliaes.old, the cron job uses the existance of that file as a flag that newaliases(8) should be run. When done it renames the .old file to .last so as to remove the trigger without losing the previous file.

Sanity checks:

Many users seem to have problems using this service, so we apply strict sanity checks to the requests. Any character in the request which is not allowed by RFC-822 or is likely to cause problems with the aliases file will cause the request to be skipped. X.400 addresses are not supported.

FILES

aliases
User only aliases file maintained by aliasd.
(eg. /etc/usr_aliases)

BUGS

Be careful of auto-wrap when mailing to programs. Long requests that get wrapped will cause aliasd to something other than what was intended. Use \ if necessary.

We have made the help message as clear as we can but we really need a ``click and drool'' version of this. It is scary just how many users send back the examples from the help message as commands. For example:

   add address your full name
and
   add $replyto your full name

AUTHOR

Simon J. Gerraty <sjg@crufty.net>


Table of Contents