home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Previous Section Next Section

AliasFile

Define the aliases file location All versions

The AliasFile option must be declared for sendmail to do aliasing. If you omit this option, sendmail might silently assume that you do not want to do aliasing at all. There is no default compiled into sendmail for the location of the aliases file.[8] For mc configurations, an appropriate default will be defined based on your operating system.

[8] Beginning with V8.7, a switched-services file (ServiceSwitchFile) can cause aliases to be found in NIS or other services and can completely ignore alias files altogether.

If you specify a file that doesn't exist (such as /et/mail/aliases if you really meant /etc/mail/aliases) or one that is unreadable, sendmail complains with, for example:

Can't open /et/mail/aliases

This is a nonfatal error. The sendmail program prints it and continues to run but assumes that it shouldn't do aliasing.

The forms of the AliasFile option are as follows:

O AliasFile=location           configuration file (V8.7 and later) 
-OAliasFile=location           command line (V8.7 and later) 
define(`ALIAS_FILE',`location')    mc configuration (V8.7 and later) 
OAlocation                     configuration file (deprecated) 
-oAlocation                    command line (deprecated) 

The location is an argument of type string and can be an absolute or a relative pathname. A relative path (such as ../aliases) can be used for testing but should never be used in the production version of your sendmail.cf file. To do so opens a security hole. Such a path is interpreted by sendmail as relative to the queue directory.

This option can be used to change the name of the aliases file (a possible consideration for security). If you change the location or name of the aliases file, be aware that other programs (such as emacs and Sun's nis services) might cease to work properly.

Note that with the mc technique the only way to eliminate the default alias file declaration is to undefine ALIAS_FILE like this:

undefine(`ALIAS_FILE')

If you need to turn off all aliasing, you must instead turn off alias support at the delivery-agent flag level by removing the F=A flag (F=A) from all local delivery agents, as, for example:

MODIFY_MAILER_FLAGS(`LOCAL', `-A')
MODIFY_MAILER_FLAGS(`CYRUS', `-A')
MODIFY_MAILER_FLAGS(`CYRUSV2', `-A')

The sendmail program also allows you to use several alias databases simultaneously. They are listed with the AliasFile option as, for example:

O AliasFile=/etc/aliases/users,/etc/aliases/maillists

In this case, sendmail will look up an alias first in the database /etc/aliases/users. If it is not found, sendmail will then look in /etc/aliases/maillists. The number of simultaneous alias files is limited to MAXALIASDB (MAX...) as defined in conf.h (by default 12). The -bi command-line switch will rebuild all alias databases in the order listed in this AliasFile option. Multiple declaration lines can appear in the file, each adding an alias database to the list:

O AliasFile=/etc/aliases/users     # aliases local users first
O AliasFile=/etc/aliases/maillists # then mailing lists
O AliasFile=/etc/aliases/retired   # then retired accounts

Duplicates are not detected. Therefore, the following causes /etc/aliases to be searched and rebuilt twice each time:

O AliasFile=/etc/aliases
O AliasFile=/etc/aliases

Multiple alias files can similarly be specified on the command line with the -O switch. But be aware that any alias files declared in the command line cause all the configuration file alias declarations to be ignored.

In addition to the name of alias databases, sendmail also allows you to specify the type of each. The type is the same as the types that are available for the K configuration command (Section 23.2). The type prefixes the name, and the two are separated by a colon:

O AliasFile=nis:mail.aliases

This example tells sendmail to look up aliases in the nis type (the nis) database called mail.aliases. The type can include command-line-style switches that mean the same thing as those allowed for the K configuration command.

For example:

O AliasFile=nis:-N mail.aliases

Here, the -N database-map switch causes lookups to include a trailing null byte with each key.[9]

[9] Also see Section 12.4.5, which illustrates the -A option switch for appending keys.

The types that are reasonable to use with this option are shown in Table 24-12. But note that it is generally better to use the service-switch file to select services because it is less confusing.

Table 24-12. Database-map types reasonable for aliases

Type

§

Version

Description

btree

btree

V8.1 and above

A db(3) form of database

dbm

dbm

V8.1 and above

Really ndbm supplied with most versions of Unix

hash

hash

V8.1 and above

A db(3) form of database

hesiod

hesiod

V8.7 and above

MIT network user authentication services

ldap

ldap (was ldapx)

V8.8 and above

The Lightweight Directory Access Protocol

netinfo

netinfo

V8.7 and above

NeXT, Darwin, and Mac OS X NetInfo

nis

nis

V8.1 and above

Sun's NIS

nisplus

nisplus

V8.7 and above

Sun's newer version of NIS

nsd

nsd

V8.10 and above

Irix nsd database maps

program

program

V8.7 and above

Run an external program to look up the key

text

text

V8.7 and above

Look up in flat text files

userdb

userdb

V8.7 and above

Look up in the User Database

If a type is not known (that is, completely unknown, rather than one that is not in this shortened table) and if the -d27 command-line switch (-d27.1) is specified, sendmail prints:

Unknown alias class bad type here

If the type cannot support aliasing (as defined by MCF_ALIASOK in conf.c) and if the -d27 command-line switch is specified, sendmail prints:

setalias: map class bad type can't handle aliases

In both cases the bad type is the offending map type. Both errors cause the AliasFile option's alias file declaration to be ignored.

Beginning with V8.7 sendmail, the declaration and use of alias files is further complicated[10] by the introduction of switched-services files (ServiceSwitchFile). If the file defined by the ServiceSwitchFile option exists, and if it defines the type and location of alias information, each alias definition is used just as if it were included in the configuration file (although the syntax differs). On Solaris, Ultrix, and OSF systems, switched-service files are supplied by the operating system. With these you should beware the silent introduction of unexpected alias services. On other operating systems you can set up a V8.7 switched-service file that can be used for aliases if you wish.

[10] Or simplified, depending on whom you talk to.

The AliasFile option is not safe. If specified from the command line, it can cause sendmail to relinquish its special privileges.

    Previous Section Next Section