LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-01-2008, 04:59 AM   #1
sunnyyang
LQ Newbie
 
Registered: Mar 2008
Posts: 15

Rep: Reputation: 0
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
 
Old 04-01-2008, 05:37 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,894

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
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
 
Old 04-01-2008, 09:20 AM   #3
sunnyyang
LQ Newbie
 
Registered: Mar 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Smile 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
 
Old 04-01-2008, 09:47 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,894

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
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
 
Old 04-01-2008, 10:24 AM   #5
sunnyyang
LQ Newbie
 
Registered: Mar 2008
Posts: 15

Original Poster
Rep: Reputation: 0
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

Last edited by sunnyyang; 04-02-2008 at 12:51 AM.
 
Old 04-02-2008, 01:56 AM   #6
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,894

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
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.
 
Old 04-02-2008, 02:15 AM   #7
sunnyyang
LQ Newbie
 
Registered: Mar 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Smile 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

Last edited by sunnyyang; 04-02-2008 at 02:21 AM.
 
Old 04-02-2008, 03:32 AM   #8
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,894

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
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.
 
Old 04-02-2008, 11:00 AM   #9
sunnyyang
LQ Newbie
 
Registered: Mar 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Talking 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
 
Old 04-02-2008, 01:50 PM   #10
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,894

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
You are welcome. I'm glad you've made it.

Regards
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sendmail and NIS databases (aliases, mail.aliases) - what kind of databases? cotton213 Linux - Software 0 03-14-2006 05:57 PM
sendmail aliases guduke Linux - Software 3 03-14-2006 06:11 AM
Sendmail and /etc/aliases soren625 Linux - Networking 4 03-07-2005 09:47 AM
SENDMAIL Aliases Help echid Linux - Software 1 03-11-2004 08:06 PM
sendmail aliases sultan Linux - Networking 2 05-02-2002 03:28 AM


All times are GMT -5. The time now is 01:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration