Next Previous Contents

10. Installing Network Daemons

10.1 Setting up SMTP

Creating groups and user

Create the groups 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 directory

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
mkdir /var/mail
cd /var/spool; ln -s ../mail mail
chmod 700 /var/spool/mqueue
chmod 775 /var/mail
chgrp mail /var/mail
chmod 1777 /tmp
 

Installing Sendmail

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, but this is not the right article. You could always use your existing /etc/sendmail.cf (or /etc/mail/sendmail.cf) file if you need to use certain features.

OSTYPE(LFS)
FEATURE(nouucp)
define(`LOCAL_MAILER_PATH', /usr/bin/procmail)
MAILER(local)
MAILER(smtp)
 

Installing Procmail

make; make install; make install-suid
 

Creating /etc/init.d/sendmail bootscript

#!/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

cd /etc/init.d/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
 

10.2 Setting up FTP

Creating groups and users

groupadd -g 65534 nogroup
groupadd -g 4 ftp
 

useradd -u 65534 -g nogroup -d /home nobody
useradd -u 4 -g ftp -s /bin/sh -m ftp
 

Installing Proftpd

./configure
make; make install
 

Creating the /etc/init.d/proftpd bootscript

#!/bin/sh
# Begin /etc/init.d/proftpd
 
check_status()
{
  if [ $? = 0 ]
  then
    echo "OK"
  else
    echo "FAILED"
  fi
}
 
case "$1" in
  start)
    echo -n "Starting Pro FTP daemon..."
    start-stop-daemon -S -q -o -x /usr/sbin/proftpd
    check_status
    ;;
 
  stop)
    echo -n "Stopping Pro FTP daemon..."
    start-stop-daemon -K -q -o -x /usr/sbin/proftpd
    check_status
    ;;
 
  restart)
    echo -n "Stopping Pro FTP daemon..."
    start-stop-daemon -K -q -o -x /usr/sbin/proftpd
    check_status
 
    sleep 1
 
    echo -n "Starting Pro FTP daemon..."
    start-stop-daemon -S -q -o -x /usr/sbin/proftpd
    check_status
    ;;
 
  *)
    echo "Usage: $0 {start|stop|restart}"
    ;;
 
esac
 
# End /etc/init.d/proftpd
 

Setting up permissions and symlinks

cd /etc/rc2.d; ln -s ../init.d/proftpd S40proftpd
cd ../rc0.d; ln -s ../init.d/proftpd K40proftpd
cd ../rc6.d; ln -s ../init.d/proftpd K40proftpd
 

10.3 Setting up HTTP

Installing Apache

./configure
make; make install
 

Configuring Apache

There's not much that needs to be configured. The only thing we need to do is to add the /usr/apache/man path to /usr/share/misc/man.conf

Creating /etc/init.d/apache bootscript

#!/bin/sh
# Begin /etc/init.d/apache
 
case "$1" in
  start)
    echo -n "Starting Apache HTTP daemon..."
    /usr/apache/bin/apachectl start
    ;;
 
  stop)
    echo -n "Stopping Apache HTTP daemon..."
    /usr/apache/bin/apachectl stop
    ;;
 
  restart)
    echo -n "Restarting Apache HTTP daemon..."
    /usr/apache/bin/apachectl restart
    ;;
 
  force-restart)
    echo -n "Stopping Apache HTTP daemon..."
    /usr/apache/bin/apachectl stop
 
    sleep 1
 
    echo -n "Starting Apache HTTP daemon..."
    /usr/apache/bin/apachectl start
    ;;
 
  *)
    echo "Usage: $0 {start|stop|restart|force-restart}"
    ;;
 
esac
 
# End /etc/init.d/apache
 

Setting up permissions and symlinks

cd /etc/rc2.d; ln -s ../init.d/apache S50apache
cd ../rc0.d; ln -s ../init.d/apache K50apache
cd ../rc6.d; ln -s ../init.d/apache K50apache
 

10.4 Setting up Telnet

Installing telnet daemon + client

./configure
make; make install
 

Creating the /etc/inetd.conf configuration file

# Begin /etc/inetd.conf
 
telnet stream tcp nowait root /usr/sbin/in.telnetd
 
# End /etc/inetd.conf
 

Creating the /etc/init.d/inetd bootscript

#!/bin/sh
# Begin /etc/init.d/inetd
 
check_status()
{
  if [ $? = 0 ]
  then
    echo "OK"
  else
    echo "FAILED"
  fi
}
 
case "$1" in
  start)
    echo -n "Starting Internet Server daemon..."
    start-stop-daemon -S -q -o -x /usr/sbin/inetd
    check_status
    ;;
 
  stop)
    echo -n "Stopping Internet Server daemon..."
    start-stop-daemon -K -q -o -p /var/run/inetd.pid
    check_status
    ;;
 
  reload)
    echo -n "Reloading Internet Server configuration file..."
    start-stop-daemon -K -q -s 1 -p /var/run/inetd.pid
    check_status
    ;;
 
  restart)
    echo -n "Stopping Internet Server daemon..."
    start-stop-daemon -K -q -o -p /var/run/inetd.pid
    check_status
 
    sleep 1
 
    echo -n "Starting Internet Server daemon..."
    start-stop-daemon -S -q -o -x /usr/sbin/inetd
    check_status
    ;;
 
  *)
    echo "Usage: $0 {start|stop|reload|restart}"
    ;;
 
esac
 
# End /etc/init.d/inetd
 

Setting up permissions and symlinks

cd /etc/rc2.d; ln -s ../init.d/inetd S30inetd
cd ../rc0.d; ln -s ../init.d/inetd K30inetd
cd ../rc6.d; ln -s ../init.d/inetd K30 inetd
 

10.5 Setting up PPP

Configuring the Kernel

Before you can logon to the Internet, the kernel must be ppp-aware. You can accomplish this by compiling ppp-support directly into the kernel, or compiling the ppp drivers are modules which you load when you need them. Whatever you prefer, do it now by re-configuring the kernel if necessary. If your LFS kernel is already ppp-aware than you don't have to re-configure the kernel.

Creating group

Installing PPP

./configure
make; make install
 

Creating /etc/resolv.conf

# Begin /etc/resolv.conf
 
nameserver <IP address of your ISP's primary DNS server>
nameserver <IP address of your ISP's secundary DNS server>
 
# End /etc/resolv.conf
 

Creating /etc/ppp/peers/provider

# Begin /etc/ppp/peers/provider
 
noauth
connect "/usr/sbin/chat -v -f /etc/chatscripts/provider"
/dev/ttyS1
115200
defaultroute
noipdefault
 
# End /etc/ppp/peers/provider
 

Creating /etc/chatscripts/provider

# Begin /etc/chatscripts/provider
 
ABORT BUSY
ABORT "NO CARRIER"
ABORT VOICE
ABORT "NO DIALTONE"
ABORT "NO ANSWER"
"" ATZ
OK ATDT <ISP's phonenumber>
TIMEOUT 35
CONNECT ''
TIMEOUT 10
ogin: \q<username>
TIMEOUT 10
assword: \q<mysecretpassword>
 
# End /etc/chatscripts/provider
 

Note on password authentication

As you see from the sample scripts (these are the actual scripts I use when I'm not using X) above I logon to my ISP using this chatscripts in stead of authenticating via pap or chap. Though my ISP supports pap, I choose to do it this slightly different way which has it's disadvantages and advantages. In my case the advantages outweigh the disadvantages. This way I have more control over my logon procedure and I can see closer what is happening when.

For example most times when I connect I have a window running tail -f /var/log/syslog so I can keep an eye on when (with my provider it's mostly 'if') things like the username and password are sent.


Next Previous Contents