Sunday, January 23, 2011

Shell scripts in sendmail aliases

I'm trying to execute a sendmail alias script using this

# aliases for my system
addressx:        |sh /usr/share/scripts/myscript.sh  WON'T WORK
addressx:        '/usr/share/scripts/myscript.sh'  WON'T WORK
addressx:        '|/usr/share/scripts/myscripts.sh'  WON'T WORK

Can I execute scripts or it must be a binary file ?

  • Sendmail uses a restricted shell to execute. You have to put programs that Sendmail can execute in the /etc/smrsh directory. You can find out more about this here.

    You should of course also ensure that the execute bit is set appropriately on that script, and that it is world readable (but not world writable).

    Rodrigo Asensio : worked perfectly. Shit! never saw such a complicated config file like the sendmail.cf thanks
    From Jon Lasser
  • The P= equate shows which shell is used to execute piped delivery. This is typically either /usr/bin/smrsh or /bin/sh. You should use whichever one meets your needs. /bin/sh is less persnickety but is less secure. /usr/bin/smrsh is more secure but has rules.

    You don't need to do something like |sh myscript.sh, the shell is identified in the sendmail configuration.

    You can execute scripts as well as binary files, BTW.

    From David M

0 comments:

Post a Comment