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


Previous Section Next Section

5.5 The makemap Program

The makemap program is supplied in source form with V8 sendmail. It can also be supplied in pre-compiled form by your vendor.[9] It is used to create database files and is run from the command line like this:

[9] Whenever you update to a newer version of sendmail, always update the version of the makemap program in parallel. Old or vendor versions might not interoperate well with an updated sendmail.

% makemap  switches dbtype outfile < infile  

We'll discuss the switches in the next section. The dbtype can be dbm (which uses the ndbm(3) library routines), hash, or btree (both of which use the db(3) library routines). The outfile is the location and name (full path or relative name) for the database file that will be created. For dbm files, the .pag and .dir suffixes are added automatically. For the db files, the .db suffix will be added automatically if it is not already included in the name.

The infile is the name of the input text file from which the database will be created. The makemap program reads from its standard input, hence the < character. That input is line-oriented, with one database entry per line. Lines that begin with a # are interpreted as comments and ignored. Lines that contain no characters (empty lines) are also ignored. Whitespace (spaces or tabs) separates the key on the left from the data on the right.

The following is an example of such an input file:

 key                  data 
 
                     
lady              relaysite!lady
my.host           relaysite!lady
bug               bug localuucp

The second line shows that keys can be multitokened (my.host is three tokens), but cannot contain space or tab characters. The data is separated from the keys by one or more space or tab characters. The last line shows that the data can contain internal space and tab characters.

In reading from existing files, some conversion might be required to massage the input into a usable form. To make a database of the /etc/hosts file (for converting host names into IP addresses), for example, you might use a command line such as the following:

% awk '/^[^#]/ {print $2, $1}' /etc/hosts | makemap ...

Here, awk(1) first eliminates the comment lines (the /^[^#]/). If it doesn't, it will wrongly move them to the second column, where makemap will not recognize them as comments.

The database files created by makemap are given a default permission of 0644 (read/write by owner, readable by everyone else). Beginning with V8.12.4 sendmail, the default permission has been changed to 0640. If you wish to tighten the default to 0600 you can do so by defining the DBMMODE compile-time macro when building makemap:

APPENDDEF(`conf_makemap_ENVDEF',  `-DDBMMODE=0600')

You can, of course, use this compile-time macro to loosen the default permissions, but looser permissions are discouraged because they open the door to a possible denial-of-service attack on the local machine.

5.5.1 makemap Command-Line Switches

The command-line switches for makemap must precede the dbtype and the outfile:

makemap switches dbtype outfile

Switches are single characters, prefixed with a - character. Switches can also be combined:

-N -o  good
-No    also good

The complete list of switches is shown in Table 5-6. (See getopt(3) for additional information about the way switches are handled.)

Table 5-6. makemap program's switches

Switch

§

Description

-c

-c

Set the cache size for hash and btree

-C

-C

Use an alternative sendmail configuration file

-d

-d

Allow duplicate keys in database

-e

-e

Allow empty data for keys

-f

-f

Don't fold uppercase to lowercase

-l

-l (lowercase L)

List database types supported

-N

-N

Append a null byte to all keys

-o

-o

Append to, don't overwrite the file

-r

-r

Replace (silently) duplicate keys

-s

-s

Skip security checks

-t

-t

Specify an alternative to whitespace for a delimiter

-u

-u

Unmake (dump) the contents of a database

-v

-v

Watch keys and data being added

In the following sections we describe each switch in detail.

    Previous Section Next Section