+--- Philip Guenther wrote:
|
| Procmail expects actions to process the entire content sent to them.
| If they can't, procmail will flag an error. It it was a filter then
| procmail will generally recover the original body (it can fail to do so
| under some rare circumstances, if I remember correctly).
|
| So, since the action of the filter, 'echo "foo"' didn't read the entire
| message, procmail assumed it failed. To tell procmail that a write
| error is expected and ignorable, put the 'i' flag on the recipe:
|
| :0 fi
| | echo foo
That kinda works :-)
Here's the base recipe I have now:
LOGFILE=/var/log/procmail.log
VERBOSE=on
SHELL=/bin/sh
SENDMAIL=/usr/lib/sendmail
FORMAIL=/usr/local/bin/formail
PATH=/usr/local/bin:/usr/bin:/bin:/usr/ucb
TEST=/usr/bin/test
CAT=/usr/bin/cat
TRUE=/bin/true
FALSE=/bin/false
DEFAULT=$HOME/Maildir/
DROPPRIVS=yes
:0
{
EXITCODE=69
:0 wif # recipe 1.1
*?$CONDITION
|echo "\n" \
"+------------+\n" \
"| A message. |\n" \
"+------------+\n";
:0 wr # recipe 1.2
*?$CONDITION
|
}
:0
{
EXITCODE=0
:0
$DEFAULT
}
We are observing rather strange behavior here, and suspect flushing may
be the problem. The idea is that $CONDITION is some external program which
tests something, and returns 0 upon success, 1 otherwise (we've been using
true and false for testing).
Assume that recipe 1.1 returns true: we should see "A message" come out via
STDOUT. This only happens if:
a) recipe 1.2 is present
b) recipe 1.2 is is true as well.
If recipe 1.1 is false but 1.2 is true, we see the message (as expected).
In order for recipe 2.1 to happen, both 1.1 and 1.2 must be false, or 1.2
must be missing.
What makes no sense is that if recipe 1.2 is not present (we really don't
need it), recipe 1.1 does not even happen:
Test case (1):
* procmailrc:
LOGFILE=/var/log/procmail.log
VERBOSE=on
SHELL=/bin/sh
SENDMAIL=/usr/lib/sendmail
FORMAIL=/usr/local/bin/formail
PATH=/usr/local/bin:/usr/bin:/bin:/usr/ucb
TEST=/usr/bin/test
CAT=/usr/bin/cat
TRUE=/bin/true
FALSE=/bin/false
CONDITION=/bin/true
DEFAULT=$HOME/Maildir/
DROPPRIVS=yes
:0
{
EXITCODE=69
:0 wif
*?$CONDITION
|echo "\n" \
"+------------+\n" \
"| A message. |\n" \
"+------------+\n";
}
:0
{
EXITCODE=0
:0
$DEFAULT
}
* dry run:
root(_at_)blah:~# procmail -d foobar < /tmp/message
root(_at_)blah:~# echo $?
0
root(_at_)blah:~#
* log:
procmail: [25113] Tue Mar 9 00:46:21 1999
procmail: Assigning "SHELL=/bin/sh"
procmail: Assigning "SENDMAIL=/usr/lib/sendmail"
procmail: Assigning "FORMAIL=/usr/local/bin/formail"
procmail: Assigning "PATH=/usr/local/bin:/usr/bin:/bin:/usr/ucb"
procmail: Assigning "TEST=/usr/bin/test"
procmail: Assigning "CAT=/usr/bin/cat"
procmail: Assigning "TRUE=/bin/true"
procmail: Assigning "FALSE=/bin/false"
procmail: Assigning "CONDITION=/bin/true"
procmail: Assigning "DEFAULT=/home/foobar/Maildir/"
procmail: Assigning "DROPPRIVS=yes"
procmail: Assuming identity of the recipient, VERBOSE=off
Folder: /home/foobar/Maildir//tmp/920958381.25113.blah 50
* huh?
If $CONDITION is set to /bin/true, and therefore meets the condition of
recipe 1.1, why is the recipe ignored?
Test case (2)
* procmailrc:
LOGFILE=/var/log/procmail.log
VERBOSE=on
SHELL=/bin/sh
SENDMAIL=/usr/lib/sendmail
FORMAIL=/usr/local/bin/formail
PATH=/usr/local/bin:/usr/bin:/bin:/usr/ucb
TEST=/usr/bin/test
CAT=/usr/bin/cat
TRUE=/bin/true
FALSE=/bin/false
CONDITION=/bin/true
DEFAULT=$HOME/Maildir/
DROPPRIVS=yes
:0
{
EXITCODE=69
:0 wif
*?$CONDITION
|echo "\n" \
"+------------+\n" \
"| A message. |\n" \
"+------------+\n";
:0 wif
*?$CONDITION
|
}
:0
{
EXITCODE=0
:0
$DEFAULT
}
* dry run:
root(_at_)blah:~# procmail -d foobar < /tmp/message
+------------+
| A message. |
+------------+
root(_at_)blah:~# echo $?
69
root(_at_)blah:~#
* log file:
procmail: [25120] Tue Mar 9 00:50:58 1999
procmail: Assigning "SHELL=/bin/sh"
procmail: Assigning "SENDMAIL=/usr/lib/sendmail"
procmail: Assigning "FORMAIL=/usr/local/bin/formail"
procmail: Assigning "PATH=/usr/local/bin:/usr/bin:/bin:/usr/ucb"
procmail: Assigning "TEST=/usr/bin/test"
procmail: Assigning "CAT=/usr/bin/cat"
procmail: Assigning "TRUE=/bin/true"
procmail: Assigning "FALSE=/bin/false"
procmail: Assigning "CONDITION=/bin/true"
procmail: Assigning "DEFAULT=/home/foobar/Maildir/"
procmail: Assigning "DROPPRIVS=yes"
procmail: Assuming identity of the recipient, VERBOSE=off
Folder: |
50
* huh?
Why does recipe 1.2 have to present _and_ be true in order for 1.1 to happen?
Only an "|" in recipe 1.2 will generate this behavior. Adding an | echo foo
will result in the same behavior as in test (1).
This is procmail3.11-pre7 with Maildir patches; 3.12 displays the same behavior
with respect to the recipes. This runs on a Solaris 2.6 box with sendmail 8.9.3.
The intent here is to have bounces have a meaningful message attached to them
via sendmail upon testing the condition. If the the condition is false, then
delivery should proceed normally.
Thanks in advance.
Gerir