Securing-Optimizing-RH-Linux-1_2_266
Comments and suggestions concerning this book should be mailed to gmourani@videotron.ca
© Copyright 1999-2000 Gerhard Mourani and Open Network Architecture ®
266
You will next need to populate the /etc/smrsh directory with the programs that are allowable for
Sendmail to execute. To prevent duplicate programs and make a nice job, it is better to establish
links to the allowable programs from /etc/smrsh rather than copy programs to this directory.
·
To allow the mail program /bin/mail, use the following commands:
[root@deep /]# cd /etc/smrsh
[root@deep smrsh]# ln -s /bin/mail mail
·
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
Would allow the mail and procmail programs to be run from a user's .forward file or an
aliases which uses the "program" syntax.
Step 3
We can now configure Sendmail to use the restricted shell. The program mailer is defined by a
single line in the Sendmail configuration file, /etc/sendmail.cf. You must modify this single line
Mprog definition in the sendmail.cf file, by replacing the /bin/sh specification with
/usr/sbin/smrsh.
Edit the sendmail.cf file (vi /etc/sendmail.cf) and change the line:
For example:
Mprog, P=/bin/sh, F=lsDFMoqeu9, S=10/30, R=20/40, D=$z:/, T=X-Unix, A=sh -c $u
Which should be changed to:
Mprog, P=/usr/sbin/smrsh, F=lsDFMoqeu9, S=10/30, R=20/40, D=$z:/, T=X-Unix, A=sh -c $u
·
Now re-start the sendmail process manually with the following command:
[root@deep /]# /etc/rc.d/init.d/sendmail restart
NOTE: In our sendmail.mc configuration file for the Mail Hub Server above, we are already
configured this line Mprog to use the restricted shell /usr/sbin/smrsh with the m4 macro
FEATURE(`smrsh',`/usr/sbin/smrsh'), so dont be surprised if the /usr/sbin/smrsh specification
is already set in your /etc/sendmail.cf file for the Mail Hub relay. Instead use the technique show
above for other /etc/sendmail.cf files in your network like the one for the nullclient local or
neighbor client and server machines that use the /etc/null.mc macro configuration file to
generate the /etc/sendmail.cf file.
The /etc/aliases file
Wrongly or carelessly administered aliases file can easily be used to gain privileged status. For
example, many vendors ship systems with a decode alias in the /etc/aliases file. The intention
is to provide an easy way for users to transfer binary files using mail. At the sending site the user
converts the binary to ASCII with uuencode, then mails the result to the decode alias at the
receiving site. That alias pipes the mail message through the /usr/bin/uuencode program, which
converts the ASCII back into the original binary file.
Remove the decode alias line from your /etc/aliases file. Similarly, every alias that executes a
program that you did not place there yourself and check completely should be questioned and
probably removed.
Edit the aliases file (vi /etc/aliases) and remove the following lines:
# Basic system aliases -- these MUST be present.
MAILER-DAEMON: postmaster