Hi list,
I''m trying to setup some very basic blacklisting of hosts that
consistently fail to pass some of my acl statements so as to deny them
earlier in the smtp transaction.
I have setup a basic mysql table to contain the data.
So far I have a lookup of the database working fine as follows:
# Check if host has failed recipient verification in the past
warn
set acl_m_dfind = ${lookup mysql\
{SELECT failed FROM dictbl \
WHERE
host=''$sender_host_address''; \
}{$value}}
# If the above check yielded a null result, set acl_m_dfind to 0
warn
condition = ${if eq\
{$acl_m_dfind}\
{}\
{1}}
set acl_m_dfind = 0
My issue is with the next acl that drops if $rcpt_count > 1, this is
where I want to INSERT the host into the table thus I have:
# Drop connection if more than three recipients fail to verify
drop
!hosts = +remote_hosts
message = Too many failed recipients
domains = +local_domains
condition = ${if >\
{$rcpt_fail_count}\
{1}\
{1}{0}}
set acl_m_dict = ${lookup mysql\
{INSERT INTO dictbl \
VALUES (
''$sender_host_address'', \
''${eval:$rcpt_fail_count+$acl_m_dfind'');}}
The above statement leaves me with the following error in mainlog:
failed to expand ACL string "${lookup mysql{INSERT INTO dictbl VALUES (
''$sender_host_address'',
''${eval:$rcpt_fail_count+$acl_m_dfind'');}}":
error in expression evaluation: expecting operator (after processing
"3+0")
So I''ve tried changing the eval part of the lookup to read:
''${eval:($rcpt_fail_count)+($acl_m_dfind)'');}}
with the same result (expected that but I like to prove to myself thats
the case) and also:
''${eval:$rcpt_fail_count+${sg{$acl_m_dfind}}}'');}}
which gives me the following error:
failed to expand ACL string "${lookup mysql{INSERT INTO dictbl VALUES (
''$sender_host_address'',
''${eval:$rcpt_fail_count+${sg{$acl_m_dfind}}}'');}}":
missing or
misplaced { or }
I''m sure I''m just mis-understanding something, but having a
tough time
figuring it out; think I just need a finger pointing out my mistake :P
I know the above is a bit crude, but it''s more of a proof of concept as
this is the first time I''ve tried to have Exim talk to a mysql database
Thanks in advance for any help :)
James
Andreas Metzler
2009-Aug-22 11:38 UTC
[Pkg-exim4-users] Unable to eval from acl_m variable
James Riach <james at jriach.co.uk> wrote: [...]> # Drop connection if more than three recipients fail to verify > drop > !hosts = +remote_hosts > message = Too many failed recipients > domains = +local_domains > condition = ${if >\ > {$rcpt_fail_count}\ > {1}\ > {1}{0}} > set acl_m_dict = ${lookup mysql\ > {INSERT INTO dictbl \ > VALUES ( ''$sender_host_address'', \ > ''${eval:$rcpt_fail_count+$acl_m_dfind'');}}> The above statement leaves me with the following error in mainlog:> failed to expand ACL string "${lookup mysql{INSERT INTO dictbl VALUES ( > ''$sender_host_address'', ''${eval:$rcpt_fail_count+$acl_m_dfind'');}}": > error in expression evaluation: expecting operator (after processing "3+0")Shouldn''t the eval contain *only* the addition, currently you seem to ask exim to add up "2" and "3;)". How about: ''${eval:$rcpt_fail_count+$acl_m_dfind}'');} cu andreas -- `What a good friend you are to him, Dr. Maturin. His other friends are so grateful to you.'' `I sew his ears on from time to time, sure''
Andreas Metzler wrote:> James Riach <james at jriach.co.uk> wrote: > [...] > >> # Drop connection if more than three recipients fail to verify >> drop >> !hosts = +remote_hosts >> message = Too many failed recipients >> domains = +local_domains >> condition = ${if >\ >> {$rcpt_fail_count}\ >> {1}\ >> {1}{0}} >> set acl_m_dict = ${lookup mysql\ >> {INSERT INTO dictbl \ >> VALUES ( ''$sender_host_address'', \ >> ''${eval:$rcpt_fail_count+$acl_m_dfind'');}} >> > > >> The above statement leaves me with the following error in mainlog: >> > > >> failed to expand ACL string "${lookup mysql{INSERT INTO dictbl VALUES ( >> ''$sender_host_address'', ''${eval:$rcpt_fail_count+$acl_m_dfind'');}}": >> error in expression evaluation: expecting operator (after processing "3+0") >> > > Shouldn''t the eval contain *only* the addition, currently you seem to > ask exim to add up "2" and "3;)". How about: > ''${eval:$rcpt_fail_count+$acl_m_dfind}'');} > > cu andreas > >Haha that''s the ticket, can''t believe I was so stupid to have missed that, it''s so obvious now :D Thanks Andreas this is much appreciated. Regards, James