Полезная информация

TCP/IP Network Administration

TCP/IP Network AdministrationSearch this book
Previous: D.3 The dhcpd.conf Configuration FileAppendix ENext: E.2 The sendmail Command
 

E. A sendmail Reference

Contents:
Compiling sendmail
The sendmail Command
m4 sendmail Macros
More sendmail.cf
Sample Configurations

This appendix provides details of the syntax of the sendmail command, of the sendmail.cf file, and of the m4 macros that can be used to build that file. It also contains excerpts of the sample sendmail.cf file described in Chapter 10, sendmail . It describes where to obtain the latest source code for sendmail and how to compile it. This appendix is a reference, not a tutorial. Refer to Chapter 10 for a tutorial on sendmail configuration.

We start the appendix with information on locating, downloading, and compiling the latest version of sendmail.

E.1 Compiling sendmail

The source code for sendmail is available via anonymous ftp from ftp.sendmail.org, where it is stored in the pub/sendmail directory. When you change to that directory, an information message tells you about the latest version of sendmail. sendmail is updated constantly. The following examples are based on sendmail V8.8.5. Remember that things will change for future releases. Always read the README files and installation documents that come with new software before beginning an installation.

Download the compressed sendmail tar file as a binary file. Uncompress and untar it. Change to the src directory in the sendmail directory created by the tar file and enter:

sh makesendmail

According to the documentation, this is all you need to do on most systems. This certainly works on BSD 4.4-based systems. However, it does not work on every system. The two systems used for examples in this book, Solaris 2.5.1 and Slackware 96 Linux, both have problems. The problem with Solaris is that it does not have a C compiler. Before even attempting to install sendmail you must download and install the GNU C compiler, gcc. The problem with Slackware is more subtle. Different versions of Linux place files in different locations in the filesystem. Let's look at the details of installing sendmail V8.8.5 on a Slackware 96 system.

First we download the tar file and put the sendmail source files into the /usr/src directory where Slackware 96 keeps various source files:

# ftp ftp.sendmail.org
Connected to kohler.CS.Berkeley.EDU.
220 kohler.CS.Berkeley.EDU FTP server ready.
Name (ftp.cs.berkeley.edu:craig): anonymous
331 Guest login ok, send your complete email address as password.
Password: craig@nuts.com
230 Guest login ok, access restrictions apply.
ftp> cd pub/sendmail
250 CWD command successful.
ftp> binary
200 Type set to I.
ftp> get sendmail.8.8.5.tar.gz
200 PORT command successful.
150 Opening BINARY mode data connection.
226 Transfer complete.
992815 bytes received in 187 secs (5.2 Kbytes/sec)
ftp> quit
221 Goodbye.
# gunzip sendmail.8.8.5.tar.gz
# cp sendmail.8.8.5.tar /usr/src
# cd /usr/src
# tar -xvf sendmail.8.8.5.tar

Next we run makesendmail.

