Loading ...
Sorry, an error occurred while loading the content.

Re: virtual-regex problem

Expand Messages
  • Noel Jones
    ... Line 1 is not ignored, the problem is that wildcards are evil and should be avoided. Virtual alias lookups are recursive, so you ll need a 1-1 mapping to
    Message 1 of 23 , Feb 14, 2013
    View Source
    • 0 Attachment
      On 2/14/2013 11:16 AM, Alex wrote:
      > Hello,
      >
      > I am having an issue with setting up virtual-regex email
      > redirection. It appears that my wild card redirection is overriding
      > an entry with less specific criteria.
      >
      > Here is what I have in my /etc/postfix/virtual-regex
      >
      > /somename+.*@.../ <http://somedomain.com/> some...@...
      > /.*@.*/ somelocaluser
      >
      >
      > Line one is being ignored

      Line 1 is not ignored, the problem is that wildcards are evil and
      should be avoided.

      Virtual alias lookups are recursive, so you'll need a 1-1 mapping to
      stop the recursion. Also be careful with your expressions so you
      don't get unintended matches. Something like:


      /somename+.*@example\.com$/ some...@...
      /^some...@gmail\.com$/ some...@...

      IF /@example\.com$/
      /./ somelocaluser@...
      ENDIF


      If you really intend your wildcard to capture the whole internet
      address space and redirect it to somelocaluser, you can remove the
      IF and ENDIF statements. Such a setup is common in a testing lab,
      but never in the real world.


      -- Noel Jones
    • Alex
      Thank you for your help. This setup is for lab/qa indeed. What I intend to do is have only certain email form a test account forward to outside and everything
      Message 2 of 23 , Feb 14, 2013
      View Source
      • 0 Attachment
        Thank you for your help. This setup is for lab/qa indeed.

        What I intend to do is have only certain email form a test account forward to outside and everything else to a single local user. Am I correct to assume that there is no way to accomplish this with regex?


        On Thu, Feb 14, 2013 at 10:26 AM, Noel Jones <njones@...> wrote:
        On 2/14/2013 11:16 AM, Alex wrote:
        > Hello,
        >
        > I am having an issue with setting up virtual-regex email
        > redirection. It appears that my wild card redirection is overriding
        > an entry with less specific criteria.
        >
        > Here is what I have in my /etc/postfix/virtual-regex
        >
        > /somename+.*@somedomain.com/  some...@...
        > /.*@.*/ somelocaluser
        >
        >
        > Line one is being ignored

        Line 1 is not ignored, the problem is that wildcards are evil and
        should be avoided.

        Virtual alias lookups are recursive, so you'll need a 1-1 mapping to
        stop the recursion.  Also be careful with your expressions so you
        don't get unintended matches. Something like:


        /somename+.*@example\.com$/ some...@...
        /^some...@gmail\.com$/  some...@...

        IF /@example\.com$/
        /./ somelocaluser@...
        ENDIF


        If you really intend your wildcard to capture the whole internet
        address space and redirect it to somelocaluser, you can remove the
        IF and ENDIF statements.  Such a setup is common in a testing lab,
        but never in the real world.


          -- Noel Jones

      • Noel Jones
        ... On 2/14/2013 1:01 PM, Alex wrote: Thank you for your help. This setup is for lab/qa indeed. ... OK. ... As I said above, the remove the IF and ENDIF
        Message 3 of 23 , Feb 14, 2013
        View Source
        • 0 Attachment
          > On Thu, Feb 14, 2013 at 10:26 AM, Noel Jones <njones@...
          > Virtual alias lookups are recursive, so you'll need a 1-1 mapping to
          > stop the recursion. Also be careful with your expressions so you
          > don't get unintended matches. Something like:
          >
          >
          > /somename+.*@example\.com$/ some...@...
          > <mailto:some...@...>
          > /^some...@gmail\.com$/ some...@... <mailto:some...@...>
          >
          > IF /@example\.com$/
          > /./ somelocaluser@...
          > ENDIF
          >
          >
          > If you really intend your wildcard to capture the whole internet
          > address space and redirect it to somelocaluser, you can remove the
          > IF and ENDIF statements. Such a setup is common in a testing lab,
          > but never in the real world.
          >
          >
          > -- Noel Jones
          >
          >


          On 2/14/2013 1:01 PM, Alex wrote:> Thank you for your help. This
          setup is for lab/qa indeed.
          >
          > What I intend to do is have only certain email form a test account
          > forward to outside and everything else to a single local user. Am I

          OK.


          > correct to assume that there is no way to accomplish this with regex?
          >


          As I said above, the remove the IF and ENDIF statements from the
          example I supplied to capture all addresses.




          -- Noel Jones
        • Alex
          I apologize, as I am being confused. Contents of my virtual-regex now are: /somename+.*@mydomain .com$/ somename@yahoo.com /^somename...@mydomain .com$/
          Message 4 of 23 , Feb 14, 2013
          View Source
          • 0 Attachment
            I apologize, as I am being confused.
            Contents of my virtual-regex now are:

            /somename+.*@mydomain\.com$/ somename@...
            /^somename...@mydomain\.com$/ somename@...

            /@mydomain\.com$/ somename@...
            /./ localuser

            When I ran postmap -q somename@... regexp:virtual.regex. I actually get correct results.
            When I ran mailx somename@... and vary name and domain all mails goes to localuser. Nothing is being forwarded out to somename@... even though regex patter should match.

            What do I need to change?

            Thank you for your help.




            On Thu, Feb 14, 2013 at 10:26 AM, Noel Jones <njones@...> wrote:
            On 2/14/2013 11:16 AM, Alex wrote:
            > Hello,
            >
            > I am having an issue with setting up virtual-regex email
            > redirection. It appears that my wild card redirection is overriding
            > an entry with less specific criteria.
            >
            > Here is what I have in my /etc/postfix/virtual-regex
            >
            > /somename+.*@somedomain.com/ <http://somedomain.com/> some...@...
            > /.*@.*/ somelocaluser
            >
            >
            > Line one is being ignored

            Line 1 is not ignored, the problem is that wildcards are evil and
            should be avoided.

            Virtual alias lookups are recursive, so you'll need a 1-1 mapping to
            stop the recursion.  Also be careful with your expressions so you
            don't get unintended matches. Something like:


            /somename+.*@example\.com$/ some...@...
            /^some...@gmail\.com$/  some...@...

            IF /@example\.com$/
            /./ somelocaluser@...
            ENDIF


            If you really intend your wildcard to capture the whole internet
            address space and redirect it to somelocaluser, you can remove the
            IF and ENDIF statements.  Such a setup is common in a testing lab,
            but never in the real world.


              -- Noel Jones

          • Wietse Venema
            ... That s now what you should query. What virtual alias expansion does is equivalent to this: postmap -q somename@somedomain.com regexp:virtual.regex postmap
            Message 5 of 23 , Feb 14, 2013
            View Source
            • 0 Attachment
              Alex:
              > When I ran postmap -q somename@... regexp:virtual.regex.
              > I actually get correct results.

              That's now what you should query.

              What virtual alias expansion does is equivalent to this:

              postmap -q somename@... regexp:virtual.regex

              postmap -q RESULT-FROM-PREVIOUS-QUESTION regexp:virtual.regex

              postmap -q RESULT-FROM-PREVIOUS-QUESTION regexp:virtual.regex

              until there is no result, or until the question appears in the result.

              Wietse
            • Noel Jones
              ... Don t use HTML; use the gmail plain text button. Don t top-post. Put responses at the bottom or in-line. ... Bad expression. username containing
              Message 6 of 23 , Feb 14, 2013
              View Source
              • 0 Attachment
                On 2/14/2013 1:40 PM, Alex wrote:
                > I apologize, as I am being confused.

                Don't use HTML; use the gmail plain text button.
                Don't top-post. Put responses at the bottom or in-line.


                > Contents of my virtual-regex now are:
                >
                > /somename+.*@mydomain\.com$/ somename@...
                > <mailto:somename@...>

                Bad expression. username containing "somenam" followed by a series
                of "eeeee" followed by anything probably not what you intend.

                better:
                /^somename\+.*@example\.com$/ somename@...


                > /^somename...@mydomain\.com$/ somename@...
                > <mailto:somename@...>

                Where's the 1-1 mapping to stop recursion? That's why it still
                doesn't work for you.

                /^somename@yahoo\.com$/ somename@...


                >
                > /@mydomain\.com$/ somename@... <mailto:somename@...>

                Don't know where you came up with that. Remove it.

                > /./ localuser
                >
                > When I ran postmap -q somename@...
                > <mailto:somename@...> regexp:virtual.regex.
                > I actually get correct results.

                because postmap doesn't do recursion.





                -- Noel Jones
              • Alex
                Apparently I do not understand what you mean by 1-1 mapping. My intentions is to have any email going to: somename(....any character)@somedomain.com to be
                Message 7 of 23 , Feb 14, 2013
                View Source
                • 0 Attachment
                  Apparently I do not understand what you mean by 1-1 mapping. My
                  intentions is to have any email going to:

                  somename(....any character)@... to be forwarded to somename@...

                  all other email to be sent to a local user.

                  Again thank you for your help.
                • /dev/rob0
                  ... All hail JWZ! [1] I d anchor this expression on the beginning, and escape the + : /^somename +.*@example .com$/ some...@gmail.com ... I ll toss out
                  Message 8 of 23 , Feb 14, 2013
                  View Source
                  • 0 Attachment
                    On Thu, Feb 14, 2013 at 12:26:34PM -0600, Noel Jones wrote:
                    > On 2/14/2013 11:16 AM, Alex wrote:
                    > > I am having an issue with setting up virtual-regex email
                    > > redirection. It appears that my wild card redirection is
                    > > overriding an entry with less specific criteria.
                    > >
                    > > Here is what I have in my /etc/postfix/virtual-regex
                    > >
                    > > /somename+.*@.../ <http://somedomain.com/> some...@...
                    > > /.*@.*/ somelocaluser
                    > >
                    > >
                    > > Line one is being ignored
                    >
                    > Line 1 is not ignored, the problem is that wildcards are evil and
                    > should be avoided.
                    >
                    > Virtual alias lookups are recursive, so you'll need a 1-1 mapping
                    > to stop the recursion. Also be careful with your expressions so
                    > you don't get unintended matches. Something like:
                    >
                    >
                    > /somename+.*@example\.com$/ some...@...

                    All hail JWZ! [1] I'd anchor this expression on the beginning, and
                    escape the "+":

                    /^somename\+.*@example\.com$/ some...@...

                    > /^some...@gmail\.com$/ some...@...
                    >
                    > IF /@example\.com$/
                    > /./ somelocaluser@...
                    > ENDIF

                    I'll toss out another idea, of which JWZ would approve: a hash: map
                    followed by a static: map:

                    main.cf :

                    mydestination = localhost.localdomain[, ...]
                    # unset virtual_alias_domains to avoid all domains being included
                    # therein by the default setting $virtual_alias_maps
                    virtual_alias_domains =
                    virtual_alias_maps =
                    hash:/path/to/virtual_alias_maps,
                    static:somelocaluser@...

                    /path/to/virtual_alias_maps :

                    somelocaluser@... somelocaluser@...
                    some...@... some...@...


                    [1] http://en.wikiquote.org/wiki/Jamie_Zawinski#Attributed
                    --
                    http://rob0.nodns4.us/ -- system administration and consulting
                    Offlist GMX mail is seen only if "/dev/rob0" is in the Subject:
                  • Noel Jones
                    ... 1 /^somename.*@example .com$/ somename@yahoo.com 2 /^somename@yahoo .com$/ somename@yahoo.com 3 /./ somelocaluser@localhost.localdomain Line 1 -
                    Message 9 of 23 , Feb 14, 2013
                    View Source
                    • 0 Attachment
                      On 2/14/2013 2:23 PM, Alex wrote:
                      > Apparently I do not understand what you mean by 1-1 mapping. My
                      > intentions is to have any email going to:
                      >
                      > somename(....any character)@... to be forwarded to somename@...
                      >
                      > all other email to be sent to a local user.
                      >
                      > Again thank you for your help.
                      >


                      1 /^somename.*@example\.com$/ somename@...
                      2 /^somename@yahoo\.com$/ somename@...
                      3 /./ somelocaluser@...


                      Line 1 - redirect secret name to yahoo account
                      line 2 - 1-1 mapping to stop recursion, input equals output
                      line 3 - wildcard catchall


                      Good luck.


                      -- Noel Jones
                    • Alex
                      Hi Noel, ... Wildcard line still catching all emails. Any other information I can provide? Thanks
                      Message 10 of 23 , Feb 14, 2013
                      View Source
                      • 0 Attachment
                        Hi Noel,

                        After implementing changes below:

                        > 1 /^somename.*@example\.com$/ somename@...
                        > 2 /^somename@yahoo\.com$/ somename@...
                        > 3 /./ somelocaluser@...

                        Wildcard line still catching all emails. Any other information I can provide?

                        Thanks
                      • Noel Jones
                        ... The above example works for me. Did you issue postfix reload after editing the regexp file? -- Noel Jones
                        Message 11 of 23 , Feb 14, 2013
                        View Source
                        • 0 Attachment
                          On 2/14/2013 4:15 PM, Alex wrote:
                          > Hi Noel,
                          >
                          > After implementing changes below:
                          >
                          >> 1 /^somename.*@example\.com$/ somename@...
                          >> 2 /^somename@yahoo\.com$/ somename@...
                          >> 3 /./ somelocaluser@...
                          >
                          > Wildcard line still catching all emails. Any other information I can provide?
                          >
                          > Thanks
                          >


                          The above example works for me. Did you issue "postfix reload"
                          after editing the regexp file?



                          -- Noel Jones
                        • Alex
                          ... Yes, I am doing postfix reload, I have verified that adding and removing willdcard has effect. Could aliases file have adverse effect?
                          Message 12 of 23 , Feb 14, 2013
                          View Source
                          • 0 Attachment
                            >
                            > The above example works for me. Did you issue "postfix reload"
                            > after editing the regexp file?


                            Yes, I am doing postfix reload, I have verified that adding and
                            removing willdcard has effect. Could aliases file have adverse effect?
                          • Noel Jones
                            ... Lots of things could have adverse effect, but no one knows what you ve done. The sample regexp file provided works for me. -- Noel Jones
                            Message 13 of 23 , Feb 14, 2013
                            View Source
                            • 0 Attachment
                              On 2/14/2013 5:11 PM, Alex wrote:
                              >>
                              >> The above example works for me. Did you issue "postfix reload"
                              >> after editing the regexp file?
                              >
                              >
                              > Yes, I am doing postfix reload, I have verified that adding and
                              > removing willdcard has effect. Could aliases file have adverse effect?
                              >


                              Lots of things could have adverse effect, but no one knows what
                              you've done.

                              The sample regexp file provided works for me.



                              -- Noel Jones
                            • Alex
                              I have checked my syntax and added another email matching string. It works only if wild card match is not present. As soon as wildcard is added other matches
                              Message 14 of 23 , Feb 15, 2013
                              View Source
                              • 0 Attachment

                                I have checked my syntax and added another email matching string. It works only if wild card match is not present. As soon as wildcard is added other matches stop working.  I can see in the maillog that initially regex is happening and then wildcard takes over. Is there anything else I can look at it? Thank you

                              • Noel Jones
                                ... As documented, virtual_alias_maps lookups are recursive, meaning the map is searched repeatedly until either there is no result, or the result is the same
                                Message 15 of 23 , Feb 15, 2013
                                View Source
                                • 0 Attachment
                                  On 2/15/2013 10:34 AM, Alex wrote:
                                  > I have checked my syntax and added another email matching string. It
                                  > works only if wild card match is not present. As soon as wildcard is
                                  > added other matches stop working. I can see in the maillog that
                                  > initially regex is happening and then wildcard takes over. Is there
                                  > anything else I can look at it? Thank you
                                  >

                                  As documented, virtual_alias_maps lookups are recursive, meaning the
                                  map is searched repeatedly until either there is no result, or the
                                  result is the same as the lookup key.

                                  To keep the wildcard from grabbing everything (wildcards are evil),
                                  your map must have extra entries to "protect" the addresses you
                                  don't want grabbed by the wildcard. This is called a 1-1 mapping entry.

                                  Your map must be structured similar to:

                                  A -> B # rewrite A to B
                                  B -> B # 1-1 mapping to protect B from wildcard
                                  wildcard # wildcard matches everything

                                  Your map is missing the 1-1 mapping entry, so the wildcard matches
                                  everything.




                                  -- Noel Jones
                                • Alex
                                  It seems that regex is indeed working, but something is forcing email into local host instead of outside. This only happens with wildcard in place. Here is an
                                  Message 16 of 23 , Feb 15, 2013
                                  View Source
                                  • 0 Attachment
                                    It seems that regex is indeed working, but something is forcing email
                                    into local host instead of outside. This only happens with wildcard in
                                    place.

                                    Here is an extract from maillog:

                                    Feb 15 14:30:54 qa6 postfix/error[9898]: A6EC61F88989:
                                    to=<somename@...>, orig_to=<somename@...>, relay=none,
                                    delay=0.02, delays=0.01/0/0/0.01, dsn=5.0.0, status=bounced (User
                                    unknown in virtual alias table)
                                  • Noel Jones
                                    ... Postfix is documented here: http://www.postfix.org/documentation.html -- Noel Jones
                                    Message 17 of 23 , Feb 15, 2013
                                    View Source
                                    • 0 Attachment
                                      On 2/15/2013 4:35 PM, Alex wrote:
                                      > It seems that regex is indeed working, but something is forcing email
                                      > into local host instead of outside. This only happens with wildcard in
                                      > place.
                                      >
                                      > Here is an extract from maillog:
                                      >
                                      > Feb 15 14:30:54 qa6 postfix/error[9898]: A6EC61F88989:
                                      > to=<somename@...>, orig_to=<somename@...>, relay=none,
                                      > delay=0.02, delays=0.01/0/0/0.01, dsn=5.0.0, status=bounced (User
                                      > unknown in virtual alias table)
                                      >


                                      Postfix is documented here:
                                      http://www.postfix.org/documentation.html


                                      -- Noel Jones
                                    • Alex
                                      Hi Noel, Furthermore wildcard seems to have an effect only on email addresses for the parent domain of the postfix host. If I send email to @yahoo and regex
                                      Message 18 of 23 , Feb 15, 2013
                                      View Source
                                      • 0 Attachment
                                        Hi Noel,

                                        Furthermore wildcard seems to have an effect only on email addresses
                                        for the parent domain of the postfix host.
                                        If I send email to @yahoo and regex changes it to @..., this works fine.
                                        If I send email to @mydomain regex changes it to wildcard.

                                        Does it make sense?
                                      • Noel Jones
                                        ... I m sure postfix is doing exactly what you ve told it to do. Postfix is documented here: http://www.postfix.org/documentation.html -- Noel Jones
                                        Message 19 of 23 , Feb 15, 2013
                                        View Source
                                        • 0 Attachment
                                          On 2/15/2013 5:25 PM, Alex wrote:
                                          > Hi Noel,
                                          >
                                          > Furthermore wildcard seems to have an effect only on email addresses
                                          > for the parent domain of the postfix host.
                                          > If I send email to @yahoo and regex changes it to @..., this works fine.
                                          > If I send email to @mydomain regex changes it to wildcard.
                                          >
                                          > Does it make sense?
                                          >


                                          I'm sure postfix is doing exactly what you've told it to do.

                                          Postfix is documented here:
                                          http://www.postfix.org/documentation.html



                                          -- Noel Jones
                                        • Alex
                                          No doubt about it. I just wish I can understand how to change it. :) Any ideas?
                                          Message 20 of 23 , Feb 15, 2013
                                          View Source
                                          • 0 Attachment
                                            No doubt about it. I just wish I can understand how to change it. :)
                                            Any ideas?
                                          • /dev/rob0
                                            ... Did you see my post yesterday? Pay close attention to the setting (unsetting, actually) of virtual_alias_domains.
                                            Message 21 of 23 , Feb 15, 2013
                                            View Source
                                            • 0 Attachment
                                              On Fri, Feb 15, 2013 at 02:35:31PM -0800, Alex wrote:
                                              > It seems that regex is indeed working, but something is forcing
                                              > email into local host instead of outside. This only happens with
                                              > wildcard in place.
                                              >
                                              > Here is an extract from maillog:
                                              >
                                              > Feb 15 14:30:54 qa6 postfix/error[9898]: A6EC61F88989:
                                              > to=<somename@...>, orig_to=<somename@...>, relay=none,
                                              > delay=0.02, delays=0.01/0/0/0.01, dsn=5.0.0, status=bounced (User
                                              > unknown in virtual alias table)

                                              Did you see my post yesterday? Pay close attention to the setting
                                              (unsetting, actually) of virtual_alias_domains.

                                              http://www.postfix.org/ADDRESS_CLASS_README.html#virtual_alias_class
                                              http://www.postfix.org/VIRTUAL_README.html#virtual_alias
                                              http://www.postfix.org/postconf.5.html#virtual_alias_domains
                                              http://www.postfix.org/postconf.5.html#virtual_alias_maps
                                              --
                                              http://rob0.nodns4.us/ -- system administration and consulting
                                              Offlist GMX mail is seen only if "/dev/rob0" is in the Subject:
                                            • Alex
                                              Solved. One typo. I guess I was staring at the file to long.
                                              Message 22 of 23 , Feb 15, 2013
                                              View Source
                                              • 0 Attachment
                                                Solved. One typo. I guess I was staring at the file to long.
                                              Your message has been successfully submitted and would be delivered to recipients shortly.