24.5 The Aliases DatabaseReading the aliases file every time sendmail begins to run can slow mail delivery and create a lot of unnecessary computational overhead. To improve efficiency, sendmail has the ability to store aliases in a separate database format on disk. In this format, sendmail rarely needs to read the aliases file. Instead, it merely opens the database and performs lookups as necessary. The sendmail program builds its database files by reading the aliases (5) file and rewriting that file in database format. Usually, the aliases file is called aliases . With that name, ndbm (3) database files are called aliases.pag and aliases.dir , and the db (5) database file is called aliases.db . The sendmail program offers several forms of database, one of which is chosen at compile time (see Section 18.4.1, "DBMDEF=" ). 24.5.1 Rebuild the Alias Database
You tell
sendmail
to rebuild its database files
by running it in
% The first form is shorthand for the second. Either causes sendmail to rebuild those files. If the database is successfully built, sendmail prints a single line:
895 aliases, longest 565 bytes, 30444 bytes total
This shows that 895
V8
sendmail
supports multiple alias database files (see the
/etc/aliasdir/users: 895 aliases, longest 565 bytes, 30444 bytes total /etc/aliasdir/lists: 34 aliases, longest 89 bytes, 1296 bytes total
24.5.2 Check the Right Side of Aliases
When V8
sendmail
rebuilds the alias database files, it can optionally
be told to check the legality of all addresses to the right of the
colons. The
O CheckAliases=True # validate RHS in newaliases Each address is validated by running it through rule set 3, then rule set 0. Rule set 0 must select a delivery agent for the address. If it does, the address is silently validated and accepted. If not, the address is skipped, and the following warning is printed:
Other errors may be printed before the above line that indicate more specific reasons for the failure. For example,
... Unbalanced '<'
The
In general, we do not recommend setting the
%
24.5.3 Prevent Simultaneous Rebuilds
The alias database files can be automatically rebuilt in three ways:
by the daemon
(if the The sendmail program uses flock (2) or fcntl (2) with F_SETLK to lock the aliases file (depending on how it was compiled). If the aliases file is already locked (because the database is currently being rebuilt), sendmail prints the following message:
Alias file
If
sendmail
is attempting to rebuild because it was
run as
newaliases
or with the
Once the
aliases
file is locked,
sendmail
next
looks to see whether the key
The
sendmail
program waits the number of seconds
specified by the
Before entering the key (the name to the left of the colon) and contents
(everything to the right of the colon) pairs into the database,
sendmail
truncates the database (reduces it to size zero), thereby
removing the Finally, sendmail closes the database and the aliases file. Closing the aliases file releases all locks it has on that file. 24.5.4 No DBM AliasingSome versions of UNIX do not provide the libraries that are needed to compile sendmail with database support. When neither the db (3) nor ndbm (3) library is available, and when no other method for getting aliases is declared (such as nis ), sendmail keeps aliases in its internal symbol table. When the symbol table is used, sendmail builds its alias database only once. When sendmail is run as a daemon, the aliases file is read only once. If the file changes, the daemon needs to be killed and restarted. In general, it is not recommended to run sendmail in daemon mode without external database files. |
|