Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: exim: users

Using ${run ...} to execute external command, dealing with result, Exim syntax

 

 

exim users RSS feed   Index | Next | Previous | View Threaded


morten at nidelven-it

Aug 27, 2009, 7:55 AM

Post #1 of 9 (1183 views)
Permalink
Using ${run ...} to execute external command, dealing with result, Exim syntax

Hi,

I'm trying to use an external python script to verify that a remote SMTP
host
can accept a recipient. Using Exim's callout didn't work (getting too many
write lock issues).

The configuration looks like this:

[...]
begin acl

greylist_acl:
warn set acl_m8 = ${run{/opt/nidelven/do_remote_callout.py
$local_part $domain $sender_address $sender_host_address
$sender_helo_name}{$value}{error}}
log_message = greylisting ACL result: $acl_m8
accept
condition = ${if eq{$acl_m8}{greylist}{1}}
deny
[...]

However, I don't see any entries in the log, so it doesn't look like the
command
or the logging is being run. Am I missing something to get logging working?

What is the right way to access the result of the command? Is that
stored in
acl_m8? Does $runrc represent the exit value of the command?

What's the right syntax for checking the exit value against 0, 1 etc?

Thanks,

Morten

--
Morten W. Petersen
Manager
Nidelven IT Ltd

Phone: +47 45 44 00 69
Email: morten [at] nidelven-it


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


Frank.Elsner at TU-Berlin

Aug 27, 2009, 9:17 AM

Post #2 of 9 (1141 views)
Permalink
Re: Using ${run ...} to execute external command, dealing with result, Exim syntax [In reply to]

On Thu, 27 Aug 2009 16:55:15 +0200 Morten W. Petersen wrote:
> Hi,
>
> I'm trying to use an external python script to verify that a remote SMTP
> host
> can accept a recipient. Using Exim's callout didn't work (getting too many
> write lock issues).

Have you ever heard of "recipient callout verification?
If not you should read
http://www.exim.org/exim-html-current/doc/html/spec_html/ch40.html#SECTcallver

--Frank Elsner

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


Dan_Mitton at YMP

Aug 27, 2009, 9:21 AM

Post #3 of 9 (1149 views)
Permalink
Re: Using ${run ...} to execute external command, dealing with result, Exim syntax [In reply to]

Morten,

I'm assuming that something is invoking 'greylist_acl'. ACLs are not like
routers where they get tried top down. Something must invoke it.

acl_m8 will get set to the STDOUT & SDTERR from your script (which might
include <CR><LF>). Remember, that there is no shell !!

Yes, $runrc is the return code from the run command. You might want to
try logging it too.

Also, try putting a couple of log_message lines before and after your
$run, just to make sure your even getting there.

Dan



Sent by: exim-users-bounces [at] exim
To: "exim-users @ exim. org" <exim-users [at] exim>
cc: (bcc: Dan Mitton/YD/RWDOE)
Subject: [exim] Using ${run ...} to execute external command,
dealing with result, Exim syntax
LSN: Not Relevant
User Filed as: Not a Record

Hi,

I'm trying to use an external python script to verify that a remote SMTP
host
can accept a recipient. Using Exim's callout didn't work (getting too
many
write lock issues).

The configuration looks like this:

[...]
begin acl

greylist_acl:
warn set acl_m8 = ${run{/opt/nidelven/do_remote_callout.py
$local_part $domain $sender_address $sender_host_address
$sender_helo_name}{$value}{error}}
log_message = greylisting ACL result: $acl_m8
accept
condition = ${if eq{$acl_m8}{greylist}{1}}
deny
[...]

However, I don't see any entries in the log, so it doesn't look like the
command
or the logging is being run. Am I missing something to get logging
working?

What is the right way to access the result of the command? Is that
stored in
acl_m8? Does $runrc represent the exit value of the command?

What's the right syntax for checking the exit value against 0, 1 etc?

Thanks,

Morten

--
Morten W. Petersen
Manager
Nidelven IT Ltd

Phone: +47 45 44 00 69
Email: morten [at] nidelven-it


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


hs at schlittermann

Aug 27, 2009, 12:58 PM

Post #4 of 9 (1134 views)
Permalink
Re: Using ${run ...} to execute external command, dealing with result, Exim syntax [In reply to]

Morten W. Petersen <morten [at] nidelven-it> (Do 27 Aug 2009 16:55:15 CEST):
> Hi,
>
> I'm trying to use an external python script to verify that a remote SMTP
> host
> can accept a recipient. Using Exim's callout didn't work (getting too many
> write lock issues).
>
> The configuration looks like this:
>
> [...]
> begin acl
>
> greylist_acl:
> warn set acl_m8 = ${run{/opt/nidelven/do_remote_callout.py
> $local_part $domain $sender_address $sender_host_address
> $sender_helo_name}{$value}{error}}
> log_message = greylisting ACL result: $acl_m8
> accept
> condition = ${if eq{$acl_m8}{greylist}{1}}
> deny
> [...]
> However, I don't see any entries in the log, so it doesn't look like the
> command
> or the logging is being run. Am I missing something to get logging working?

