procmail
[Top] [All Lists]

Re: more tweaking

1999-11-21 08:09:50
From: era eriksson <era(_at_)iki(_dot_)fi>

On Sun, 21 Nov 1999 05:20:47 -0800 (PST), Dallman Ross
<dman(_at_)netcom(_dot_)com> wrote:

 >         :0 Dch  # no lock, we're not saving anything
 >    * for <sat(1|2|3|4|5)@maindomain\.com>
 >    * for <\/sat(1|2|3|4|5)
 >    $MATCH

Oh, but you are. This will attempt to save to a folder whose name is
the value of the variable MATCH (in your MAILDIR, if no explicit path
name is in the value of MATCH).

Your response was much appreciated.  Let me reply to a couple of
items.  First, I do know that I'm saving something here.  It's
just that I don't want to be once I get it working.  :-)
I was only interested in testing what my condition lines did to
$MATCH, and the save was an easy kludge to let me see that.


 > First of all, I had trouble with the leading tab. I couldn't get,

Right on. Procmail internally folds every header line to a single
"logical line" and so that ^ you put there is preventing these from
matching. You probably want something like this:

    * ($)[    ]for <sat

but I wouldn't be too sure that the line will always come through
folded anyhow. If you're scared of false matches, put something before

Ah.  Good idea.

it to make sure this is only on a Received: line and roughly in the
correct context ("Received: from foo by bar for baz with SMTP id ...")

Ditto.


 > Purpose is: mail to, e.g., sat1(_at_)NOTmaindomain(_dot_)com will not
 > match.  But mail to sat1(_at_)maindomain(_dot_)com will match, and the
 > match string will be just "sat1".  This does work.  Is there a
 > better way?

You can grab too much and then trim it down, like this:

    :0
    * ^Received: from (.*) by (.*)[   ]for[   
]<\/sat[1-5](_at_)maindomain\(_dot_)com>
    * MATCH ?? ^^\/sat[1-5]
    { }  # no action, we do this just for the grabbing

YES!!!  That's what I was looking for.  (Bless you!)  And the "{ }"
makes sense also.  I don't get the parens, though, in the first
condition line.  I see what it's doing, but have never seen these parens
before.  You use them above with "($)" also.  I think after
experimenting that the (.*) means real parens in the header.  (Your
line is close but not perfect in order to match the reality of what I
get.)  But I still don't know why it's above with "($)".


If you need more complex grab manipulation, a more generic recipe
might look like this:

    :0  # grab sat[1-5](_at_)maindomain(_dot_)com> into MATCH
    * ^Received: from (.*) by (.*)[   ]for[   
]\/sat[1-5](_at_)maindomain\(_dot_)com>
    {
        # want "sat[1-5]" in LOCALPART and "maindomain.com" in HOSTPART

        TEMP=$MATCH

        :0  # extract from TEMP into LOCALPART
        * TEMP ?? ^^\/[^(_at_)]+
        { LOCALPART=$MATCH }

        :0  # now the same for the stuff after the @ but excluding the >
        * TEMP ?? @\/[^@<>]+
        { HOSTPART=$MATCH }

        # If you're paranoid, scream if either LOCAL or HOST is unset here
    }

Interesting and a very good example of how to use parsing with MATCH,
that I will save.  But since the Received line worked above, I don't
really need to test further for the validity of HOSTPART here.
I'm glad you posted the example, though - very helpful to the learning
process.

Still unanswered is whether, after all that work, the variables I
save will work later in the rcfile.  So far I can't get them to!
And do I use braces to save $MATCH to other variable names?  It
appears that is the only way?


 > Okay, now to two other issues I'm running into on this 
 > server.  When I have a prepared message piped to sendmail
 > as in
 >    ( whatever ) | sendmail -oi -t
 > I get bounces.  The server says that "-oi" and "-t"
 > are not valid addresses.  I don't get it.  This


Use $SENDMAIL which is what ! expands to. Probably just "sendmail"
without a path invokes some local wrapper or cheap imitation, while
$SENDMAIL with a full path invokes a different program altogether,
which is (or is better at pretending to be) a true Sendmail.

No, that's not the answer, unfortunately.  I do use $SENDMAIL.
I was just writing in shorthand.  But I misspoke:  It's only bouncing
"-oi" and not "-t".


 > Final problem (of this mail): fileperms are stuck
 > public (rwxr-xr-x) and I can't change them.  
 >    UMASK = 077
 > has absolutely no effect.  Why would that be?

Can't help with that one, I'm afraid. You should be aware that UMASK
affects the creation of new files only, though. It cannot change the
mode of a file which already exists and which you append to.

Yes, I knew that.  It's not working in any case. :-(
I'd hate to have to call chmod from the shell just for such a silly thing.


One of the fundamental answers is still "don't do things this way if
you can avoid it". See <http://www.iki.fi/era/procmail/mini-faq.html>,
look for the section about virtual domains.

Hmmmmmmmmmmmm.  Thanks.  :-)  Not an easy way around using them,
though, unless I want to pay big bucks.  www.mydomain.com is how
I manage the "satellite" domains, and it's free and very cool.

-- 
    \     .-.     .-.     .-.     .-.     .-.     .-.     .-.     /
     \-d-/-m-\-a-/-n-\-(_at_)-/-n-\-e-/-t-\-c-/-o-\-m-/-.-\-c-/-o-\-m-/
      '-'     '-'     '-'     '-'     '-'     '-'     '-'     '-'

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