Installing qmail: Quick-Start Instructions

 < Free Open Study > 



Now, for the sake of the impatient and the experienced, this section provides a condensed version of the complete installation process. It can also be used as a checklist while you're following the detailed instructions. If you're new to installing qmail, you should skip to the "Installing qmail Step by Step" section for detailed directions.

  1. Verify that your system meets these requirements:

    • 10 megabytes of free space in the build area

    • A few megabytes for the binaries, documentation, and configuration files

    • Sufficient disk space for the queue on an appropriate local file system

    • Unix or a Unix-like operating system

    • Access to a Domain Name System (DNS) resolver

    • Adequate network connectivity

    • A complete development environment including a C compiler, linker, header files, make or gmake, libraries, and so on

    • The gunzip utility from the gzip package (http://www.gnu.org/directory/gzip.html)

  1. Verify the build environment.

At a command-line prompt, type cc and press the Enter key:

 $ cc cc: No input files specified $ 

If you get a similar response, you have a C compiler in your path and you can go to step 3.

If you get an error like this:

 $ cc sh: cc: command not found $ 

It doesn't necessarily mean you don't have one installed. You might, but maybe it isn't in your path. Of course, it could also mean that you don't have one. Try using these:

  • /usr/bin/cc

  • /usr/bin/gcc

  • /usr/local/bin/cc

  • /usr/local/bin/gcc

  • /usr/ccs/bin/cc

  1. Locate the source.

You'll need the source tarballs for qmail, ucspi-tcp and daemontools:

  • qmail (ftp://cr.yp.to/software/qmail-1.03.tar.gz)

  • ucspi-tcp (ftp://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz)

  • daemontools (ftp://cr.yp.to/daemontools/daemontools-0.70.tar.gz)

Retrieve these files using your Web browser or FTP client.

  1. Unpack the distribution.

At this time you probably want to become the superuser, if you are not already:

 $ su - Password: rootpassword (doesn't echo) # 

Copy or move the tarballs to the directory in which you want to do the build.

 # mkdir -p /usr/local/src # mv *.tar.gz /usr/local/src # 

Unpack the tarballs:

 # umask 022 # cd /usr/local/src # gunzip qmail-1.03.tar.gz # tar xf qmail-1.03.tar # gunzip ucspi-tcp-0.88.tar.gz # tar xf ucspi-tcp-0.88.tar # gunzip daemontools-0.70.tar.gz # tar xf daemontools-0.70.tar # rm *.tar             # optional, unless space is very tight 

Change to the qmail-1.03 directory:

 # cd qmail-1.03 # 

  1. Create the master directory.

Because qmail's installation program creates the subdirectories as they're needed, you only need to create the master qmail directory:

 # mkdir /var/qmail # 

  1. Create users and groups.

Many versions of Unix provide utilities like adduser, useradd, or mkuser that make this easy. Alternatively, you can manually edit the password and group files and add them yourself.

Linux/Solaris

 groupadd nofiles useradd -g nofiles -d /var/qmail/alias alias -s /nonexistent useradd -g nofiles -d /var/qmail qmaild -s /nonexistent useradd -g nofiles -d /var/qmail qmaill -s /nonexistent useradd -g nofiles -d /var/qmail qmailp -s /nonexistent groupadd qmail useradd -g qmail -d /var/qmail qmailq -s /nonexistent useradd -g qmail -d /var/qmail qmailr -s /nonexistent useradd -g qmail -d /var/qmail qmails -s /nonexistent 

FreeBSD

 pw groupadd nofiles pw useradd alias -g nofiles -d /var/qmail/alias -s /nonexistent pw useradd qmaild -g nofiles -d /var/qmail -s /nonexistent pw useradd qmaill -g nofiles -d /var/qmail -s /nonexistent pw useradd qmailp -g nofiles -d /var/qmail -s /nonexistent pw groupadd qmail pw useradd qmailq -g qmail -d /var/qmail -s /nonexistent pw useradd qmailr -g qmail -d /var/qmail -s /nonexistent pw useradd qmails -g qmail -d /var/qmail -s /nonexistent 

AIX

 mkgroup -A nofiles mkuser pgrp=nofiles home=/var/qmail/alias shell=/bin/true alias mkuser pgrp=nofiles home=/var/qmail shell=/bin/true qmaild mkuser pgrp=nofiles home=/var/qmail shell=/bin/true qmaill mkuser pgrp=nofiles home=/var/qmail shell=/bin/true qmailp mkgroup -A qmail mkuser pgrp=qmail home=/var/qmail shell=/bin/true qmailq mkuser pgrp=qmail home=/var/qmail shell=/bin/true qmailr mkuser pgrp=qmail home=/var/qmail shell=/bin/true qmails 

Other Operating Systems

Start by using your favorite editor and editing /etc/group. You need to add the following two lines to the end of the file:

 qmail:*:2107: nofiles:*:2108: 

Caution 

Make sure that 2107 and 2108 aren't already used. If they are, choose two group numbers not already in use.

Next, using vipw (most systems have it; if not, you'll need to use your editor again but this time on /etc/passwd), add these lines to the end of the file:

 alias:*:7790:2108::/var/qmail/alias:/bin/true qmaild:*:7791:2108::/var/qmail:/bin/true qmaill:*:7792:2108::/var/qmail:/bin/true qmailp:*:7793:2108::/var/qmail:/bin/true qmailq:*:7794:2107::/var/qmail:/bin/true qmailr:*:7795:2107::/var/qmail:/bin/true qmails:*:7796:2107::/var/qmail:/bin/true 

Caution 

Make sure 7790–7796 aren't already used and that 2107 and 2108 are the same group IDs you used previously.

  1. Install qmail.

In step 2, you located your C compiler. If it's not called cc or the directory it resides in isn't in your PATH environment variable, you'll need to edit the conf-cc and conf-ld build configuration files. Say your compiler is gcc, and it's in /opt/gnu/bin, which is not in your PATH. Simply edit conf-cc and conf-ld and replace cc with /opt/gnu/bin/gcc.

Now type the following:

 # make setup check 

Note 

If make is not found, try gmake.

The next step is to create the basic configuration files under /var/qmail/control. Executing the config script does this:

 # ./config 

If config can't find your host name in DNS—not /etc/hosts—you can instead run the config-fast script:

 # ./config-fast the.full.hostname 

For example, if your domain is example.com and the host name of your computer is dolphin, the command would be:

 # ./config-fast dolphin.example.com 

  1. Install ucspi-tcp.

Now change to the ucspi-tcp build directory:

 # cd /usr/local/src/ucspi-tcp-0.88 

In the previous section, if you modified conf-cc and conf-ld, you'll need to make the same changes in this directory.

Then build the binaries by executing

 # make 

To install the programs under /usr/local/bin, do this:

 # make setup check 

  1. Install daemontools.

Change to the daemontools build directory:

 # cd /usr/local/src/daemontools-0.70 

Once again, if you modified conf-cc and conf-ld during the qmail and ucspitcp builds, you'll need to make the same changes in this directory.

Then build the binaries by executing

 # make 

To install the programs under /usr/local/bin, do this:

 # make setup check 

Now create the /service directory:

 # mkdir /service 

Next, set up svscan to run on the /service directory each time the system is booted. If your system has an /etc/inittab (Linux or a System V, Release 4 derivative), add the following single line (with no line breaks) to the end of the file:

 SV:123456:respawn:env - PATH=/usr/local/bin:/usr/sbin: /usr/bin: /bin svscan /service </dev/null >/dev/console 2>/dev/console 

Then tell init to reread /etc/inittab by doing this:

 # kill -HUP 1 

On Berkeley Software Distribution (BSD)-based systems that don't have an /etc/inittab, put the following in /etc/rc.local, creating it, if necessary, and reboot the system:

 env - PATH=/usr/local/bin:/usr/sbin:/usr/bin:/bin csh -cf 'svscan /service &' 

Use ps to verify that svscan is running:

 # ps -ef | grep svscan 

or

 # ps -waux | grep svscan 

Finally, run a few tests to make sure the tools work right. First, run the automatic tests script:

 # cd /usr/local/src/daemontools-0.70 # ./rts > rts.out # cmp rts.out rts.exp # 

If all the tests succeeded, the cmp command will generate no output. However, some System V Release 4 derivatives will fail one of the lock tests. This is normal. Now we'll check some of the timestamp tools:

 # date | ./tai64n | ./tai64nlocal 2001-03-16 21:46:17.890891500 Fri Mar 16 21:46:17 EST 2001 # date | sh -c './multilog t e 2>&1' | ./tai64nlocal 2001-03-16 21:46:18.063667500 Fri Mar 16 21:46:18 EST 2001 # 

The date and time at the beginning of each line should be within a second of the date and time at the end of the line.

  1. Set up the qmail boot script.

Use your editor to create the following /var/qmail/rc:

 #!/bin/sh # Using stdout for logging # Using control/defaultdelivery from qmail-local to deliver messages by default exec env - PATH="/var/qmail/bin:$PATH" \ qmail-start "'cat /var/qmail/control/defaultdelivery'" 

Caution 

Note that this script uses back quotes ('), which look a little like single quotes (').

Execute this command:

 # chmod 755 /var/qmail/rc 

See the "Choosing a Mailbox Format and Location" section for information about selecting a default delivery method. Put the desired delivery instructions into /var/qmail/control/defaultdelivery. For example, to select the standard qmail Mailbox delivery, do this:

 # echo ./Mailbox > /var/qmail/control/defaultdelivery 

  1. Install qmailctl script.

Create the qmailctl script listed in the "System Startup Files" section of the detailed installation later in the chapter using your editor or by downloading it from the book Web site. Install it into the /var/qmail/bin directory with the name qmailctl.

Make the script executable and link it to a directory in your PATH:

 # chmod 755 /var/qmail/bin/qmailctl # ln -s /var/qmail/bin/qmailctl /usr/local/sbin 

  1. Update BSD-style rc.local.

On BSD-based systems, add the following to /etc/rc.local:

 if [ -x /var/qmail/bin/qmailctl ]; then   /var/qmail/bin/qmailctl start fi 

  1. Populate System V-style init.d.

On System V-based systems, symbolically link the qmailctl script to the appropriate startup directories. First is the init.d directory, which should be in one of the following locations:

  • /etc/init.d

  • /sbin/init.d

  • /etc/rc.d/init.d

You'll also need to link the script into a couple of rc directories. These directories are named like rcN.d, where N is the system runlevel to which they apply. There are many variations in the startup directory tree for different operating systems, so if you can't find the rc directories, consult your system documentation. They will probably be in one of these:

  • /etc

  • /sbin

  • /etc/rc.d

To create the links, execute the following commands, replacing INITDIR and RCDIR with the location of your system's init.d and rc directories:

 # ln -s /var/qmail/bin/qmailctl INITDIR/qmail # ln -s ../init.d/qmail RCDIR/rc0.d/K30qmail # ln -s ../init.d/qmail RCDIR/rc1.d/K30qmail # ln -s ../init.d/qmail RCDIR/rc2.d/S80qmail # ln -s ../init.d/qmail RCDIR/rc3.d/S80qmail # ln -s ../init.d/qmail RCDIR/rc4.d/S80qmail # ln -s ../init.d/qmail RCDIR/rc5.d/S80qmail # ln -s ../init.d/qmail RCDIR/rc6.d/K30qmail 

Note 

The numbers in the previous step are highly system dependent, but somewhat flexible. If Sendmail is currently installed, running the command find RCDIR -name "*sendmail" -print will give you numbers that should work for your system.

  1. Set up the qmail services.

First, create the supervise directories for the qmail services:

 # mkdir -p /var/qmail/supervise/qmail-send/log # mkdir -p /var/qmail/supervise/qmail-smtpd/log # chmod +t /var/qmail/supervise/qmail-send # chmod +t /var/qmail/supervise/qmail-smtpd 

Using your editor, create the /var/qmail/supervise/qmail-send/run file:

 #!/bin/sh exec /var/qmail/rc 

Now create the var/qmail/supervise/qmail-send/log/run file:

 #!/bin/sh exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail 

Now create the /var/qmail/supervise/qmail-smtpd/run file:

 #!/bin/sh # next three lines have backquotes ('), not single quotes (') QMAILDUID='id -u qmaild' NOFILESGID='id -g qmaild' MAXSMTPD='head -1 /var/qmail/control/concurrencyincoming' exec /usr/local/bin/softlimit -m 2000000 \     /usr/local/bin/tcpserver -v -p -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \         -u "$QMAILDUID" -g "$NOFILESGID" 0 25 /var/qmail/bin/qmail-smtpd 2>&1 

Note 

If you're using Solaris, the normal id program won't work correctly in this script. Instead of id, use /usr/xpg4/bin/id; for example, use QMAILDUID='/usr/xpg4/bin/id -u qmaild' and NOFILESGID='/usr/xpg4/bin/id -g qmaild'

Create the concurrencyincoming control file:

 # echo 20 > /var/qmail/control/concurrencyincoming # chmod 644 /var/qmail/control/concurrencyincoming 

Create the /var/qmail/supervise/qmail-smtpd/log/run file:

 #!/bin/sh exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog \   t var/log/qmail/smtpd 

Make the run files executable:

 # chmod 755 /var/qmail/supervise/qmail-send/run # chmod 755 /var/qmail/supervise/qmail-send/log/run # chmod 755 /var/qmail/supervise/qmail-smtpd/run # chmod 755 /var/qmail/supervise/qmail-smtpd/log/run 

Set up the logging directories:

 # mkdir -p /var/log/qmail/smtpd # chown -R qmaill /var/log/qmail 

Link the services into /service:

 # ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service 

Note 

qmail will start automatically shortly after you create these links. If you don't want a partially configured mail system running, do qmailctl stop now.

  1. Set up SMTP access control.

Because qmail-smtpd assumes that all connections are from remote systems—even those from the local host, we'll specifically allow the local host to relay:

 # echo '127.:allow,RELAYCLIENT=""' > /etc/tcp.smtp # qmailctl cdb 

Note 

RELAYCLIENT should be set to the empty string—with nothing between the double quotes.

  1. Create system aliases.

Create aliases for root, postmaster, and mailer-daemon. To do this, decide where you want each of them to go (probably either your local account or a remote address) and create and populate the appropriate .qmail files. For example, say local user erica is the mail administrator and jessica@blossom.example.net is the system administrator:

 # echo \&jessica@blossom.example.net > /var/qmail/alias/.qmail-root # echo \&erica > /var/qmail/alias/.qmail-postmaster # ln -s .qmail-postmaster /var/qmail/alias/.qmail-mailer-daemon # chmod 644 /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-postmaster 

  1. Stop and disable the installed mailer.

If your existing MTA is Sendmail, and you're using a System V variant, you should be able to stop it by running its init.d script with the stop argument. For example, one of these should work:

  • /etc/init.d/sendmail stop

  • /sbin/init.d/sendmail stop

  • /etc/rc.d/init.d/sendmail stop

If you can't find an init.d/sendmail script, or you're using a BSD variant, you can locate Sendmail's process ID (PID) using ps -ef | grep sendmail or ps waux | grep sendmail and stop it using:

 # kill process-ID-of-sendmail 

where process-ID-of-sendmail is the PID of sendmail as displayed by the ps command.

If your MTA isn't Sendmail, check your documentation for the correct shutdown procedure.

You should also consider removing the old MTA completely from the system. At least disable the init.d script or comment the startup command out of /etc/rc.local so it won't be restarted again when the system is rebooted.

For Red Hat Linux, for example, you can remove Sendmail by doing this:

 # rpm -e --nodeps sendmail 

Install qmail's sendmail interface for Sendmail compatibility:

 # mv /usr/lib/sendmail /usr/lib/sendmail.old                # ignore errors # mv /usr/sbin/sendmail /usr/sbin/sendmail.old              # ignore errors # chmod 0 /usr/lib/sendmail.old /usr/sbin/sendmail.old      # ignore errors # ln -s /var/qmail/bin/sendmail /usr/lib # ln -s /var/qmail/bin/sendmail /usr/sbin 

  1. Start qmail.

If you stopped qmail after creating the links in /service, you should restart it now:

 # qmailctl start 

If anything goes wrong, you can always do this:

 # qmailctl stop 

which will stop all of the qmail services.

Tip 

The inst_check script located at the official book Website (http://www.apress.com) can be used to help ensure that the installation is correct before starting qmail the first time.

  1. Test the installation.

Send test messages to and from various combinations of valid and invalid local and remote users using local injection tools and SMTP. See the detailed instructions in the "Testing the Installation" section for more information about how to conduct these tests:

  • Local user to local user

  • Local user to nonexistent local address

  • Local user to valid remote address

  • Local user to local postmaster

  • Invalid local user to invalid local user

  • Group membership test

  • SMTP server test

  • Remote user to local user

  • Remote user to invalid local user

  • Mail user agent (MUA) test

  • Remote to postmaster



 < Free Open Study > 



The Qmail Handbook
The qmail Handbook
ISBN: 1893115402
EAN: 2147483647
Year: 2001
Pages: 186
Authors: Dave Sill

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net