1
0
mirror of https://github.com/meineerde/holgerjust.de.git synced 2025-10-17 17:01:01 +00:00
holgerjust.de/source/articles/2010/howto-compile-postfix-sasl-ldap-opensolaris.md.erb

96 lines
3.6 KiB
Plaintext

---
title: How to compile Postfix + SASL + LDAP on Opensolaris
author: Holger Just
date: 2010-06-14 18:44 UTC
lang: :en
tags: Technology
cover: 2010/howto-compile-postfix-sasl-ldap-opensolaris/cover.jpg
cover_license: 'Cover Image ["Mailbox"](https://flic.kr/p/vgjt7U) by [Bob M ~](https://www.flickr.com/photos/12463666@N03/), [CC BY 2.0](https://creativecommons.org/licenses/by/2.0/)'
layout: post
---
Currently, Opensolaris does [not provide](http://defect.opensolaris.org/bz/show_bug.cgi?id=6067) a Postfix package. Although there exist packages on [blastwave](http://www.blastwave.org/jir/pkgcontents.ftd?software=postfix&style=brief&state=5&arch=i386) and on [OpenCSW](http://www.opencsw.org/packages/CSWpostfix/) they are either outdated or do not play well together.
Fortunately, [Ihsan Dogan](http://ihsan.dogan.ch) did create a [script](http://ihsan.dogan.ch/postfix/) to create Postfix packages from scratch as well as some precompiled packages. Unfortunately, these packages miss SASL support. So I was in need to compile these myself.
READMORE
You will obviously need the Postfix sources and the package script:
```bash
wget http://de.postfix.org/ftpmirror/official/postfix-2.7.1.tar.gz
gunzip -c postfix-2.7.1.tar.gz | tar -xf -
wget http://ihsan.dogan.ch/postfix/downloads/makePostfixPkg.sh
chmod +x makePostfixPkg.sh
cd postfix-2.7.1
```
Since Opensolaris b130, NIS+ was removed from the system. As Postfix does not know that, it will not compile as it defines a dependency to it. However, this can be disabled by simply applying the following patch:
```diff
--- src/util/sys_defs.h 2010-06-02 01:56:57.000000000 +0200
+++ src/util/sys_defs.h 2010-06-14 22:08:35.596113543 +0200
@@ -400,7 +400,6 @@
#define DEF_DB_TYPE "dbm"
#define ALIAS_DB_MAP "dbm:/etc/mail/aliases"
#define HAS_NIS
-#define HAS_NISPLUS
#define USE_SYS_SOCKIO_H /* Solaris 2.5, changed sys/ioctl.h */
#define GETTIMEOFDAY(t) gettimeofday(t)
#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
```
Just put that patch into a file called `nisplus.patch` and patch the code:
```bash
patch -p0 < nisplus.patch
```
*(found on [estibi's Solaris blog](http://estseg.blogspot.com/2010/03/postfix-w-opensolaris-nis.html))*
Before actually compiling Postfix, we need some packages:
```bash
# First install the sunstudio compilers and some additional
# development tools
pkg install sunstudio12u1 object-file
# ...and some additional libraries and tools
pkg install libsasl pcre
```
Now we can generate the script compile and generate the SRV4 package. We will tell the compilers to include the default Cyrus SASL library for client authentication as well as the Dovecot library which I will use later to connect both servers and authenticate SMTP users.
```bash
# Clean up first and after failed attempts
make tidy
# Generate the makefile
make makefiles CCARGS='-DUSE_TLS -DHAS_LDAP \
-DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE=\"dovecot\" \
-DUSE_CYRUS_SASL -I/usr/include/sasl'
AUXLIBS="-L/usr/lib -lsasl -lssl -lcrypto -lldap"
CC=/opt/sunstudio12.1/bin/cc
# Build
make
# Create the package if the build succeeded
../makePostfixPkg.sh
```
The `makePostfixPkg.sh` script will create a Solaris package named something like `CNDpostfix-2.7.1,REV=100614-SunOS5.11-i386.pkg` inside the Postfix directory. This package can then be installed like this:
```bash
# make sure you removed the default Sendmail package first if it installed
pkg uninstall sendmail
# install the package
pkgadd -d CNDpostfix-2.7.1,REV=100614-SunOS5.11-i386.pkg CNDpostfix
# Configure the package to your needs. Then enable the service
svcadm enable svc:/network/postfix:default
```