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


Previous Section Next Section

23.2 The K Configuration Command

The K configuration command is used to associate a symbolic name with a database-map type. The symbolic name will later be used in the RHS of rules. The form of the K command looks like this:

Kname type args

The name is the symbolic name, the type is the kind of database map to use, and the args specifies its location and properties. We describe each in turn.

23.2.1 The name

The name portion of the K configuration command immediately follows the K. Whitespace between the K and the name is optional:

K name type args
  
 optional whitespace

The name must begin with a letter or digit and can contain only letters, digits, and the underscore character:

K local_hosts   good
K $andcents     bad

The case of the letters in name does not matter. All names are converted to lowercase before they are stored:

K LOCAL_Hosts
K local_hosts   the same

If you begin a name with a bad character, the following error will be printed and that K line will be ignored:

configfile: line num: readcf: config K line: no map name 

If a bad character appears in the middle of a name, the part preceding the bad character will be taken as the name, and the part following the bad character will be taken as the type. For example, the name me@home will produce this error:

configfile: line num: readcf: map me: class home  not available 

23.2.2 The type

Recall that the type[2] portion of the K configuration command follows the name:

[2] The sendmail source calls this class, but we chose type to make it clear that this is different from class macros.

Kname type args

Note that whitespace between the name and the type can be a joined indented line, which allows commenting and improves readability:

Kname             # Why this name
        type      # Why this type
        args      # and so on

The type declares which sort of database map to use. It must be one of the types listed in Table 23-2.

Table 23-2. Possible K command types

Type

§

Version

Description

arith

arith

V8.10 and above

Perform arithmetic computations

btree

btree

V8.1 and above

A db(3) form of database

bestmx

bestmx

V8.7 and above

Look up the best MX record for a host

dbm

dbm

V8.1 and above

Really ndbm supplied with most versions of Unix

dequote

dequote

V8.6 and above

Remove quotation marks

dns

dns

V8.12 and above

Look up information using DNS

hash

hash

V8.1 and above

A db(3) form of database

hesiod

hesiod

V8.7 and above

MIT network user authentication services

host

host

V8.1 and above

Internal table to store and look up hostnames

implicit

implicit

V8.1 and above

Search for an aliases database entry

ldap

ldap (was ldapx)

V8.8 and above

The Lightweight Directory Access Protocol (LDAP)

ldapx

ldap (was ldapx)

V8.9 and earlier

Replaced by ldap

macro

macro

V8.10 and above

Store a value into a macro via a rule

netinfo

netinfo

V8.7 and above

NeXT, Darwin, and Mac OS X network information services

nis

nis

V8.1 and above

Sun's Network Information Services (NIS)

nisplus

nisplus

V8.7 and above

Sun's newer version of NIS (NIS+)

nsd

nsd

V8.10 and above

Irix nsd database maps

null

null

V8.7 and above

Provide a never-found service

ph

ph

V8.10 and above

CCSO Nameserver (ph) lookups

program

program

V8.7 and above

Run an external program to look up the key

regex

regex

V8.9 and above

Use regular expressions

sequence

sequence

V8.7 and above

Search a series of database maps

stab

stab

V8.10 and above

Internally load aliases into the symbol table

switch

switch

V8.7 and above

Build sequences based on service switch

syslog

syslog

V8.10 and above

Log information using syslog(3) via rule sets

text

text

V8.7 and above

Look up in flat text files

userdb

userdb

V8.7 and above

Look up in the User Database

user

user

V8.7 and above

Look up local passwd information

All of these database-map types are described in Section 23.7 at the end of this chapter. If the type is not one of those listed, or if support for the type was not compiled in, the following error is printed and the K command is ignored:

configfile: line num: readcf: map name: class type  not available 

23.2.3 The args

The args of the K configuration command follow the symbolic name and type:

Kname type args

The args specify (among other things) the location of the database file or the name of a network database map. The args is like a miniature command line, and its general form looks like this:

switches file_or_map

The switches are letters prefixed with a - character that modify the use of the database. (We'll discuss them in the next section.) The file_or_map is the location of the database file or the name of a network database map. The file_or_map should exclude the .pag and .dir suffixes for dbm-type files and exclude the .db suffix for hash or btree-type files.

A database map is opened for reading when the configuration file is processed. If the file cannot be opened (and the -o is omitted, -o), an appropriate error is printed. The file_or_map should be an absolute pathname of a file (such as /etc/mail/uuhosts) or a literal network database-map name (such as hosts.byname). An nis database-map specification can include a domain:

map@domain

Relative filenames (names that omit a leading /) are interpreted as relative to the queue directory and should never be used.

The database files must live in a safe directory (one whose every component is writable only by root or the user defined by the TrustedUser option, TrustedUser). If the file itself is unsafe or its directory is unsafe, one of several errors will be printed or logged, depending on how you run sendmail. (See the description of the DontBlameSendmail option (DontBlameSendmail) for more information about this safety check.)

    Previous Section Next Section