O'Reilly logo

Sendmail, 3rd Edition by Bryan Costales

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

${load_avg}

Synopsis

The ${load_avg} macro contains as its value the current one-minute load average of the machine on which sendmail is running. That value is a rounded integer representation of a possible floating-point value.

One use for this ${load_avg} sendmail macro might be to reject SMTP ETRN commands when the load average it too high:

LOCAL_CONFIG
D{OurETRNlimit}5
Karith math

LOCAL_RULESETS
Scheck_etrn
R $*             $: $(math l $@ $&{load_avg} $@ ${OurETRNlimit} $)
R FALSE          $# error $@ 4.7.1 $: "450 The load average is currently too high."

Here, we add two new sections to our mc configuration file. The first, under LOCAL_CONFIG, defines a sendmail macro, ${OurETRNlimit}, that will hold as its value the limit we have set to reject ERTN commands. In this mc section we also defined a database map of type arith (arith).

In the second section, following the LOCAL_RULESETS, we declare the check_etrn rule set (check_etrn). That rule set is called from inside sendmail (just after an SMTP ETRN command is received, but before the reply to that command is sent) and can determine if the SMTP ETRN command should be allowed. If the rule set returns the $#error delivery agent, the SMTP ETRN command is denied. Otherwise, it is allowed.

The first rule matches anything in the LHS, then ignores that value in the RHS. The RHS looks up the current ($&) value of the ${load_avg} macro, then uses the math database map to compare that value to the limit set in our ${OurETRNlimit} macro. If the load average ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required