procmail
[Top] [All Lists]

Re: Help with lockfile (:0:)

2000-01-31 09:42:14
"W. Mark Herrick, Jr." <markh(_at_)va(_dot_)rr(_dot_)com> writes:
Below is a snippit from my .procmailrc file, and I'm wondering if I have 
the lockfile in the correct place.

The script in the 2nd part uses the contents of 'mark-relay' in it's 
processing (grep/awk/sed/mailx), so I don't want 'mark-relay' to be 
appended to until the script finishes...

Do I have the lockfile in the correct place? I think I do...

:0:
* !^FROM_DAEMON
* !^FROM_MAILER
* ^X-RR-Relay:
{
:0c
mark-relay
:0
| /usr/local/bin/bash /export/home/twabuse/relayscan.sh
}

To quote the procmailrc(5) manpage's BUGS section:

       A locallockfile on the recipe that marks the  start  of  a
       non-forking nested block does not work as expected.

There are two easy solutions:

1) Rewrite relayscan.sh to accept the message on its stdin.  If it
   has to scan the message several times then you could just start the
   script with
        cat >>mark-relay

   The recipe would then be:
        :0:mark-relay.lock
        * !^FROM_DAEMON
        * !^FROM_MAILER
        * ^X-RR-Relay:
        | /usr/local/bin/bash /export/home/twabuse/relayscan.sh

2) Use a regional lockfile:
        :0:mark-relay.lock
        * !^FROM_DAEMON
        * !^FROM_MAILER
        * ^X-RR-Relay:
        {
            LOCKFILE = mark-relay.lock
            :0 c
            mark-relay
            :0
            | /usr/local/bin/bash /export/home/twabuse/relayscan.sh
            LOCKFILE
        }

Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>