Procmail configuration - Using variabile expansion in conditions

My knowledge level related to Procmail is average. At the moment I’m looking to improve it to advanced and I came across a very good tutorial here Jari's Procmail Tips Page.

The issue I would like to discuss is related to the use of variables in Procmail conditions. I faced a problem recently and I discovered that Procmail version v3.23pre does not process variables if I don’t use variable expansion in conditions. For example, if SpamAssassin processes an email and set the score to 20 the next chunk is matched

SPAM_SCORE="[0-9-]"
SPAM_VALUE=20
:0
* $ ^X-Spam-Status: Yes, score=\/$SPAM_SCORE+
* $ ? /usr/bin/test $MATCH -ge $SPAM_VALUE
$HOME/Maildir/.Trash/

but not this one

:0
* ^X-Spam-Status: Yes, score=\/$SPAM_SCORE+
* ? /usr/bin/test $MATCH -ge $SPAM_VALUE
$HOME/Maildir/.Trash/

The difference between the two chunks is easy to observe, I used expansion variables in conditions (* $), which informs Procmai that there is a variable in that line. The great article in the link above proves me right in this regard.

Now let’s take a look inside this file /etc/procmailrc (Debian 11) which is customized by Virtualmin

LOGFILE=/var/log/procmail.log
TRAP=/etc/webmin/virtual-server/procmail-logger.pl
:0wi
VIRTUALMIN=|/etc/webmin/virtual-server/lookup-domain.pl --exitcode 73 $LOGNAME
EXITCODE=$?
:0
* ? /usr/bin/test "$EXITCODE" = "73"
/dev/null
EXITCODE=0
:0
* ? /usr/bin/test "$VIRTUALMIN" != ""
{
INCLUDERC=/etc/webmin/virtual-server/procmail/$VIRTUALMIN
}
ORGMAIL=$HOME/Maildir/
DEFAULT=$HOME/Maildir/
DROPPRIVS=yes
:0
$DEFAULT

Question: Why in the two lines where there are conditions that test the values of the EXITCODE and VIRTUALMIN variables you did not use variable expansion (* $ ? /usr/bin/test …)?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.