procmail
[Top] [All Lists]

Re: How to set line buffer

2007-05-17 20:03:08
On 5/17/07, DR. Lee - NS1 <kflee(_at_)itnc(_dot_)com> wrote:

I am playing with script of Barton E. Schaefer's mimepart.txt, trying to
get it work with file types other than just application and hit a
condition of line buffer overflow.

First of all, are you sure that the manual you're reading and the
installation of procmail you have are the equivalent versions?  What
is the first line of output from
  procmail -v
on your mail server?  Overflow should cause procmail to truncate the
line and set the PROCMAIL_OVERFLOW variable, so if that's not
happening then the error is not in procmail itself.

Could it be possible that the mimepart.txt uses linebuf for the
extracted attachment as well and thus can be affected by the size of
attachment?

The extracted attachment does pass through the procmail line buffer,
but mimepart.txt calculates the size of the attachment in advance and
assigns a large enough value to LINEBUF so that overflow will not
occur.  Read through mimepart.txt, there are comments and obvious
assignments to LINEBUF.

I suspect the overflow occurs when you execute

  echo "$BODY_PART"

in the shell, and not inside procmail at all.  (You DO have quotation
marks around the reference to $BODY_PART, don't you?  If you do not,
and $BODY_PART contains some character like ">" or "*" that is special
to the shell, bad things may happen.

I try to put a line:

LINEBUF=1024000

 inside the procmailrc and it does not make difference; so where this
line or equivalent should go?

In the procmailrc is the correct place, so if that assignment doesn't
change anything then the problem is definitely outside of procmail.


Try extracting the attachment as follows.

# Fork so we don't affect the original message
:0 c
{
  # Replace the entire message body with just the attachment
  :0 fbi
  | echo "$BODY_PART"

  # Now pipe the message body to mimencode
  :0 bw:
  | mimencode -u -b > "$TARGET"

  # That should be considered a delivery and terminate the forked procmail.
  # Just in case it failed or otherwise did not terminate, force
termination here.
  EXITCODE=$?
  HOST
}

I didn't actually test the above, but I believe it to be correct.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail