[exim] Run a Program from within Exim

2010-03-23 Thread David Cunningham
Hi All,

Sorry if I am repeating something already asked.  I searched the  
archive before sending this question and found only one thread that  
appears to be related, but does not seem to work.

The short of the story is that I need exim to execute another program  
upon the delivery of an email and send that program the following  
string:

"/var/spool/maildirs/${substr_0_10:$tod_log}/${domain}/${local_part}/Maildir/new"

For example, I tried adding a condition to my local_delivery transport  
that looked like this:

condition = {run echo  
"/var/spool/maildirs/${substr_0_10:$tod_log}/${domain}/${local_part}/Maildir"  
 >> /dev/shm/temp.file}{0}{1}

In this example I am simply trying to echo that string to a file in  
/dev/shm.  I do not get an error in my logs, but I also do not get  
this file.

Any advice is much appreciated.

Thanks!


-- 
## 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/


Re: [exim] Run a Program from within Exim

2010-03-23 Thread Lena
> From: David Cunningham

> I tried adding a condition to my local_delivery transport  
> that looked like this:
> 
> condition = {run echo  
> "/var/spool/maildirs/${substr_0_10:$tod_log}/${domain}/${local_part}/Maildir" 
>  
>  >> /dev/shm/temp.file}{0}{1}

