Re: [exim] Sourcing Exim Filter from MySQL/MariaDB table?

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Mike Tubby
Dátum:  
Címzett: exim-users
Tárgy: Re: [exim] Sourcing Exim Filter from MySQL/MariaDB table?

On 08/05/2019 00:57, Jeremy Harris via Exim-users wrote:
> On 08/05/2019 00:39, Mike Tubby via Exim-users wrote:
>
>> user_filter:
>>     driver = forwardfile
>>     data = ${lookup mysql{SELECT rule FROM users LEFT JOIN domains \
>>         ON domains.id=users.domain_id LEFT JOIN filters \
>>         ON users.id=filters.user_id WHERE
>> domains.domain='${quote_mysql:$domain}' \
>>         AND users.username='${quote_mysql:$local_part}' \
>>         AND domains.active=1 \
>>         AND users.active=1 \
>>         AND filters.active=1}}
>>     no_verify
>>     no_expn
>>     check_ancestor
> Where's your rule ordering? And what on earth is "forwardfile" ?


erm, that's something left over from an Exim 3.x config file which I
used to create the above example - my bad ;-(


>> Am I going to need to arrange for the database result set to start with
>> '# Exim Filter' each time or is their a boolean to force this?
>>
>> If there isn't a boolean to force it, then it would be good to have a
>> 'is_filter' boolean ;-)
> No, there's not enough call for that; it's your problem :)
> It's only a string; just glom it on before the result
> of the DB lookup expansion.


I can do but I cannot obviously see how to do string concatenation in to
'data ='  (have you tried lloking up how to do this string concat in the
Exim documentation?)

     data = "# Exim Filter \n\n" ${lookup mysql{SELECT rule FROM users LEFT JOIN domains \
         ON domains.id=users.domain_id LEFT JOIN filters \
         ON users.id=filters.user_id WHERE
    domains.domain='${quote_mysql:$domain}' \
         AND users.username='${quote_mysql:$local_part}' \
         AND domains.active=1 \
         AND users.active=1 \
         AND filters.active=1 ORDER BY filters.id ASC LIMIT 100}}



Fixing the order of the filters and a sensible maximum is trivial with a
bit of SQL.

>> As far as memory utilisation goes, won't Exim discard any memory it
>> allocated for the result set at the end of the delivery?
> Yes. I wasn't meaning permanent.


Good ;-)