# cd sendmail-8.8.5/src
# ./makesendmail
Configuration: os=Linux, rel=2.0.0, rbase=2, rroot=2.0, arch=i586, sfx=
Creating obj.Linux.2.0.0.i586 using Makefile.Linux
Making dependencies in obj.Linux.2.0.0.i586
make: Nothing to be done for `depend'.
Making in obj.Linux.2.0.0.i586
cc -I. -O -I/usr/local/include -DNDBM -DNEWDB    -c alias.c -o alias.o
.
.
.
cc -I. -O -I/usr/local/include -DNDBM -DNEWDB -c map.c -o map.o map.c:42: ndbm.h: No such file or directory make: * [map.o] Error 1

makesendmail recognizes this is a Linux system, but the Makefile it selects is obviously not correct for the Slackware 96 variant of Linux. All of the Makefiles that makesendmail uses are located in the src/Makefiles subdirectory. Two of those files, Makefile.Linux and Makefile.Linux.ppc, are designed for Linux. The Makefile.Linux.ppc is a possible solution to our problem. Move it to Makefile.Linux and rerun makesendmail:

# cd Makefiles
# mv Makefile.Linux Makefile.Linux.orig
# cp Makefile.Linux.ppc Makefile.Linux
# cd ..
# touch *
# ./makesendmail
Configuration: os=Linux, rel=2.0.0, rbase=2, rroot=2.0, arch=i586, sfx=
Making in obj.Linux.2.0.0.i586
cc -I. -O -I/usr/local/include -DNEWDB    -c alias.c -o alias.o
cc -I. -O -I/usr/local/include -DNEWDB    -c version.c -o version.o
cc -o sendmail alias.o ... version.o  -L/usr/local/lib -ldb
groff -Tascii -mandoc aliases.5 > aliases.0
groff -Tascii -mandoc sendmail.8 > sendmail.0

That's more like it! sendmail compiled and linked without problems.

A quick look at the differences in the two Makefiles shows that only four lines have been changed. Of those four lines, only two, DBMDEF and LIBS, were actually needed to successfully compile sendmail. Possible values for the database definition (DBMDEF) are shown in Table 13.4

Table E.1: DBMDEF Database Arguments
ArgumentFunction
NDBMThe dbm format from BSD 4.3 accessed with ndbm(3).
NEWDBThe new BSD 4.4 database format accessed with db(3).
NISSun NIS.
NISPLUSSun NIS+.
NETINFONeXT's NetInfo.
HESIODMIT's Hesiod server.
LDAPMAPX500 LDAP lookups.

The error displayed by the first ./makesendmail run stated that ndbm.h was not found. This indicates that the NDBM argument on the DBMDEF line is the likely culprit. Further, the comments in the Makefile.Linux file recommend using DNEWDB and the ldb library. This suggests that a possible solution is to change DBMDEF to DBMDEF= -DNEWDB and LIBS to LIBS= -ldb. This is exactly what Paul DuBois did when he created the Makefile.Linux.ppc file, and it is what allows sendmail to compile on a Slackware 96 system.

He also changed two other lines, neither of which is critical to the compile, but both of which are indicative of the type of things customized in a Makefile. Paul changed the STDIR variable that defines where the sendmail.st file is stored to STDIR= ${DESTDIR}/var/log. The location of files is the most commonly modified information in a makefile. He also changed BINGRP to BINGRP= mail to use the mail group defined by the Slackware 96 system as the group ID for the sendmail binary files.

Once sendmail compiles, it is installed with the following command:

# ./makesendmail install

One other thing that should be checked before declaring the installation complete is the makemap command. This is the command that builds the databases read by sendmail. Given the fact that sendmail encountered trouble while compiling certain types of database support, we are suspicious that compiling makemap will have similar problems.

First change to the sendmail-8.8.5/makemap directory and look at the two makefiles located there. One of them, Makefile.dist, is the type of makefile supported by Slackware Linux. Copy Makefile.dist to Makefile and attempt a compile of makemap:

# cd ../makemap
# mv Makefile Makefile.orig
# cp Makefile.dist Makefile  
# make
cc -I. -O -I../src -I/usr/sww/include -DNDBM -DNEWDB    -c makemap.c
   -o makemap.o
makemap.c:53: ndbm.h: No such file or directory
make: *** [makemap.o] Error 1

Just as we suspected! makemap has the same compile problem as sendmail. Luckily, Paul DuBois's solution to the sendmail problem shows us the changes needed for the DBMDEF and LIBS variables. Additionally, we check all of the directory paths in the Makefile to ensure they are valid for a Slackware 96 system:

# grep -v '^#' Makefile | grep '/'
SRCDIR= ../src
INCDIRS=-I${SRCDIR} -I/usr/sww/include
LIBDIRS=-L/usr/sww/lib
BINDIR= ${DESTDIR}/usr/sbin
LINKS=  ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq
${OBJS}: ${SRCDIR}/conf.h
# ls /usr/sww
ls: /usr/sww: No such file or directory
# ls /usr/ucb
ls: /usr/ucb: No such file or directory
# whereis makemap
makemap: /usr/sbin/makemap
# whereis newaliases
newaliases: /usr/bin/newaliases
# whereis mailq
mailq: /usr/bin/mailq

These tests show that, in addition to Paul DuBois's corrections, we need to remove references to the non-existent /usr/sww and /usr/ucb directories and insert references to /usr/bin where mailq and newaliases really reside. After we make these changes, a diff shows the new Makefile code and a rerun of make shows that we have fixed the problem:

# diff Makefile.dist Makefile
22c22
< DBMDEF=       -DNDBM -DNEWDB
---
> DBMDEF=       -DNEWDB
30c30
< INCDIRS=-I${SRCDIR} -I/usr/sww/include
---
> INCDIRS=-I${SRCDIR}
36c36
< LIBDIRS=-L/usr/sww/lib
---
> LIBDIRS=
39c39
< LIBS= -ldb -ldbm
---
> LIBS= -ldb
53c53
< LINKS=        ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq
---
> LINKS=        ${DESTDIR}/usr/bin/newaliases ${DESTDIR}/usr/bin/mailq
# make
cc -I. -O -I../src -DNEWDB    -c makemap.c -o makemap.o
cc -o makemap  makemap.o   -ldb

Run make install to install the new version of makemap. We're finished. Compiling sendmail wasn't as easy as the documentation implies, but wasn't impossible.

sendmail is now ready to run. The next section describes the syntax of the sendmail command.


Previous: D.3 The dhcpd.conf Configuration FileTCP/IP Network AdministrationNext: E.2 The sendmail Command
D.3 The dhcpd.conf Configuration FileBook IndexE.2 The sendmail Command