The ">>" is a shell operator. ${run doesn't use shell by default.
An example from my config:

LIM = 100
PERIOD = 1h
WARNTO = ab...@example.com
DIR = /var/spool/exim
EXIMBINARY = /usr/local/sbin/exim
SHELL = /bin/sh
...
acl_check_rcpt:
...
  accept authenticated = *
set acl_m_user = ${sg{$authenticated_id}{\N\W.*$\N}{}}
condition = ${if exists{DIR/blocked_users}}
condition = ${if eq{${lookup{$acl_m_user}lsearch\
{DIR/blocked_users}{1}{0}}}{1}}
control = freeze/no_tell
add_header = X-Authenticated-As: $acl_m_user

  accept authenticated = *
!verify = recipient/defer_ok/callout=10s,defer_ok,use_sender
ratelimit = LIM / PERIOD / per_rcpt / user-$acl_m_user
continue = ${run{SHELL -c "echo $acl_m_user >>DIR/blocked_users; \
   \N{\N echo Subject: user $acl_m_user blocked; echo; echo because \
   has sent mail to more than LIM invalid recipients during PERIOD.; \
   \N}\N | EXIMBINARY WARNTO"}}
control = freeze/no_tell
add_header = X-Authenticated-As: $acl_m_user

-- 
## 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/


Re: [exim] Run a Program from within Exim

2010-03-23 Thread Jakob Hirsch
David Cunningham, 2010-03-23 12:46:

> The short of the story is that I need exim to execute another program  
> upon the delivery of an email and send that program the following  
> string:
> "/var/spool/maildirs/${substr_0_10:$tod_log}/${domain}/${local_part}/Maildir/new"

What do you mean by "send"? Give as an argument? Write to its stdin?

> For example, I tried adding a condition to my local_delivery transport  
> that looked like this:
> 
> condition = {run echo  
> "/var/spool/maildirs/${substr_0_10:$tod_log}/${domain}/${local_part}/Maildir" 
>  
>  >> /dev/shm/temp.file}{0}{1}

RTFM:

1. The syntax is
${run{ }{}{}}
not
{run  ...}

2. "As in other command executions from Exim, a shell is not used by
default. If you want a shell, you must explicitly code it. "

As you use redirection in your test, you need to use a shell there.

3. You have to give the full path to the executable you want to run.
(Unfortunately, this is not documented in the spec of the ${run...}
expansion item. Should probably be added.)

So the expansion string would look like this:

${run {/bin/sh -c "echo
/var/spool/maildirs/${substr_0_10:$tod_log/${domain}/${local_part}/Maildir
>> /dev/shm/temp.file"}{0}{1}}

You really have to take care here that nobody can do shell injection
(e.g. by using ';' or other special shell chars in the local part). This
only applies when using a shell, so you should probably avoid that. Just
use a little script, that logs what your program would get, e.g.

#/bin/sh
echo $1 >> /tmp/bla.log

and use that instead of your real program.

> In this example I am simply trying to echo that string to a file in  
> /dev/shm.  I do not get an error in my logs, but I also do not get  
> this file.

Errors are hidden here. Look into $runrc to see what went wrong.


-- 
## 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/


Re: [exim] Run a Program from within Exim

2010-03-23 Thread David Cunningham

This is why I love mailing lists!

Thank you very  much!  That worked great!



Quoting Jakob Hirsch :

> David Cunningham, 2010-03-23 12:46:
>
>> The short of the story is that I need exim to execute another program
>> upon the delivery of an email and send that program the following
>> string:
>> "/var/spool/maildirs/${substr_0_10:$tod_log}/${domain}/${local_part}/Maildir/new"
>
> What do you mean by "send"? Give as an argument? Write to its stdin?
>
>> For example, I tried adding a condition to my local_delivery transport
>> that looked like this:
>>
>> condition = {run echo
>> "/var/spool/maildirs/${substr_0_10:$tod_log}/${domain}/${local_part}/Maildir"
>>  >> /dev/shm/temp.file}{0}{1}
>
> RTFM:
>
> 1. The syntax is
> ${run{ }{}{}}
> not
> {run  ...}
>
> 2. "As in other command executions from Exim, a shell is not used by
> default. If you want a shell, you must explicitly code it. "
>
> As you use redirection in your test, you need to use a shell there.
>
> 3. You have to give the full path to the executable you want to run.
> (Unfortunately, this is not documented in the spec of the ${run...}
> expansion item. Should probably be added.)
>
> So the expansion string would look like this:
>
> ${run {/bin/sh -c "echo
> /var/spool/maildirs/${substr_0_10:$tod_log/${domain}/${local_part}/Maildir
>>> /dev/shm/temp.file"}{0}{1}}
>
> You really have to take care here that nobody can do shell injection
> (e.g. by using ';' or other special shell chars in the local part). This
> only applies when using a shell, so you should probably avoid that. Just
> use a little script, that logs what your program would get, e.g.
>
> #/bin/sh
> echo $1 >> /tmp/bla.log
>
> and use that instead of your real program.
>
>> In this example I am simply trying to echo that string to a file in
>> /dev/shm.  I do not get an error in my logs, but I also do not get
>> this file.
>
> Errors are hidden here. Look into $runrc to see what went wrong.
>
>




-- 
## 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/


Re: [exim] Rewrite to Multiple Recipients

2010-03-23 Thread Matthias-Christian Ott
On Mon, Mar 22, 2010 at 09:52:40PM +, Dave Evans wrote:
> On Mon, Mar 22, 2010 at 03:42:46PM +0100, Matthias-Christian Ott wrote:
> > I have to following rewrite rule:
> > 
> > *...@* exam...@example.com T
> > 
> > How can I specify to rewrite it to multiple recipients, so that all
> > E-Mails are send to foo...@example.com and exam...@example.com?
> 
> Using a redirect router, not a rewrite.
> 
> Redirect routers are for changing the recipients of a message.  Rewrite rules
> are (primarily) for rewriting message headers; a completely different thing.

How would I do this? The documentation for the redirect router doesn't
contain an example for multiple recipients.

Regards,
Matthias-Christian

-- 
## 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] Problem with .forward

2010-03-23 Thread laurent ducos
Hello.
I'm french user of exim4 and i apologize for my bad English.
I configured exim4 with clamav and spamassassin on Debian.
Clamav :

   deny
 malware = *
 message = This message was detected as possible malware ($malware_name).

And Spamassassin :

   accept
  condition = ${if >={$message_size}{500k}{yes}{no}}
   warn
 spam = nobody:true
 message = X-Spam_score: $spam_score\n\
   X-Spam_score_int: $spam_score_int\n\
   X-Spam_bar: $spam_bar\n\
   X-Spam_report: $spam_report
   deny
  message = This message scored $spam_score spam points.
  spam = nobody:true
  condition = ${if >{$spam_score_int}{120}{1}{0}}

I'm doing tests with viruses, and spam testing and everything works well.
The problem is with the .forward

  # Exim filter
if error_message then
finish
endif

if $h_X-Spam_score_int is above 50 then
 save Maildir/.junkmail/
 finish
endif
finish

The problem is with the .forward. When I receive a local mail or mail with
attachments, I get a *Mail Delivery System,
*

An error has been found in your .forward file.


If someone knows the solution to this problem
-- 
## 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/


Re: [exim] Problem with .forward

2010-03-23 Thread Graeme Fowler
On Tue, 2010-03-23 at 15:25 +0100, laurent ducos wrote:
> If someone knows the solution to this problem

You can test the .forward file like so:

http://www.exim.org/exim-html-current/doc/html/filter.html#SECTtesting

Graeme


-- 
## 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] Exim 4.71 on netBSD pthreads

2010-03-23 Thread Niels Dettenbach
Dear all,


i'm fiddeling some time here with an update to Exim 4.71 on NetBSD but can't 
get it running as the running process complains:

  14512 LOG: MAIN
  14512   exim 4.71 daemon started: pid=14512, no queue runs, listening for 
SMTP on [w.x.y.z]:26 [127.0.0.1]:26 [127.0.0.1]:10026
_res is not supported for multi-threaded programs.

this seems not new and so i found and followed this thread: 
http://mail-index.netbsd.org/pkgsrc-users/2009/11/18/msg011153.html

and tried to remove all parts which (i think of) pulling out pthreads out of 
the exim build, but this brought no solution for me and btw i rely on things 
like mysql and openssl here.

This is my last working exim version on NetBSD (exim 4.69):

# ldd /usr/sbin/exim 
/usr/sbin/exim:
-lc.12 => /usr/lib/libc.so.12
-lcrypt.0 => /usr/lib/libcrypt.so.0
-lm.0 => /usr/lib/libm387.so.0
-lm.0 => /usr/lib/libm.so.0
-lcrypto.4 => /usr/lib/libcrypto.so.4
-lssl.6 => /usr/lib/libssl.so.6
-lz.1 => /usr/pkg/lib/libz.so.1
-lmysqlclient.15 => /usr/pkg/lib/libmysqlclient.so.15
-lresolv.1 => /usr/lib/libresolv.so.1
-lsasl2.2 => /usr/pkg/lib/libsasl2.so.2


And this is what i get compiled with 4.71:

# ldd build-NetBSD-i386/exim
build-NetBSD-i386/exim:
-lc.12 => /usr/lib/libc.so.12
-lcrypt.0 => /usr/lib/libcrypt.so.0
-lm.0 => /usr/lib/libm387.so.0
-lm.0 => /usr/lib/libm.so.0
-lcrypto.4 => /usr/lib/libcrypto.so.4
-lssl.6 => /usr/lib/libssl.so.6
-lz.1 => /usr/pkg/lib/libz.so.1
-lmysqlclient.15 => /usr/pkg/lib/libmysqlclient.so.15
-lpthread.0 => /usr/lib/libpthread.so.0
-lcrypto.0.9.8 => /usr/pkg/lib/libcrypto.so.0.9.8
-lssl.0.9.8 => /usr/pkg/lib/libssl.so.0.9.8
-lresolv.1 => /usr/lib/libresolv.so.1
-lsasl2.2 => /usr/pkg/lib/libsasl2.so.2
-lpcre.0 => /usr/pkg/lib/libpcre.so.0


As the machine is not used for exim alone it would be very nice to find any 
kind of solution here - i'm happy about any hint or tip here...

many many thanks in advance.
cheers,


Niels.

-- 

---

  Niels Dettenbach
  ---
  Syndicat IT&Internet
  http://www.syndicat.com
  T.-Muentzer.-Str. 2, 37308 Heilbad Heiligenstadt - DE
  ---
  Kryptoinfo: 
  PGP public key ID 651CA20D
  Fingerprint: 55E0 4DCD B04C 4A49 1586  88AE 54DC 4465 651C A20D
  https://syndicat.com/pub_key.asc
  ---

-- 
## 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/


Re: [exim] Problem with .forward

2010-03-23 Thread laurent ducos
I think that in case the value of $h_X-Spam_score_int is undefined, the
filter can not work.
I did a test with this rule has proved correct

# Exim filter
if 40 is above 70
then
save Maildir/.junkmail/
finish
endif

So if a mail came from the local area there is no value in the variable.
It should therefore that I can write a rule saying that if the header exists
X-Spam_score_int, then I apply the rules


2010/3/23 laurent ducos 

> Hello.
> I'm french user of exim4 and i apologize for my bad English.
> I configured exim4 with clamav and spamassassin on Debian.
> Clamav :
>
>deny
>  malware = *
>  message = This message was detected as possible malware ($malware_name).
>
> And Spamassassin :
>
>accept
>   condition = ${if >={$message_size}{500k}{yes}{no}}
>
>warn
>  spam = nobody:true
>  message = X-Spam_score: $spam_score\n\
>X-Spam_score_int: $spam_score_int\n\
>X-Spam_bar: $spam_bar\n\
>X-Spam_report: $spam_report
>
>deny
>   message = This message scored $spam_score spam points.
>   spam = nobody:true
>   condition = ${if >{$spam_score_int}{120}{1}{0}}
>
> I'm doing tests with viruses, and spam testing and everything works well.
> The problem is with the .forward
>
>   # Exim filter
> if error_message then
> finish
> endif
>
> if $h_X-Spam_score_int is above 50 then
>  save Maildir/.junkmail/
>
>  finish
> endif
> finish
>
> The problem is with the .forward. When I receive a local mail or mail with
> attachments, I get a *Mail Delivery System,
> *
>
> An error has been found in your .forward file.
>
>
> If someone knows the solution to this problem
>
>


-- 
Laurent Ducos
57 rue Tillet
33000 Bordeaux

06 50 02 56 03
-- 
## 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/


Re: [exim] Problem with .forward

2010-03-23 Thread laurent ducos
I think this rule is good
# Exim filter
if error_message then
finish
endif

if $h_X-Spam_score_int is exists
  then
  if $h_X-Spam_score_int is above 50 then
 save Maildir/.junkmail/
 finish
  endif
endif
finish

2010/3/23 laurent ducos 

> I think that in case the value of $h_X-Spam_score_int is undefined, the
> filter can not work.
> I did a test with this rule has proved correct
>
> # Exim filter
> if 40 is above 70
>
> then
> save Maildir/.junkmail/
> finish
> endif
>
> So if a mail came from the local area there is no value in the variable.
> It should therefore that I can write a rule saying that if the header
> exists X-Spam_score_int, then I apply the rules
>
>
> 2010/3/23 laurent ducos 
>
> Hello.
>> I'm french user of exim4 and i apologize for my bad English.
>> I configured exim4 with clamav and spamassassin on Debian.
>> Clamav :
>>
>>deny
>>  malware = *
>>  message = This message was detected as possible malware ($malware_name).
>>
>> And Spamassassin :
>>
>>accept
>>   condition = ${if >={$message_size}{500k}{yes}{no}}
>>
>>
>>warn
>>  spam = nobody:true
>>  message = X-Spam_score: $spam_score\n\
>>X-Spam_score_int: $spam_score_int\n\
>>X-Spam_bar: $spam_bar\n\
>>X-Spam_report: $spam_report
>>
>>
>>deny
>>   message = This message scored $spam_score spam points.
>>   spam = nobody:true
>>   condition = ${if >{$spam_score_int}{120}{1}{0}}
>>
>> I'm doing tests with viruses, and spam testing and everything works well.
>> The problem is with the .forward
>>
>>   # Exim filter
>> if error_message then
>> finish
>> endif
>>
>> if $h_X-Spam_score_int is above 50 then
>>  save Maildir/.junkmail/
>>
>>  finish
>> endif
>> finish
>>
>> The problem is with the .forward. When I receive a local mail or mail
>> with attachments, I get a *Mail Delivery System,
>> *
>>
>> An error has been found in your .forward file.
>>
>>
>>
>> If someone knows the solution to this problem
>>
>>
>
>
> --
> Laurent Ducos
> 57 rue Tillet
> 33000 Bordeaux
>
> 06 50 02 56 03
>



-- 
Laurent Ducos
57 rue Tillet
33000 Bordeaux

06 50 02 56 03
-- 
## 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/


Re: [exim] Exim 4.71 on netBSD pthreads

2010-03-23 Thread Phil Pennock
On 2010-03-23 at 16:42 +0100, Niels Dettenbach wrote:
> this seems not new and so i found and followed this thread: 
> http://mail-index.netbsd.org/pkgsrc-users/2009/11/18/msg011153.html
> 
> and tried to remove all parts which (i think of) pulling out pthreads out of 
> the exim build, but this brought no solution for me and btw i rely on things 
> like mysql and openssl here.

Since the last time the NetBSD incompatible changes to _res behaviour
changes came up, I've bought a new laptop and have a VM system installed
on it.  I'll set up a NetBSD VM and look into what are the minimal code
changes needed to support NetBSD without turning the source code into
spaghetti.

If you don't hear back from me within a week, ping me.

-Phil

-- 
## 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/


Re: [exim] Exim 4.71 on netBSD pthreads

2010-03-23 Thread Niels Dettenbach
Dear Phil,

i've got it running for now with some ugly hacks here (i.e. i've deleted all 
sqlite stuff and tricked with other libs) - so i'm really happy if someone 
brings exim back to "compatible" with NetBSD again as i like EXIM like NetBSD 
(it's a really nice couple...).

If you need active devel- or beta-tester(s) for your code for NetBSD - just 
contact me. In case you prefer a small NetBSD VM for testing purposes this 
would be possible too.

Many thanks in advance,

Niels.
---
Syndicat IT&Internet
http://www.syndicat.com


-- 
## 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/


Re: [exim] Rewrite to Multiple Recipients

2010-03-23 Thread Øyvind Kolbu
On 2010-03-23 at 14:15, Matthias-Christian Ott wrote:
> How would I do this? The documentation for the redirect router doesn't
> contain an example for multiple recipients.

Either you can use comma separated, or newlines between each entry. The
latter most useful for file lookups.

Below is a router which forwards all mail to foo...@example.com and
b...@example.com.

shadow_redirect:
driver = redirect
data = foo...@example.com, b...@example.com
unseen

For more info see
http://www.exim.org/exim-html-current/doc/html/spec_html/ch22.html#SECID126

-- 
Øyvind Kolbu

-- 
## 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/


Re: [exim] Exim 4.71 on netBSD pthreads

2010-03-23 Thread Scott Ellis

On 3/23/2010 8:42 AM, Niels Dettenbach wrote:
[snip]


and tried to remove all parts which (i think of) pulling out pthreads out of
the exim build, but this brought no solution for me and btw i rely on things
like mysql and openssl here.

[snip]


And this is what i get compiled with 4.71:

# ldd build-NetBSD-i386/exim
build-NetBSD-i386/exim:
 -lc.12 =>  /usr/lib/libc.so.12
 -lcrypt.0 =>  /usr/lib/libcrypt.so.0
 -lm.0 =>  /usr/lib/libm387.so.0
 -lm.0 =>  /usr/lib/libm.so.0
 -lcrypto.4 =>  /usr/lib/libcrypto.so.4
 -lssl.6 =>  /usr/lib/libssl.so.6
 -lz.1 =>  /usr/pkg/lib/libz.so.1
 -lmysqlclient.15 =>  /usr/pkg/lib/libmysqlclient.so.15
 -lpthread.0 =>  /usr/lib/libpthread.so.0
 -lcrypto.0.9.8 =>  /usr/pkg/lib/libcrypto.so.0.9.8
 -lssl.0.9.8 =>  /usr/pkg/lib/libssl.so.0.9.8
 -lresolv.1 =>  /usr/lib/libresolv.so.1
 -lsasl2.2 =>  /usr/pkg/lib/libsasl2.so.2
 -lpcre.0 =>  /usr/pkg/lib/libpcre.so.0



Wow Niels, you're pulling in a bunch of stuff I didn't bother with. :-) 
For reference, Exim-4.71 on NetBSD/amd64-current works awesomely.  My 
binary shows:


/usr/local/bin/exim:
-lcrypt.1 => /usr/lib/libcrypt.so.1
-lc.12 => /usr/lib/libc.so.12
-lm.0 => /usr/lib/libm.so.0
-lssl.8 => /usr/lib/libssl.so.8
-lcrypto.6 => /usr/lib/libcrypto.so.6

I attached the Makefile I used, in case that helps.  Note that I 
forcibly disable IPv6 support, but otherwise it's pretty a pretty boring 
configuration. :-)


ScottE


Makefile.exim_Intrepid.bz2
Description: Binary data
-- 
## 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/