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. Currently (as of V8.8 sendmail), three configuration commands are honored:

The # may begin a line. The other two configuration commands in rule-testing mode must begin with a dot. Failure to use a dot will produce this error message:

No address!

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)


Define a Macro with .D

The D rule testing command is used to define a macro. One use for this command might be to modify a rule that depends on the $& prefix (see "Use Value as Is with $&"). For example, consider the rule in rule set 0 that is intended is to deliver a local user's address via the local delivery agent:

R$+ $#local $@ $&X $: $1

If $X has a value, this rule returns it as the host (the $@) part of a rule set 0 triple. 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 (see "Plussed Users").

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

> 0 bob rewrite: ruleset 0 input: bob rewrite: ruleset 0 returns: $# local $@ $: bob

This form of rule testing and the output produced are described in detail in . 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:

> 0 bob rewrite: ruleset 0 input: bob rewrite: ruleset 0 returns: $# local $@ home $: bob

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

The D command can also be used to redefine the value of existing macros. It may not, however, be used to redefine macros used in rules (except for $&), because macros are expanded as rules are read from the configuration file. (See "When Is a Macro Expanded?" and ; describes how to view macro values in rule-testing mode.)

Internally, the D command calls three routines, two of which you can watch. First it calls macid() to translate a macro name into an integer index. This can be watched with the -d35.14 debugging switch (see -d35.14). Second, it calls translate_dollars() to convert the $x form into its internal form. This step cannot be watched. Finally, it calls define() to actually define the macro. This step can be watched with the -d35.9 debugging switch (see -d35.9).

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:

> 3,0 bob@mailhub rewrite: ruleset 3 input: bob @ mailhub rewrite: ruleset 3 returns: bob < @ mailhub > rewrite: ruleset 0 input: bob < @ mailhub > rewrite: ruleset 0 returns: $# smtp $@ mailhub $: bob < @ mailhub

This form of rule testing and the output that is produced are described in detail in . Here, merely note that the smtp 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 (see $=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:

> 3,0 bob@mailhub rewrite: ruleset 3 input: bob @ mailhub rewrite: ruleset 3 returns: bob < @ mailhub . > rewrite: ruleset 0 input: bob < @ mailhub . > rewrite: ruleset 0 returns: $# local $: bob

Success! Adding mailhub to the class $=w fixed the problem. You could now make that change permanent by editing the configuration file or by adding the name to the sendmail.cw file (see FEATURE(use-cw-file)).

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

Internally, the C command calls four routines, but you can watch only three. First it calls macid() to translate a macro name into an integer index. This can be watched with the -d35.14 debugging switch (see ). Second, it calls translate_dollars() to convert the $=x form into its internal form. This step cannot be watched. Third, it calls expand() to expand any macros that appear in the list of words. This may be watched with the -d35.24 debugging switch (see -d35.24). Finally, for each word that it adds to the class, it calls setclass(), which can be watched with the -d37.8 debugging switch (see -d37.8).