SV: SV: [Exim] I need help to implement sender rules for vir…

Góra strony
Delete this message
Reply to this message
Autor: Flemming Christensen
Data:  
Dla: exim-users
CC: ph10
Temat: SV: SV: [Exim] I need help to implement sender rules for virtualdomain users (panic error!)
I tried what you suggested Philip but I still get a panic error.

This is my router:
------------------------
forbid_external_in:
  driver = redirect
  domains = +internal_domains
  condition = ${if and \
                 {\
                   eq {\
                        ${lookup mysql\
                           {select local_only from user where \
                            mailadresse='${quote_mysql:$local_part@$domain}'\
                           }\
                         }\
                      }\
                      {1} \
                 } \
                 {eq {\
                        ${lookup mysql\
                            {select domain from user \
                            where domain = '${domain:$sender_address}'\
                            }\
                         }\
                      }\
                      {} \
                 }\
                 {yes}{no}\
               }
  allow_fail
  data = :fail:



This is the error from exim_panic.log
-------
2002-07-31 08:59:37 17ZnS0-0001pb-00 failed to expand condition "${if and {eq {${lookup mysql{select local_only from use
r where mailadresse='${quote_mysql:$local_part@$domain}'}}}{1} } {eq {${lookup mysql{select domain from user where domai
n = '${domain:$sender_address}'}}}{} }{yes}{no}}" for forbid_external_in router: subcondition in {} expected inside "and
{...}" condition





-----Oprindelig meddelelse-----
Fra: Philip Hazel [mailto:ph10@cus.cam.ac.uk]
Sendt: 30. juli 2002 17:24
Til: Flemming Christensen
Cc: Joachim Wieland; Exim-Users (E-mail)
Emne: Re: SV: [Exim] I need help to implement sendder rules for
virtualdomain users


I always split up complicated expansions like this when debugging:


condition = ${if and
               {
               eq {
                    ${lookup mysql
                        {select local_only from user where
                         mailadresse='${quote_mysql:$local_part@$domain}'
                        }
                     }               <<<<<<<
                     {$value}
                  }


That looks like your problem. The } I have indicated terminates the
${lookup. So the {$value} isn't much use here. Mind you, it will just be
an empty string, so it won't do much (but some of the spaces will be
part of the looked up value). Just delete "${value}".

                  {1}{yes}{no}


There's the next problem. eq{x}{y} is a complete condition. Since it is
part of an "and", it must be enclosed inside {}. That's what Exim is
complaining about. You don't want "{yes}{no}" there.

               }


               {
               eq {
                    $lookup mysql{select domain from user
                     ^
                     ^
               Missing { here.


                                  where domain = '${domain:$sender_address}'
                                  }
                     }                 <<<<<<<<<<<<< same remark
                     {$value}          <<<<<<<<<<<<<
                  }


                  {}{yes}{no}          <<<<<<<< and here
               }


             <<<<<<<<<<< This is where you want "{yes}{no}"


             }


If is often helpful to use macros to define long things like SQL
queries, so that the options are easier to read. You need something like

condition = ${if and {                    \
                     {eq {LOOKUP1}{1}}    \
                     {eq {LOOKUP2}{}}     \
                     }                    \
                 {yes}{no}}



where you define the macros (at the top of the config) like so:

LOOKUP1=${lookup mysql{select local_only from user where \
                       mailadresse='${quote_mysql:$local_part@$domain}'}}






--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.