smrshの設定

mail経由でコマンドを実行する際に、smrshで制限を掛ける。
このため、従来smrshの無い環境から移行すると、smrshがチェックを行い、実行できない。

このための解決方法として、perlphpを実行可能にする方法が提示されていたりするが、これは危険な方法である。

smrshのマニュアルにも

Note that this does not restrict the use of
shell or perl scripts in the sm.bin directory (using the ‘‘#!’’ syn-
tax); it simply disallows execution of arbitrary programs.

とある。

smrshは、メール経由で実行されると、mailのユーザになる。
そこで、実際には、下記の様に設定する。

前提条件
ユーザ foo
group bar
実行したいスクリプト
/home/foo/dothis

dothisまでのパスをmailがアクセスできる様にする。
dothisを/etc/smrshに追加する

ln -s /home/foo/dothis /etc/smrsh
usermod -G bar mail
chmod g+rwx /home/foo
chmod g+rx /home/foo/dothis

確認は、root で

sudo -u mail /usr/sbin/smrsh -c /home/foo/dothis