Compile and optimize

Securing and Optimizing Linux: RedHat Edition -A Hands on Guide
Prev | Chapter 22. Software -Server/Mail Network | Next

# 22.2. Compile and optimize

The Build script of Sendmail uses by default a site configuration file that correspond to your operating system type to get information about definitions for system installation and various compilation values. This file is located under the subdirectory named `devtools/OS` and if you're running a Linux system, it'll be named `Linux`. We'll rebuild this site configuration file to suit our Linux system installation and put it in the default `devtools/OS` sub-directory of the Sendmail source distribution since the Build script will look for the default site configuration file in this directory during compile time of Sendmail.

Move into the new Sendmail directory, edit the Linux file, vi `devtools/OS/Linux`, and remove all predefined lines then add the following lines inside the file:

             define(`confENVDEF', `-DPICKY_QF_NAME_CHECK -DXDEBUG=0')
             define(`confCC', `egcs')
             define(`confOPTIMIZE', `-O9 -funroll-loops -mcpu=pentiumpro -march=pentiumpro -fomit-frame-pointer -fno-exceptions')
             define(`confLIBS', `-lnsl')
             define(`confLDOPTS', `-s')
             define(`confMANROOT', `/usr/man/man')
             define(`confMANOWN', `root')
             define(`confMANGRP', `root')
             define(`confMANMODE', `644')
             define(`confMAN1SRC', `1')
             define(`confMAN5SRC', `5')
             define(`confMAN8SRC', `8')
             define(`confDEPEND_TYPE', `CC-M')
             define(`confNO_HELPFILE_INSTALL)
             define(`confSBINGRP', `root')
             define(`confSBINMODE', `6755')
             define(`confUBINOWN', `root')
             define(`confUBINGRP', `root')
             define(`confEBINDIR', `/usr/sbin')

This tells Linux file to set itself up for this particular configuration setup with:

define(`confENVDEF', `-DPICKY_QF_NAME_CHECK -DXDEBUG=0')

  This macro option is used primarily to specify code that should either be specially included or excluded. With `-DPICKY_QF_NAME_CHECK` defined, Sendmail will log an error if the name of the `qf` file is incorrectly formed and will rename the `qf` file into a `Qf` file. The `-DXDEBUG=0` argument disables the step of additional internal checking during compile time.

define(`confCC', `egcs')

  This macro option defines the C compiler to use for compilation of Sendmail. In our case we use the egcs C compiler for better optimization.

define(`confOPTIMIZE', `-O9 -funroll-loops -mcpu=pentiumpro -march=pentiumpro -fomit-frame-pointer -fno-exceptions')

  This macro option defines the flags passed to CC for optimization related to our specific CPU architecture.

define(`confLIBS', `-lnsl')

  This macro option defines the -l flags passed to ld.

define(`confLDOPTS', `-s')

  This macro option defines the linker options passed to ld.

define(`confMANROOT', `/usr/man/man')

  This macro option defines the location to install the Sendmail man pages.

define(`confMANOWN', `root')

  This macro option defines the owner for all Sendmail installed man pages.

define(`confMANGRP', `root')

  This macro option defines the group for all Sendmail installed man pages.

define(`confMANMODE', `644')

  This macro option defines the mode for all Sendmail installed man pages.

define(`confMAN1SRC', `1')

  This macro option defines the source for man pages installed in confMAN1.

define(`confMAN5SRC', `5')

  This macro option defines the source for man pages installed in confMAN5.

define(`confMAN8SRC', `8')

  This macro option defines the source for man pages installed in confMAN8.

define(`confDEPEND_TYPE', `CC-M')

  This macro option specifies how to build dependencies with Sendmail.

define(`confNO_HELPFILE_INSTALL')

  This macro option specifies to not install the Sendmail help file by default. Some experienced administrators recommend it, for better security.

define(`confSBINGRP', `root')

  This macro option defines the group for all Sendmail setuid binaries.

define(`confSBINMODE', `6755')

  This macro option defines the mode for all Sendmail setuid binaries.

define(`confUBINOWN', `root')

  This macro option defines the owner for Sendmail binaries.

define(`confUBINGRP', `root')

  This macro option defines the group for Sendmail binaries.

define(`confEBINDIR', `/usr/sbin')

  This macro option defines where to install binaries executed from other binaries. On Red Hat Linux the path must be set to the `/usr/sbin` directory.

Now we must compile and install Sendmail in the server:

             [root@deep ]/sendmail-8.10.1# cd sendmail
             [root@deep ]/sendmail# sh Build
             [root@deep ]/sendmail# sh Build install
             [root@deep ]/sendmail# cd ..
             [root@deep ]/sendmail-8.10.1# cd mailstats
             [root@deep ]/mailstats# sh Build install
             [root@deep ]/mailstats# cd ..
             [root@deep ]/sendmail-8.10.1# cd smrsh
             [root@deep ]/smrsh# sh Build install
             [root@deep ]/smrsh# cd ..
             [root@deep ]/sendmail-8.10.1# cd makemap
             [root@deep ]/makemap# sh Build install
             [root@deep ]/makemap# cd ..
             [root@deep ]/sendmail-8.10.1# cd praliases
             [root@deep ]/praliases# sh Build install
             [root@deep ]/praliases# cd ..
             [root@deep ]/sendmail-8.10.1# ln -fs /usr/sbin/sendmail /usr/lib/sendmail
             [root@deep ]/sendmail-8.10.1# chmod 511 /usr/sbin/smrsh
             [root@deep ]/sendmail-8.10.1# install -d -m 755 /var/spool/mqueue
             [root@deep ]/sendmail-8.10.1# chown root.mail /var/spool/mqueue
             [root@deep ]/sendmail-8.10.1# mkdir /etc/smrsh

  Required only for Mail Hub configuration
  Required only for Mail Hub configuration
  Required only for Mail Hub configuration
  Required only for Mail Hub configuration

- The sh Build command would build and make the necessary dependencies for the different binary files required by Sendmail before installation on your system.

- The sh Build install command would install sendmail, mailstats, makemap, praliases, smrsh binaries as well as the corresponding man pages on your system if compiled with this command.

- The ln -fs command would make a symbolic link of the sendmail binary to the `/usr/lib` directory. This is required, since some programs hope to find the sendmail binary in this directory `/usr/lib`.

- The install command would create the directory `mqueue` with permission 755 under `/var/spool`. A mail message can be temporarily undeliverable for a wide variety of reasons. To ensure that such messages are eventually delivered, Sendmail stores them in its queue directory until they can be delivered successfully.

- The chown command would set UID root and GID mail for the `mqueue` directory.

- The mkdir command would create the `/etc/smrsh` directory on your system. This directory is where we'll put all program mailers that we allow Sendmail to be able to run.

> : The programs makemap, and praliases must only be installed on the Central Mail Hub Server. makemap permits you to create a database map like the `/etc/mail/aliases.db` or `/etc/mail/access.db` files, for Sendmail. The praliases display the system mail aliases, the content of `/etc/mail/aliases file`. Since it is better to only have one place like our Central Mail Hub to handle and manage all the `db` files in our network, then it is not necessary to use the makemap, and praliases programs and build `db` files on your other hosts in the network.

Prev | Home | Next
Linux Sendmail Server | Up | Configurations