preload preload preload preload

Compiling SASL Packages with Postfix

Compiling SASL Packages with Postfix

The environmental variables in CCARGS for instance, provide the options that Postfix needs.

AUXLIBS – If you build support for any additional applications you may need to tell the linker where to look for the additional libraries for those programs.  The standard location for system libraries is /usr/lib.  If you want the linker to look for additional libraries you must indicate that with the -L option.

CentOS Example
AUXLIBS=’-L/usr/lib’

However, that is not enough because you must also indicate the specific library to link to with the -l option.  Library files start with lib and will have an extension of .a for static libraries, .so for a shared object or .sl for a shared library.  If the -l is used the library is referred to without the lib and without the file extension.  So if you were going to add MySQL and mysqlclient it would look like this:

CentOS Example
AUXLIBS=’-L/usr/lib/mysql -L/usr/lib -lmysqlclient -lz -lm’

CC – Postfix will use the gcc compiler, If you want to use a different one you will need to indicate that specifically.  If you look in the makedefs file you will see this text indicating the default is gcc, “${CC-gcc}”.

CCARGS – This will supply any additional arguments you want to make to the compiler.  This is used to indicate files that you need that are not in default locations.

DEBUG – This will provide debugging levels that you may want to use.  Typically you will want to increase debugging levels when you initially build Postfix for testing and then eliminate it when you build the final version for your production server.

OPT – These are optimization levels that you can set if you need your Postfix Mail Server to function at higher levels.

The compiler options can be set up in using the CCARGS.  The standard location for the header files that you need are in /usr/include.  If you need to indicate an alternative location for header files you would use the CCARGS to indicate that.  The “I” options are used for each additional directory the compiler should use.

CCARGS=’-I/usr/local/include/’

The -D option gives you a method of defining a macro to include support for a particular program you want to include.  So that you could tell Postfix to include support for the MySQL macro, HAS_MYSQL like this:

CCARGS=’DHAS_MYSQL’

If you want to change the location of directories you will need to include the Macro Name and the location where you want to place the directory.

Make makefiles CCARGS=’-DEF_CONFIG_DIR=\”a/location\”’

Parameters whose defaults can be specified in this way are:

Macro name         default value for         typical default
DEF_COMMAND_DIR     command_directory     /usr/sbin
DEF_CONFIG_DIR     config_directory         /etc/postfix
DEF_DAEMON_DIR     daemon_directory         /usr/libexec/postfix
DEF_DATA_DIR         data_directory         /var/lib/postfix
DEF_MAILQ_PATH     mailq_path             /usr/bin/mailq
DEF_HTML_DIR         html_directory         no
DEF_MANPAGE_DIR     manpage_directory         /usr/local/man
DEF_NEWALIAS_PATH     newaliases_path         /usr/bin/newaliases
DEF_QUEUE_DIR         queue_directory         /var/spool/postfix
DEF_README_DIR     readme_directory         no
DEF_SENDMAIL_PATH     sendmail_path         /usr/sbin/sendmail

Parameter Changes for the Environment
When you want to make changes to the parameters you will need to execute the build with two steps so that you can modify the Makefile.  Here is an example of some changes you could make.

make makefiles CCARGS=’-DDEF_COMMAND_DIR=\”/usr/local/sbin\” \
-DDEF_DAEMON_DIR=\”/usr/local/libexec/postfix\” \
-DDEF_MAILQ_PATH=\”/usr/local/bin/mailq\” \
-DDEF_NEWALIAS_PATH=\”/usr/local/bin/newaliases\” \
-DHAS_MYSQL -I/usr/src/mysql/include/mysql’ \
AUXLIBS=’-L/usr/src/mysql/lib/mysql -lmysqlclient’

On any server that you are compiling Postfix on, you need to take into account where the additional programs are that you want to compile with Postfix.  These directories will be in different locations depending upon the distro that you are using.

One application you may want to compile with Postifx is SASL support.  The illustration using CentOS but you can see how you would change directories for Ubuntu or Debian and it can work that way also.   Use yum to find out information on your version as you may have to make changes based on version.  Here you can see cyrus-sasl is version 2.1.22.

yum info cyrus-sasl

Name       : cyrus-sasl
Arch       : i386
Version    : 2.1.22
Release    : 4
Size       : 4.6 M
Repo       : installed
Summary    : The Cyrus SASL library.
URL        : http://asg.web.cmu.edu/sasl/sasl-library.html
License    : Freely Distributable
Description: The cyrus-sasl package contains the Cyrus implementation of SASL. SASL is the Simple Authentication and Security Layer, a method for adding
: authentication support to connection-based protocols.

The following assumes that the Cyrus SASL include files are in /usr/local/
include, and that the Cyrus SASL libraries are in /usr/local/lib.

On some systems this generates the necessary Makefile definitions:

% make tidy # if you have left-over files from a previous build
% make makefiles CCARGS=”-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
-I/usr/local/include/sasl” AUXLIBS=”-L/usr/local/lib -lsasl2″

(for Cyrus SASL version 2.1.x):

% make tidy # if you have left-over files from a previous build
% make makefiles CCARGS=”-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
-I/usr/local/include/sasl” AUXLIBS=”-L/usr/local/lib \
-R/usr/local/lib -lsasl2″

Why this won’t work.
ls /usr/include/sasl
hmac-md5.h  md5global.h  md5.h  prop.h  sasl.h  saslplug.h  saslutil.h

Modified
make makefiles CCARGS=”-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
-I/usr/include/sasl” AUXLIBS=”-L/usr/lib -lsasl2″

make upgrade

ldd `postconf -h daemon_directory`/smtpd
linux-gate.so.1 =>  (0x00bfc000)
libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0×00464000)
libdb-4.3.so => /lib/libdb-4.3.so (0×00110000)
libnsl.so.1 => /lib/libnsl.so.1 (0×00207000)
libresolv.so.2 => /lib/libresolv.so.2 (0x003fc000)
libc.so.6 => /lib/libc.so.6 (0x0021e000)
libdl.so.2 => /lib/libdl.so.2 (0x00d22000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0×00362000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00d28000)
/lib/ld-linux.so.2 (0x00bb9000)