procmail
[Top] [All Lists]

Re: Msg size restriction

2001-08-29 21:12:51
Ashley wrote,

|     Someone on the sendmail newsgroup suggested this:

[The suggested code that Ashley quoted fed a copy of the message to a pipe
and then dropped the message into /dev/null.  How odd; why not just feed the
original to the pipe?]

Anyhow, my response is going to be similar to what I'd been meaning to send
for a question she posted (or he?) a couple weeks ago that I never managed
to sit down and write.

|     The problem with this is, I'd have to create it for each and every
| user and nothing is going to stop them from removing that file.

You'd have to put the code into /etc/procmailrc.

| Ideally I'd want:
|
|     - a site-wide (machine wide) recipe

Just put it into /etc/procmailrc.

|     - have it check a flat file for users, with their size restriction
|       (I'm guessing something like: DEFAULT_LIMIT    75000
|                                     userA          1000000
|                                     userB           150000
|                                     userF        999999999)

That is possible.  I'll explain farther on.

|     - if the msg received, is larger than the user's allowed size:
|       + send a reply to the sender, saying their msg got pitched
|       + pipe the msg to /dev/null
|       + tell the recipient...not a damned thing

It takes extra work to do #1 without #2 and #3 following as a matter of
course, so we'll just do #1.

|     - and if the msg received falls within their restriction, pass it on
| like nothing ever happened.

|     Is this even doable?  Is the flat file idea sane?

Very much.

Here's your flatfile ... I don't think it has to fit within LINEBUF, but you
can raise LINEBUF if it does.  You need entries only for users with
non-default values:

MAXTABLE="
user1 2437574
user2 43254554
user9 4757483
"

Another file contains the body of the autoresponse.

And here's the code in /etc/procmailrc:

MAXSIZE=7500000 # or whatever
INCLUDERC=/path/to/flatfile

:0
* $ MAXTABLE ?? ^()$LOGNAME \/[0-9]+
{ MAXSIZE=$MATCH }

:0h # not positive that the $ modifier is needed; it can't hurt
* $ > $MAXSIZE
SAVEHEADERS=| formail -XDate: -XSubject:

# I wouldn't sweat an X-Loop: line, because if your autoresponse
# comes back to you somehow, it won't be large enough to trigger
# this code.  Autoresponse text is most easily kept in a separate
# file, beginning, "was too large for delivery here." or with other
# wording to complete the sentence started by the recipe below.

:0Ah
| ( formail -r -I "Subject: oversize message rejected" -I "From:
postmaster(_at_)$HOST" ; \
   echo "Your message described here:" ; echo "" ; \
   echo "$SAVEHEADERS" ; echo "Envelope-To: $LOGNAME" ; echo "" ; \
   cat /path/to/canned/response ) | $SENDMAIL $SENDMAILFLAGS -f postmaster

All right ... all that is proofread but untested.  Good luck.


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

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