First question: did you configure the use of your greylist_acl?
When it should run at „RCPT TO“ time, you should set (in the global part
of the config)

acl_smtp_rcpt = greylist_acl

And, I'd write the ACL this way:

greylist_acl:
accept condition = ${run{/opt/nidelven/do_remote_callout.py \
$local_part \
$domain \
$sender_address \
$sender_host_address \
$sender_helo_name}\
{true}{false}}
deny

And in this case you should make sure, that your command exists with a
zero exit value (as normal programs do) on success and with anything
else on verification error.

On the other hand, I'd investigate the problems regarding the built in
callout verification, except for some special requirements it should
just work.

> What is the right way to access the result of the command? Is that
> stored in
> acl_m8? Does $runrc represent the exit value of the command?

Should. Should.

> What's the right syntax for checking the exit value against 0, 1 etc?

condition = $acl_m8

should suffice.

But(!) I may be wrong, so double check my answer and have a look into
the spec file.


Best regards from Dresden/Germany
Viele Grüße aus Dresden
Heiko Schlittermann
--
SCHLITTERMANN.de ---------------------------- internet & unix support -
Heiko Schlittermann HS12-RIPE -----------------------------------------
gnupg encrypted messages are welcome - key ID: 48D0359B ---------------
gnupg fingerprint: 3061 CFBF 2D88 F034 E8D2 7E92 EE4E AC98 48D0 359B -
Attachments: signature.asc (0.19 KB)


hs at schlittermann

Aug 27, 2009, 1:03 PM

Post #5 of 9 (1140 views)
Permalink
Re: Using ${run ...} to execute external command, dealing with result, Exim syntax [In reply to]

Morten W. Petersen <morten [at] nidelven-it> (Do 27 Aug 2009 16:55:15 CEST):
> Hi,
…
> I'm trying to use an external python script to verify that a remote SMTP
> host

If the builtin callout does not suffice, I'd try using „swaks“, it
should do everything you need.

Best regards from Dresden/Germany
Viele Grüße aus Dresden
Heiko Schlittermann
--
SCHLITTERMANN.de ---------------------------- internet & unix support -
Heiko Schlittermann HS12-RIPE -----------------------------------------
gnupg encrypted messages are welcome - key ID: 48D0359B ---------------
gnupg fingerprint: 3061 CFBF 2D88 F034 E8D2 7E92 EE4E AC98 48D0 359B -
Attachments: signature.asc (0.19 KB)


morten at nidelven-it

Sep 3, 2009, 10:42 AM

Post #6 of 9 (1055 views)
Permalink
Re: Using ${run ...} to execute external command, dealing with result, Exim syntax [In reply to]

Heiko Schlittermann skrev:
> Morten W. Petersen <morten [at] nidelven-it> (Do 27 Aug 2009 16:55:15 CEST):
>
>> Hi,
>>
>> I'm trying to use an external python script to verify that a remote SMTP
>> host
>> can accept a recipient. Using Exim's callout didn't work (getting too many
>> write lock issues).
>>
>> The configuration looks like this:
>>
>> [...]
>> begin acl
>>
>> greylist_acl:
>> warn set acl_m8 = ${run{/opt/nidelven/do_remote_callout.py
>> $local_part $domain $sender_address $sender_host_address
>> $sender_helo_name}{$value}{error}}
>> log_message = greylisting ACL result: $acl_m8
>> accept
>> condition = ${if eq{$acl_m8}{greylist}{1}}
>> deny
>> [...]
>> However, I don't see any entries in the log, so it doesn't look like the
>> command
>> or the logging is being run. Am I missing something to get logging working?
>>
>
> First question: did you configure the use of your greylist_acl?
> When it should run at „RCPT TO“ time, you should set (in the global part
> of the config)
>
> acl_smtp_rcpt = greylist_acl
>
> And, I'd write the ACL this way:
>
> greylist_acl:
> accept condition = ${run{/opt/nidelven/do_remote_callout.py \
> $local_part \
> $domain \
> $sender_address \
> $sender_host_address \
> $sender_helo_name}\
> {true}{false}}
> deny
>
> And in this case you should make sure, that your command exists with a
> zero exit value (as normal programs do) on success and with anything
> else on verification error.
>
> On the other hand, I'd investigate the problems regarding the built in
> callout verification, except for some special requirements it should
> just work.
>
>
>> What is the right way to access the result of the command? Is that
>> stored in
>> acl_m8? Does $runrc represent the exit value of the command?
>>
>
> Should. Should.
>
>
>> What's the right syntax for checking the exit value against 0, 1 etc?
>>
>
> condition = $acl_m8
>
> should suffice.
>
> But(!) I may be wrong, so double check my answer and have a look into
> the spec file.
>

