procmail
[Top] [All Lists]

Re: * ! ? $TEST -d "$some_directory" may not work

2004-03-27 10:07:09
On Sat, 27 Mar 2004, 09:31 GMT-06 David W. Tamkin wrote:

Could you please tell us exactly what that condition was?  Unless the
expansion of $TEST or the quoted expansion of "$VIRUSDIR/EXE" contains
whitespace or something else whose meaning would change upon 
re-evaluation, there's no way to say.

You still have to agree that the extra "$" was not required simply to
expand the variable $TEST.

have I? ;-)

In fact, exactly the "magic" behaviour procmail may treat 'test' in some
cases, as we have discussed earlier here, could cause

  *  ! ? $TEST -d "$av_REQUIRED_DIR"

not to expand the variable $TEST. The condition above is used in my
current SoftlabsAV package (version 0.6.1), available at

http://prdownloads.sourceforge.net/softlabsav/SoftlabsAV-0.6.1.tar.bz2?download

On the system I have been testing it intensively, that works if TEST
is set to '/usr/bin/test' (the proper location of the actual 'test'
binary) - as recommended in the shipped '/etc/procmailrc' file.

To see what's going on, here is the relevant verbose log:

procmail: Assigning "TEST=/usr/bin/test"
procmail: Assigning "av_REQUIRED_DIR=/home/roal/mail/TRASH/viruses/EXE"
procmail: Assigning "INCLUDERC=/etc/procmailrcs/softlabs/inc/av_mkdir.inc"
procmail: Executing "/usr/bin/test,-d,/home/roal/mail/TRASH/viruses/EXE"
procmail: No match on ! "/usr/bin/test -d /home/roal/mail/TRASH/viruses/EXE"

OK, fine. But see what happens if TEST has not been set. In that case,
my code sets it to a fallback of 'test':

procmail: Assigning "TEST=test"
procmail: Assigning "av_REQUIRED_DIR=/home/roal/mail/TRASH/viruses/EXE"
procmail: Assigning "INCLUDERC=/etc/procmailrcs/softlabs/inc/av_mkdir.inc"
procmail: Executing " $TEST -d "$av_REQUIRED_DIR""
#                    ^^^^^^
procmail: No match on ! " $TEST -d "$av_REQUIRED_DIR""

So, the variable $TEST did *not* expand unless the "$" expansion
modifier has been added to the condition, like this:

  * $ ! ?$TEST -d "$av_REQUIRED_DIR"

That way, it worked in all cases, regardless if TEST is set to
'/usr/bin/test' or to 'test':

procmail: Assigning "TEST=test"
procmail: Assigning "av_REQUIRED_DIR=/home/roal/mail/TRASH/viruses/EXE"
procmail: Assigning "INCLUDERC=/etc/procmailrcs/softlabs/inc/av_mkdir.inc"
procmail: Executing "test -d /home/roal/mail/TRASH/viruses/EXE"
procmail: No match on ! "test -d /home/roal/mail/TRASH/viruses/EXE"

procmail: Assigning "TEST=/usr/bin/test"
procmail: Assigning "av_REQUIRED_DIR=/home/roal/mail/TRASH/viruses/EXE"
procmail: Assigning "INCLUDERC=/etc/procmailrcs/softlabs/inc/av_mkdir.inc"
procmail: Executing "/usr/bin/test,-d,/home/roal/mail/TRASH/viruses/EXE"
procmail: No match on ! "/usr/bin/test -d /home/roal/mail/TRASH/viruses/EXE"

We can also see here again that not setting TEST to its proper
location may cost additional resources for invoking an extra shell
layer.

Isn't that whole test thing some kind of strange?

rob.




_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail