Chapter 10. Installing network daemons

Table of Contents
Setting up SMTP
Setting up FTP
Setting up Telnet
Setting up PPP

Setting up SMTP

Creating groups and users

  • Create the groups and users needed by Sendmail by running:


groupadd -g 1 bin
groupadd -g 2 kmem
groupadd -g 3 mail
useradd -u 1 -g bin -d /bin -s /bin/sh bin

Creating directories

Outgoing mail processed by Sendmail is put in the /var/spool/mqueue directory. Incoming mail is forwarded to Procmail by Sendmail so we need to have an incoming mail directory as well which is /var/mail. We'll create these directories and give them the proper permissions:


mkdir /var/spool/mqueue
mkdir /var/mail
cd /var/spool
ln -s ../mail mail
chmod 700 /var/spool/mqueue
chmod 755 /var/mail
chgrp mail /var/mail
chmod 1777 /tmp

Installing Sendmail

  • Unpack the Sendmail archive and install it by running:


cd src
./Build
./Build install

Configuring Sendmail

Configuring Sendmail isn't as easily said as done. There are a lot of things you need to consider while configuring Sendmail and I can't take everything into account. That's why at this time we'll create a very basic and standard setup. If you want to tweak Sendmail to your own liking, go right ahead. You could always use your existing /etc/sendmail.cf (or /etc/mail/sendmail.cf) file if you need to use certain features.

  • Go to the ../cf directory

  • Create a new file cf/lfs.mc containing:


OSTYPE(LFS)
FEATURE(`local_procmail')
FEATURE(`nouucp')
define(`confDEF_USER_ID',nobody:daemon)
define(`confERROR_MODE',m)
define(`confSAFE_QUEUE')
MAILER(local)
MAILER(smtp)

  • Create an empty file ostype/LFS.m4 by running:


touch ostype/LFS.m4

  • Compile and install the lfs.mc file by running:


m4 m4/cf.m4 cf/lfs.mc > cf/lfs.cf
cp cf/lfs.cf /etc/sendmail.cf

  • Create an emtpy file /etc/aliases by running:


touch /etc/aliases

Per RFC822 it's required that every site be set up so that mail addressed to postmaster is always delivered successfully. It's up to you to either add the postmaster alias and possibly other aliases (like aliassing mail for user root to a normal user)

  • Initialize the aliases database by running:


sendmail -bi

Installing Procmail

  • Unpack the Procmail archive and install it by running:


make
make install
make install-suid

Creating the /etc/init.d/sendmail script

  • Create a new file /etc/init.d/sendmail containing:


#!/bin/sh
# Begin /etc/init.d/sendmail

check_status()
{
  if [ $? = 0 ]
  then
    echo "OK"
  else
    echo "FAILED"
  fi
}

case "$1" in
  start)
    echo -n "Starting Sendmail..."
    start-stop-daemon -S -q -o -x /usr/sbin/sendmail -- -bd
    check_status
    ;;

  stop)
    echo -n "Stopping Sendmail..."
    start-stop-daemon -K -q -o -p /var/run/sendmail.pid
    check_status
    ;;

  reload)
    echo -n "Reloading Sendmail configuration file..."
    start-stop-daemon -K -q -s 1 -p /var/run/sendmail.pid
    check_status
    ;;

  restart)
    echo -n "Stopping Sendmail..."
    start-stop-daemon -K -q -o -p /var/run/sendmail.pid
    check_status

    sleep 1

    echo -n "Starting Sendmail..."
    start-stop-daemon -S -q -o -x /usr/sbin/sendmail -- -bd
    check_status
    ;;

  *)
    echo "Usage: $0 {start|stop|reload|restart}"
    exit 1
    ;;

esac

# End /etc/init.d/sendmail

Setting up permissions and symlinks

  • Set the proper permissions by running:


cd /etc/rc2.d
ln -s ../init.d/sendmail S20sendmail
cd ../rc0.d
ln -s ../init.d/sendmail K20sendmail
cd ../rc6.d
ln -s ../init.d/sendmail K20sendmail