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


Previous Section Next Section

8.2 Configuration Lines

Selected configuration file lines can be entered in rule-testing mode. They will behave just as they do when being read from the configuration file. For V8.8 sendmail and above, three configuration commands are honored:

#

Commands that begin with a # are treated as comments and ignored. Blank lines are also ignored.

D

The D configuration command (Section 21.3) is used to define a sendmail macro. Both single-character and multicharacter sendmail macro names can be used.

C

The C configuration command (Section 22.1) is used to add a value to a class. Both single-character and multicharacter class names can be used.

The # can begin a line. The other two configuration commands in rule-testing mode must begin with a dot:

.D{ntries} 23
.Cw localhost

Failure to use a dot will produce this error message:

Undefined ruleset Cw

The use of any character other than the two listed will produce this error:

Unknown "." command .bad command here

To get a usage message, just type a dot:

> .
Usage: .[DC]macro value(s)

8.2.1 Define a Macro with .D

The .D rule-testing command is used to define a sendmail macro. One use for this command might be to modify a rule that depends on the $& prefix (Section 21.5.3). For example, consider this small configuration file that contains a rule in parse rule set 0 that is intended to deliver a local user's address via the local delivery agent:

V10
Sparse=0
R$+      $#local $@ $&X $: $1

If $X has a value, this rule returns that value as the host (the $@) part of a parse rule set 0 triple (Section 19.5). If $X lacks a value, the host part is empty. This technique is useful because the $@ part with the local delivery agent is used to implement plussed users (Section 12.4.4).

This scheme can be tested in rule-testing mode by first specifying a local user with $X undefined:

% /usr/sbin/sendmail -bt -Ctest.cf
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> parse bob
parse              input: bob
parse            returns: $# local $@ $: bob

This form of rule testing and the output produced are described in detail in Section 8.6. Here, it is important only to note that the host part of the triple (the $@ part) is empty.

Now, use the .D command to give $X the value home:

> .DXhome

Now, test those rules again:

> parse bob
parse              input: bob
parse            returns: $# local $@ home $: bob

This time the host part of the triple (the $@ part) has the value home as intended.

The .D command can also be used to redefine the value of existing sendmail macros. It cannot, however, be used to redefine sendmail macros used in rules (except for $&) because those macros are expanded as rules are read from the configuration file (Section 21.5.2). Also see Section 8.3.1, which describes how to view sendmail macro values in rule-testing mode.

8.2.2 Add to a Class with .C

The .C rule-testing command is used to add a member to a class. If the class does not exist, it is created. One possible use for this command would be to test whether adding a member to $=w will have the effect you desire. For example, suppose that a new alias called mailhub has been created for the local host. In the following, we test sendmail to see whether it will detect that new name as local:

% /usr/sbin/sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> canonify,parse bob@mailhub
canonify           input: bob @ mailhub
Canonify2          input: bob < @ mailhub >
Canonify2        returns: bob < @ mailhub >
canonify         returns: bob < @ mailhub >
parse              input: bob < @ mailhub >
Parse0             input: bob < @ mailhub >
Parse0           returns: bob < @ mailhub >
ParseLocal         input: bob < @ mailhub >
ParseLocal       returns: bob < @ mailhub >
Parse1             input: bob < @ mailhub >
MailerToTriple     input: < > bob < @ mailhub >
MailerToTriple   returns: bob < @ mailhub >
Parse1           returns: $# esmtp $@ mailhub $: bob < @ mailhub >
parse            returns: $# esmtp $@ mailhub $: bob < @ mailhub >

This form of rule testing and the output that is produced are described in detail in Section 8.6. Here, merely note that the esmtp delivery agent was selected, suggesting that mailhub was not automatically recognized as local.

One way to fix this is to add mailhub to the class $=w ($=w). In rule-testing mode this can be done by using the .C command:

> .Cw mailhub

Now, feed sendmail the same rules and address as before to see whether this fixed the problem:

> canonify,parse bob@mailhub
canonify           input: bob @ mailhub
Canonify2          input: bob < @ mailhub >
Canonify2        returns: bob < @ mailhub . >
canonify         returns: bob < @ mailhub . >
parse              input: bob < @ mailhub . >
Parse0             input: bob < @ mailhub . >
Parse0           returns: bob < @ mailhub . >
ParseLocal         input: bob < @ mailhub . >
ParseLocal       returns: bob < @ mailhub . >
Parse1             input: bob < @ mailhub . >
Parse1           returns: $# local $: bob
parse            returns: $# local $: bob

Success! Adding mailhub to the class $=w fixed the problem. You could now make that change permanent by editing your mc file and using that to create a new configuration file, or by adding the name to the /etc/mail/local-host-names file[3] (FEATURE(use_cw_file)).

[3] Prior to V8.10 sendmail this file was called /etc/mail/sendmail.cw.

Another use for .C would include trying out masquerading for a subdomain (FEATURE(limited_masquerade)). See also Section 8.3.2 for a way to print the members of a class while in rule-testing mode.

    Previous Section Next Section