Macros in Rules
Each noncomment part of a rule is expanded as the configuration file is read.[246] Thus, any references to defined macros are replaced with the value that the macro has at that point in the configuration file. To illustrate, consider the following mini configuration file (which we will call test.cf):
V10 Stest DAvalue1 R $A $A.new DAvalue2 R $A $A.new
First, note that as of V8.10
sendmail, rules (the R
lines) cannot exist
outside of rule sets (the S
line). If you omit a rule set
declaration, the following error will be printed and
logged:
configfile: line number: missing valid ruleset for "bad rule here"
Second, note that beginning with V8.9,
sendmail will complain if the
configuration file lacks a correct version number
(the V
line). Had
we omitted that line, sendmail
would have printed and logged the following
warning:
Warning: .cf file is out of date: sendmail 8.12.6 supports version 10, .cf file is version 0
The first D
line
assigns the value value1
to the $A
sendmail macro. The second
D
line replaces
the value assigned to $A
in the first line with the new value
value2
. Thus,
$A
will have
the value value1
when the first R
line is expanded and value2
when the second is expanded.
Prove this to yourself by running
sendmail in -bt
rule-testing mode to
test that file:
% echo =Stest | /usr/sbin/sendmail -bt -Ctest.cf
> =S0
R value1 value1 . new
R value2 value2 . new
Here, we use the =S
command (Show Rules in a Rule Set with =S on page 306) to show each rule after it has been ...
Get sendmail, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.