LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sendmail Aliases (http://www.linuxquestions.org/questions/linux-newbie-8/sendmail-aliases-632115/)

sunnyyang 04-01-2008 05:59 AM

Sendmail Aliases
 
Hi,

I am configuring Sendmail Aliases to let system run a script after receiving a mail.

But it seems not working, message re-direction is ok, here is the details:

root: another-user --- working
root: |/script --- not working

Anybody wants to help me? thank you. :)


Yang

bathory 04-01-2008 06:37 AM

Try
Code:

root: "|/script"
i.e. use the quotation marks around the full path to the script you want to run and see if it works.
After editing /etc/mail/aliases, run "newaliases" and restart sendmail.

Regards

sunnyyang 04-01-2008 10:20 AM

Thank you.
 
Thank you Bathory.

I tried this, still not working.

Here is a part of my aliases file.
-------------------------------------------
# Person who should get root's mail
#root: marc
root: yangg
yangg: "|/tmp/run.sh:"
-------------------------------------------

Messages sent to root can be forwarded to yangg, but if you address yangg nothing happens, yangg cannot receive this message either.

script run.sh is very simple: touch /tmp/aliases.tst, that's it.

I really don't have idea.

If you need to view my sendmail.mc file, please let me know..

Thank you in advance.


Yang

bathory 04-01-2008 10:47 AM

Edit aliases and in the line:
Quote:

yangg: "|/tmp/run.sh:"
remove the colon ":" at the end of the script name. The line should look like this:
Code:

yangg: "|/tmp/run.sh"
Also make sure that the script is executable:
Code:

chmod +x /tmp/run.sh
Regards

sunnyyang 04-01-2008 11:24 AM

Hi Bathory,


Excution permission has been granted to the script run.sh and the colon is also removed.

After that, I run newaliases, restart sendmail sucessfully. But ... no good.

Anything should I do with sendmail.mc or sendmail.cf?


Yang

bathory 04-02-2008 02:56 AM

Take a look at the log files /var/log/maillog, /var/log/messages or whatever other log files your distro uses to see if you find any clues why the aliases is not working.
What distro are you using btw?
I don't think you have to do anything with sendmail.mc or sendmail.cf, since normal usernames aliases work.

sunnyyang 04-02-2008 03:15 AM

Log analysis
 
Sendmail Log
------------------
1. Apr 2 15:06:03 ts3 sendmail[5687]: alias database /etc/aliases rebuilt by root
2. Apr 2 15:06:03 ts3 sendmail[5687]: /etc/aliases: 65 aliases, longest 14 bytes, 655 bytes total
3. Apr 2 15:06:14 ts3 sendmail[5707]: alias database /etc/aliases rebuilt by root
4. Apr 2 15:06:14 ts3 sendmail[5707]: /etc/aliases: 65 aliases, longest 14 bytes, 655 bytes total
5. Apr 2 15:06:14 ts3 sendmail[5719]: starting daemon (8.12.8): SMTP+queueing@01:00:00
6. Apr 2 15:06:14 ts3 sm-msp-queue[5728]: starting daemon (8.12.8): queueing@01:00:00
7. Apr 2 15:07:00 ts3 sendmail[5733]: m32770ow005733: from=root, size=78, class=0, nrcpts=1,
8. msgid=<200804020707.m32770ow005733@ts3.tp.edu.sg>, relay=root@localhost
9. Apr 2 15:07:00 ts3 sendmail[5735]: m32770Da005735: from=<root@ts3.tp.edu.sg>, size=351, class=0, nrcpts=1, msgid=<200804020707.m32770ow005733@ts3.tp.edu.sg>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
10. Apr 2 15:07:00 ts3 sendmail[5733]: m32770ow005733: to=yangg, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30068, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (m32770Da005735 Message accepted for delivery)
11. Apr 2 15:07:00 ts3 smrsh: uid 8: attempt to use "run.sh" (stat failed)
12. Apr 2 15:07:00 ts3 sendmail[5736]: m32770Da005735: to="|/tmp/run.sh", ctladdr=<yangg@ts3.tp.edu.sg> (8/0), delay=00:00:00, xdelay=00:00:00, mailer=prog, pri=30564, dsn=5.0.0, stat=Service unavailable
13. Apr 2 15:07:00 ts3 sendmail[5736]: m32770Da005735: m32770Da005736: DSN: Service unavailable
14. Apr 2 15:07:00 ts3 sendmail[5736]: m32770Da005736: to=user1\t\t, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31588, dsn=2.0.0, stat=Sent
--------------------

Yes, normal aliases works. The Aliases seemed to be triggered, but failed in running the script. It looks like that statement "|/tmp/run.sh" was treated as an address instead of a command.

For our convinience to talk, I hereby numbered the log.

What is "Distro"? Basically, besides access file and aliases it's all default in Redhat9.

yang

bathory 04-02-2008 04:32 AM

Distro is the Linux distribution you use, so you've answered it's RH 9. Anyway looking at the logs smrsh looked suspicious, so doing a little googling, I found this.
So I guess you need either to create the symlink mentioned there, or disable smrsh, in that case you need to rebuild your sendmail.cf.

sunnyyang 04-02-2008 12:00 PM

Done!!
 
Hi Bathory,

It's done!

I created a link under /etc/smrsh pointing to my script according to the following information:
-----------------------------------------------------------------
To allow the procmail program /usr/bin/procmail, use the following commands:
[root@deep] /# cd /etc/smrsh
[root@deep ]/smrsh# ln -s /usr/bin/procmail procmail

This will allow the mail and procmail programs to be run from a user's .forward file or an aliases file which uses the program syntax.
-----------------------------------------------------------------
This information is from
http://www.faqs.org/docs/securing/chap22sec182.html

But I got to switch to this link exactly from the webpage you passed to me. You have been always on the right direction, expert!!

Thank you.

I pasted all these meant to share with other people may need this.

Thank you all.

Case closed.

Thank you again Bathory!! I hope I can help people like how I was helped.

Yang

bathory 04-02-2008 02:50 PM

You are welcome. I'm glad you've made it.

Regards


All times are GMT -5. The time now is 12:39 PM.