$acl_m8 seems to be empty, but runrc does the trick. Thanks for the help! :)

-Morten

--
Morten W. Petersen
Manager
Nidelven IT Ltd

Phone: +47 45 44 00 69
Email: morten [at] nidelven-it


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


morten at nidelven-it

Sep 4, 2009, 6:50 AM

Post #7 of 9 (1050 views)
Permalink
Re: Using ${run ...} to execute external command, dealing with result, Exim syntax [In reply to]

Morten W. Petersen skrev:
> Heiko Schlittermann skrev:
>
>> Morten W. Petersen <morten [at] nidelven-it> (Do 27 Aug 2009 16:55:15 CEST):
>>
>>
>>> Hi,
>>>
>>> I'm trying to use an external python script to verify that a remote SMTP
>>> host
>>> can accept a recipient. Using Exim's callout didn't work (getting too many
>>> write lock issues).
>>>
>>> The configuration looks like this:
>>>
>>> [...]
>>> begin acl
>>>
>>> greylist_acl:
>>> warn set acl_m8 = ${run{/opt/nidelven/do_remote_callout.py
>>> $local_part $domain $sender_address $sender_host_address
>>> $sender_helo_name}{$value}{error}}
>>> log_message = greylisting ACL result: $acl_m8
>>> accept
>>> condition = ${if eq{$acl_m8}{greylist}{1}}
>>> deny
>>> [...]
>>> However, I don't see any entries in the log, so it doesn't look like the
>>> command
>>> or the logging is being run. Am I missing something to get logging working?
>>>
>>>
>> First question: did you configure the use of your greylist_acl?
>> When it should run at „RCPT TO“ time, you should set (in the global part
>> of the config)
>>
>> acl_smtp_rcpt = greylist_acl
>>
>> And, I'd write the ACL this way:
>>
>> greylist_acl:
>> accept condition = ${run{/opt/nidelven/do_remote_callout.py \
>> $local_part \
>> $domain \
>> $sender_address \
>> $sender_host_address \
>> $sender_helo_name}\
>> {true}{false}}
>> deny
>>
>> And in this case you should make sure, that your command exists with a
>> zero exit value (as normal programs do) on success and with anything
>> else on verification error.
>>
>> On the other hand, I'd investigate the problems regarding the built in
>> callout verification, except for some special requirements it should
>> just work.
>>
>>
>>
>>> What is the right way to access the result of the command? Is that
>>> stored in
>>> acl_m8? Does $runrc represent the exit value of the command?
>>>
>>>
>> Should. Should.
>>
>>
>>
>>> What's the right syntax for checking the exit value against 0, 1 etc?
>>>
>>>
>> condition = $acl_m8
>>
>> should suffice.
>>
>> But(!) I may be wrong, so double check my answer and have a look into
>> the spec file.
>>
>>
>
> $acl_m8 seems to be empty, but runrc does the trick. Thanks for the help! :)
>

OK, I now have a working system which checks the remote SMTP whether it
accepts the recipient.

However, the remote SMTP is sometimes unavailable.. is it possible to tell
Exim to give a temporary error if that's the case?

-Morten

--
Morten W. Petersen
Manager
Nidelven IT Ltd

Phone: +47 45 44 00 69
Email: morten [at] nidelven-it


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


jonathan at fluent

Sep 4, 2009, 9:19 AM

Post #8 of 9 (1052 views)
Permalink
Re: Using ${run ...} to execute external command, dealing with result, Exim syntax [In reply to]

Is it possible to run an external command after delivering a mail to a
mailbox? perhaps to fork an external delivery via SMTP from a maildir?

Kind Regards,

Jonathan Gilpin
Fluent Ltd
www.fluent.ltd.uk


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


eximX0902w at linuxwan

Sep 4, 2009, 5:10 PM

Post #9 of 9 (1049 views)
Permalink
Re: Using ${run ...} to execute external command, dealing with result, Exim syntax [In reply to]

On Fri, 2009-09-04 at 17:19 +0100, Jonathan Gilpin wrote:
> Is it possible to run an external command after delivering a mail to a
> mailbox? perhaps to fork an external delivery via SMTP from a maildir?

Not exactly -

Pipe delivery & do anything you want?

Use an unseen router to duplicate delivery

Use system filter to duplicate delivery

Once a message is delivered to all recipients, the work of the MTA is
done. If you want to do some thing once an email has been delivered
completely to a Maildir, perhaps you could look into using inotify or a
cron job.

--
The Exim manual - http://docs.exim.org


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

exim users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.