I would like to get any advice for my issue to run script on /etc/aliases. At first, here are my envirements/script.
- OS : centos 6
- script : python 2.6.6
- mail : sendmail-8.14 / dovecot-2x
- python script (it's very simple for testing)
import sys
f = open("aa.txt", 'w')
for i in range(1, 5): data = "%d \n" % i f.write(data)
f.close() sys.exit()
and then I did some congiguration to use smrsh like, make link on /etc/smrsh/, move script on /etc/smrsh/...
and then modified the /etc/aliases as below:
testuser: "|/etc/smrsh/python /etc/smrsh/aa.py"
and then run newaliases
.
When I send email to testuser user, maillog shows error as below: (sorry for changing some info like IP, domain)
Mar 13 11:14:38 localhost sendmail[8153]: s2DBEcX7008153: from=<ttt@test.com>, size=4448, class=0, nrcpts=1, msgid=<B75C8C1216C9824DBF46410575577E294559AC17@test.com>, proto=ESMTP, daemon=MTA, relay=relay.test.com [xx.xxx.000.xx]
Mar 13 11:14:39 localhost sendmail[8154]: s2DBEcX7008153: to="|/etc/smrsh/python /etc/smrsh/aa.py", ctladdr=<testuser@[xx.xx.xx.xx]> (8/0), delay=00:00:01, xdelay=00:00:01, mailer=prog, pri=34652, dsn=5.3.0, stat=unknown mailer error 1
Mar 13 11:14:39 localhost sendmail[8154]: s2DBEcX7008153: s2DBEdX7008154: DSN: unknown mailer error 1
but, just forwarding email via /etc/aliases works very well like, testuser : test@zzz.com
I tried to run with smrsh on the shell :
smrsh -c "|/etc/smrsh/python /etc/smrsh/aa.py"
it also works very well.
here are my sendmail.cf for Mprog,
Mlocal, P=/usr/bin/procmail, F=lsDFMAw5:/|@qSPfhn9, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL,
T=DNS/RFC822/X-Unix,
A=procmail -t -Y -a $h -d $u
Mprog, P=/usr/sbin/smrsh, F=lsDFMoqeu9, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL, D=$z:/,
T=X-Unix/X-Unix/X-Unix,
A=smrsh -c $u
and, /etc/smrsh/
lrwxrwxrwx. 1 root root 17 Mar 13 09:01 procmail -> /usr/bin/procmail
lrwxrwxrwx. 1 root root 15 Mar 13 09:08 python -> /usr/bin/python
lrwxrwxrwx. 1 root root 15 Mar 13 09:42 smrsh -> /usr/sbin/smrsh
lrwxrwxrwx. 1 root root 17 Feb 13 09:17 vacation -> /usr/bin/vacation
-rwxr-xr-x. 1 root root 125 Mar 13 11:27 aa.py
-rw-r--r--. 1 root root 12 Mar 13 11:27 aa.txt
Could someone help to slove this problem? Many Thanks!