Re: Danger, real or imagined. [Was: Some desired features, do they exist?]

2015-08-13 Thread mutt
Ian Zimmerman wrote:

> On 2015-08-13 20:24 +1000, Erik Christiansen wrote:
> 
> > >A line buffer of length $LINEBUF is used when processing the
> > >rcfile, any expansions that don't fit within this limit will be
> > >truncated and PROCMAIL_OVERFLOW will be set.  If the overflowing
> > >line is a condition or an action line, then it will be considered
> > >failed and procmail will continue processing.  If it is a
> > >variable assignment or recipe start line then procmail will abort
> > >the entire rcfile.
> 
> > You might like to read both recipe and manpage again. When "processing
> > the rcfile", the line with $SUBJECT does not expand. The "SUBJECT=" line
> > is a variable assignment, not a macro definition. 
> 
> And this (the assignment line) is what I'm worried about, not the later
> line where $SUBJECT is used.  According to the above paragraph, if _the
> expansion_ doesn't fit in $LINEBUF, the panic mode is triggered.  I
> think substituting a shell command output counts as "expansion".  Do you
> not agree?

if you are just worried about procmail rules not fitting in $LINEBUF,
just make it huge. i have very large automatically-generated procmail
rules so i use:

  LINEBUF=131072



Re: Danger, real or imagined. [Was: Some desired features, do they exist?]

2015-08-13 Thread Ian Zimmerman
On 2015-08-13 20:24 +1000, Erik Christiansen wrote:

> >A line buffer of length $LINEBUF is used when processing the
> >rcfile, any expansions that don't fit within this limit will be
> >truncated and PROCMAIL_OVERFLOW will be set.  If the overflowing
> >line is a condition or an action line, then it will be considered
> >failed and procmail will continue processing.  If it is a
> >variable assignment or recipe start line then procmail will abort
> >the entire rcfile.

> You might like to read both recipe and manpage again. When "processing
> the rcfile", the line with $SUBJECT does not expand. The "SUBJECT=" line
> is a variable assignment, not a macro definition. 

And this (the assignment line) is what I'm worried about, not the later
line where $SUBJECT is used.  According to the above paragraph, if _the
expansion_ doesn't fit in $LINEBUF, the panic mode is triggered.  I
think substituting a shell command output counts as "expansion".  Do you
not agree?

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.



Danger, real or imagined. [Was: Some desired features, do they exist?]

2015-08-13 Thread Erik Christiansen
On 11.08.15 14:52, Ian Zimmerman wrote:
> Sorry for resurrecting an ancient thread, but I feel this is important
> enough to warrant it.

Maybe not.  ;-)

> On 2015-05-12 21:50 +1000, Erik Christiansen wrote:
> 
> > Heinz, it can all be done in one line of sed, included in the procmail
> > rule. This is what I use:
> > 
> >:0  
> >* ^TO_luv-main@.*luv.asn.au
> >{   
> > # We need the subject line _content_, minus 
> > [list-name]:
> > 
> >   SUBJECT=`formail -czX "Subject:" | sed -re "s/Subject:// ; s/ 
> > \[luv-[a-z]*\]//g"`
> >
> > # Header filter leaves body alone:
> >   :0fhw
> >   | formail -i "Subject: $SUBJECT"
> >
> > # Delivery, with lockfile:
> >   :0: 
> >   luv-main
> >}
> 
> This could be dangerous, I was just re-reading the procmailrc manpage
> and in the BUGS section it says:
> 
>A line buffer of length $LINEBUF is used when processing the
>rcfile, any expansions that don't fit within this limit will be
>truncated and PROCMAIL_OVERFLOW will be set.  If the overflowing
>line is a condition or an action line, then it will be considered
>failed and procmail will continue processing.  If it is a
>variable assignment or recipe start line then procmail will abort
>the entire rcfile.

You might like to read both recipe and manpage again. When "processing
the rcfile", the line with $SUBJECT does not expand. The "SUBJECT=" line
is a variable assignment, not a macro definition. The "$SUBJECT" line
reads a variable; it does not expand a macro. Even if expansion of the
additional 66 characters were to be imagined to occur, then given that
the default LINEBUF is 2048 characters¹, perhaps you can explain the
perceived problem even in such a case in more detail?

Or, does the sense of alarm arise from believing that incoming message
text is in some way relevant to the above manpage warning? If one reads
the procmailrc manpage, then we see >>> This limit [LINEBUF] , of
course, does not apply to the mail  itself, which can have  arbitrary
line lengths,  or could be a binary file for that matter. <<<

> So, you want to either scrap the SUBJECT variable and stuff the pipeline
> literally into the recipe, or add head -c $LINEBUF to the pipeline.

The pipeline _is_ literally in the recipe. Take a closer look.
It is used in the first formail invocation to extract the subject, less
the egregious "[list-name]" crap. All that the second formail invocation
in the recipe does is reinsert the improved subject line. At no time is
the value of $LINEBUF relevant to those operations.

> Otherwise an overlong Subject will make procmail bail out and the mail
> bounce (best case).

No, not really. You might like to read more of the procmailrc manpage.

Erik

¹ See "LINEBUF" in man procmailrc.