Osez installer Qmail
mis à jour le 27/04/2007
 ©  Christian Caleca   

Qmail & co.

Accueil ] Daemontools et ucspi-tcp ] [ Qmail & co. ] Vpopmail ] Essais divers ] courier-imap ] POP3 ] outils admin ] Ezmlm-idx ] qmailadmin ] Filtrage des mails ] Livraison locale ] Conclusions ]


Conditions d'expérimentation

Tout ce qui suit est essentiellement testé sur une Debian "testing" (lenny). Comme j'ai fait de multiples tests sur des machines différentes, il pourra se faire que dans le texte, apparaissent certaines incohérences concernant le nom des machines, ou quelques divergences mineures dans les copies d'écran, qui m'auront échappées. Je vous prie par avance de bien vouloir m'en excuser.

"La" machine de référence finale s'appelle "janus" et appartient à un domaine "fictif" : maison.mrs

Premier problème

De très nombreux paquetages Debian font référence à un MTA. Comme il n'y en aura plus dans l'arbre des dépendances des paquetages (installation par les sources oblige), cela va causer pas mal de troubles. Aussi devons-nous d'abord nous arranger pour que l'arbre des dépendances sache qu'il y a tout de même un MTA d'installé.

Nous partons ici d'une installation tout à fait minimale, sans serveur http, sans base de données, sans FTP, juste avec Exim, puisqu'il est installé par défaut. Le paquetage "equivs" va nous venir en aide.

apt-get install equivs
cd /tmp
cp /usr/share/doc/equivs/examples/mail-transport-agent.ctl .
equivs-build mail-transport-agent.ctl

Ceci permet de créer un "faux paquetage" :  mta-local_1.0_all.deb

Si vous avez un exim installé :

dpkg --ignore-depends=exim4 -r exim4
dpkg --ignore-depends=exim4-daemon-light -r exim4-daemon-light

Ces deux lignes permettent de supprimer Exim sans enlever tous les éventuels paquetages dépendants.

 dpkg -i /tmp/mta-local_1.0_all.deb

Cette dernière ligne permet de placer notre faux paquetage qui fera croire au système de dépendances d'apt qu'un MTA est toujours présent. Ainsi, le reste de la distribution ne sera plus perturbé par le manque d'un paquetage de MTA de la distribution, et les commandes apt fonctionneront normalement.

Qmail

On "patche" ou pas ?

L'objectif est de réaliser un système de messagerie complet avec la gestion :

De plus, nous désirons que les clients puissent :

Qmail/vpopmail/ezmlm dans leur forme initiale ne suffisent pas pour réaliser toutes ces opérations. Il nous faut donc patcher...

Un Qmail "amélioré"

Fort heureusement, il existe des ressources qui vont nous permettre de réaliser assez simplement la préparation de Qmail et son installation, mais aussi Vpopmail, pour la gestion des domaines virtuels, ezmlm, pour la gestion des listes de diffusions, et quelques autres accessoires que nous découvrirons en temps opportun.

Il existe plusieurs façons "d'améliorer" le qmail original, de manière à lui apporter les fonctionnalités qui lui manquent, principalement dans la lutte anti spam et anti virus.

Netqmail 1.05

Netqmail 1.05 se présente sous la forme d'une archive qui contient :

Qmail-toaster-0.9.0.patch

Il s'agit d'un "patch" cumulatif qui permet, entre autres, d'utiliser TLS/SSL non seulement entre les clients et le serveur SMTP mais aussi entre SMTPs si c'est possible.

L'ensemble de ces ressources permettra de réaliser un serveur SMTP qui répondra complètement au cahier des charges.

Le moyen le plus simple pour réaliser une installation de ce type est de consulter l'excellent site http://shupp.org/toaster/ qui vous donnera pas à pas les informations nécessaires pour réaliser cette installation.

qmail-1.03-jms1.6cd.patch

Il s'agit d'un patch cumulatif réalisé par  John M. Simpson, qui, appliqué à qmail-1.03, aboutit à un résultat sensiblement équivalent à ce qui a été vu plus haut. Nous adopterons cette méthode.

Le détail de ce patch cumulatif est donné ici http://qmail.jms1.net/patches/combined-details.shtml par son auteur.

Préparation du dépôt des sources

Nous allons commencer par créer un répertoire /usr/local/src/tar dans lequel nous rangerons toutes les archives.

Certains logiciels vont exiger d'être configurés et compilés sous une identité d'utilisateur "normal" (autre que root). Pour ce faire, dans ce ce qui va suivre, nous disposons d'un utilisateur "normal" de login "sysop". Pour que ce dernier puisse écrire dans /usr/local/src, il doit appartenir au groupe "staff" (a aménager, suivant la distribution utilisée) :

usermod -G sysop,staff sysop
su sysop
mkdir -p /usr/local/src/tar
exit

Installation

Assurez-vous que les outils nécessaires à la compilation, ainsi que quelques accessoires, sont installés :

apt-get install libgdbm-dev gcc g++ patch make libc-dev libssl-dev apache2 php5 wget bzip2

Préparation de qmail

Nous allons récupérer dans la foulée les daemontools, ucspi-tcp, qmail, les patchs nécessaires et quelques scripts dont nous verrons l'utilité plus loin :

cd /usr/local/src/tar
wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
wget http://cr.yp.to/software/qmail-1.03.tar.gz
wget http://qmail.jms1.net/patches/qmail-1.03-jms1.6cd.patch
wget http://djbware.csi.hu/patches/daemontools-0.76.errno.patch
wget http://djbware.csi.hu/patches/ucspi-tcp-0.88.errno.patch
wget http://qmail.jms1.net/scripts/service-qmail-send-run
wget http://qmail.jms1.net/scripts/service-qmail-smtpd-run
wget http://qmail.jms1.net/scripts/service-any-log-run

Extraction de l'archive, puis application du patch cumulatif de John Simpson :

cd ..
tar xzf tar/qmail-1.03.tar.gz
mv qmail-1.03 qmail-1.03-jms1.6cd
cd qmail-1.03-jms1.6cd
patch < ../tar/qmail-1.03-jms1.6cd.patch

Installation des daemontools

Pour faire démarrer automatiquement un service, il est d'usage d'avoir recours aux scripts normalisés de /etc/init.d.

D.J.Bernstein a cependant créé un système, très différent, mais qui offre quelques avantages originaux, principalement la surveillance des services lancés (si un service s'arrête, pour une raison ou une autre, indépendante de l'administrateur, il sera automatiquement relancé).

De plus, une gestion assez fine des logs de ces services est assurée, sans avoir recours à l'habituel syslog.

L'ensemble de ces outils se trouve dans une archive nommée daemontools-0.76.tar.gz. Cette archive "officielle" est disponible sur le site de son concepteur : http://cr.yp.to/daemontools/install.html.

Il est bien entendu très fortement recommandé d'utiliser les daemontools

Les daemontools nécessitent, pour rester conforme aux spécifications de D.J.Bernstein, de créer un répertoire dans la racine, nommé "package" et d'y mettre les sources dedans. Nous en profiterons pour y appliquer le daemontools-0.76.errno.patch (compilation avec glibc > 2.3) :

mkdir -p /package
chmod 1755 /package
cd /package
tar -xpzf /usr/local/src/tar/daemontools-0.76.tar.gz
cd admin/daemontools-0.76
patch -p1 < /usr/local/src/tar/daemontools-0.76.errno.patch

Puis nous installons ces daemontools :

package/install

Notez que l'installation va ajouter à votre fichier /etc/inittab la ligne :

SV:123456:respawn:/command/svscanboot

Cette ligne a pour but de maintenir éveillé un premier service : scanboot, qui lui-même va démarrer et maintenir un autre service : svscan.

Ce service va parcourir une arborescence que nous n'avons pas encore construite, à partir du répertoire /service.

Si tout c'est bien passé, une commande "ps aux" devrait donner ceci :

janus:/# ps aux | grep svs
root 4477 0.0 0.4 2668 1264 ? Ss 09:49 0:00 /bin/sh /command/svscanboot
root 4494 0.0 0.1 1612 352 ? S 09:49 0:00 svscan /service

Le service "svscan", chaque fois qu'il trouvera ce qu'il attend (nous verrons quoi plus tard) dans l'arborescence /service, lancera une instance de "supervise", destinée à maintenir en vie le service spécifié.

Installation de UCSPI-TCP

Qmail-smtpd, le service smtp de Qmail, n'est pas un serveur dit "standalone". Il s'appuie sur un système comme inetd ou xinetd. Ici encore, D.J.Bernstein a conçu un "tcp wrapper" sur mesure. Il est possible de faire fonctionner qmail-smtpd avec inetd ou xinetd, mais il est bien sûr fortement conseillé d'utiliser plutôt ucspi-tcp, d'autant qu'il va permettre une configuration beaucoup plus fine du fonctionnement de notre MTA, comme nous le verrons plus loin. En effet, ucspi-tcp va rendre possible :

ucspi-tcp est disponible également sur le site de leur concepteur : http://cr.yp.to/ucspi-tcp/install.html, mais encore une fois, nous avons déjà récupéré ces sources.

La procédure est assez similaire à celle des daemontools :

cd /usr/local/src/
tar -xzf tar/ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
patch -p1 < /usr/local/src/tar/ucspi-tcp-0.88.errno.patch
make
make setup check

Les binaires seront placés dans /usr/local/bin. Ceux que nous manipulerons de façon explicite seront :

Pour mettre en place les règles, il faudra créer un fichier texte où on le souhaite, avec le nom qu'on souhaite. Nous ferons ceci plus tard.

Installation de Qmail

Qmail a besoin de quelques utilisateurs sans privilèges, sous le nom desquels divers services s'exécuteront. Il est nécessaire de les créer avant d'installer Qmail. En effet, les UID et GID de ces utilisateurs seront inscrits "en dur" dans le code, de manière à éviter toute falsification ultérieure.

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

Pour respecter les désirs de D.J.B, Qmail sera installé dans le répertoire /var/qmail/ :

mkdir /var/qmail

Enfin, nous installons Qmail, "patché" par qmail-1.03-jms1.6cd :

cd /usr/local/src/qmail-1.03-jms1.6cd
make
make setup check

Un petit moment après, /var/qmail sera peuplé de tout le code nécessaire :

drwxr-sr-x  2 alias  qmail    6 2005-12-28 18:14 alias
drwxr-xr-x  2 root   qmail 4096 2005-12-28 18:14 bin
drwxr-xr-x  2 root   qmail  137 2005-12-28 18:14 boot
lrwxrwxrwx  1 root   root    10 2005-12-28 17:37 control
drwxr-xr-x  2 root   qmail 4096 2005-12-28 18:14 doc
drwxr-xr-x 10 root   qmail   94 2005-12-28 18:14 man
drwxr-x--- 11 qmailq qmail  109 2005-12-28 18:14 queue
drwxr-xr-x  2 root   qmail    6 2005-12-28 18:14 users

Un dernier script permettra de créer quelques points de configuration importants. Il s'agit d'indiquer à Qmail le nom pleinement qualifié de la machine hôte :

/usr/local/src/qmail-1.03-jms1.6cd/config-fast janus.maison.mrs

(janus est dans le domaine fictif maison.mrs)

Ce script donne quelques informations sur ce qu'il fait :

Your fully qualified host name is janus.maison.mrs.
Putting janus.maison.mrs into control/me...
Putting bts.eme into control/defaultdomain...
Putting bts.eme into control/plusdomain...
Putting janus.maison.mrs into control/locals...
Putting janus.maison.mrs into control/rcpthosts...
Now qmail will refuse to accept SMTP messages except to janus.maison.mrs.
Make sure to change rcpthosts if you add hosts to locals or virtualdomains! 

Pour le manuel (installé dans /var/qmail/man), ça ne va pas être bien pratique. Une solution sale mais efficace consiste à les copier dans l'arborescence de la distribution :

for mandir in 1 5 7 8; do cp /var/qmail/man/man$mandir/* /usr/share/man/man$mandir/; done

Une solution nettement plus propre est d'agir sur le fichier /etc/manpath.config, en y ajoutant l'entrée :

MANDATORY_MANPATH /var/qmail/man

(solution testée sur Debian Etch et sur Ubuntu 5.10)

Et sendmail ?

Beaucoup d'applications s'attendent à trouver un exécutable nommé "sendmail". Placé dans  /usr/sbin ou dans /usr/lib chez debian. Qmail en fournit un, mais dans /var/qmail/bin. Donc :
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail

Les logs

Nous allons utiliser qmail-log. Ce n'est pas une obligation, nous pourrions utiliser syslog, mais sur une installation classique de Qmail, nous nous attendons à trouver des logs gérés par qmail-log (vous verrez que ce n'est pas forcément un cadeau, mais avec un peu d'habitude, on s'y fait très bien). Qmail-log gère lui-même la rotation des logs.

Suivant le "gourou" que l'on adopte pour mener à bien une installation de qmail, l'emplacement de ces logs peut beaucoup varier. Jms adopte une pratique originale qui découle d'une certaine logique, mais qui va à l'encontre des pratiques habituelles consistant à regrouper les logs dans /var/log. Nous verrons que Jms préconise de grouper les logs dans une arborescence de /service (déjà évoqué avec les daemontools). Tout ceci sera vu plus en détail plus loin.

Qmail-smtpd est le "daemon" qui reçoit les messages via SMTP. Il invoque qmail-queue pour les déposer dans la file d'attente.

A l'autre bout de la file d'attente, il y a qmail-send, qui transmettra les messages à qmail-lspawn ou a qmail-rspawn, suivant que le destinataire est local ou distant.

Démarrage des services

Nous allons devoir faire démarrer les divers services par l'entremise des daemontools. Nous avons déjà installé ces daemontools et le service svscan est déjà à l'affût.

Nous allons voir par l'exemple comment ceci fonctionne.

mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log

Nous commençons par créer un répertoire "supervise" dans /var/qmail qui, lui-même, contiendra un sous-répertoire par service à démarrer. Chacun de ces sous-répertoires contiendra un répertoire "log", pour le service des logs associé.

Ainsi, le répertoire supervise/qmail-send contiendra par la suite ce qu'il faut pour démarrer le service qmail-send et le répertoire supervise/qmail-send/log contiendra par la suite ce qu'il faut pour démarrer les logs associés à ce service.

L'élément déclencheur sera un script nommé "run". Les différents scripts "run" sont déjà présents dans nos commissions, il suffit de les recopier aux bons endroits :

cp /usr/local/src/tar/service-qmail-send-run /var/qmail/supervise/qmail-send/run
cp /usr/local/src/tar/service-qmail-smtpd-run /var/qmail/supervise/qmail-smtpd/run

Puis, de les rendre exécutables :

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

Voyons le contenu de ces scripts :

qmail-send

cat /var/qmail/supervise/qmail-send/run
#!/bin/sh
#
# service-qmail-send-run (formerly "run.qmail")
# John Simpson <jms1@jms1.net> 2003-07-05
#
# daemontools "run" script for qmail
#
# 2005-04-11 jms1 - (no code changed.) changed the copyright notice to
# specify that the license is the GPL VERSION 2 ONLY. i'm not comfortable
# with the "or future versions" clause until i know what these "future
# versions" will look like.
#
# 2005-11-24 jms1 - (no code changed.) changed the filename as stored on
# the http://qmail.jms1.net/ web site.
#
###############################################################################
#
# Copyright (C) 2003-2005 John Simpson.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# or visit http://www.gnu.org/licenses/gpl.txt
#
###############################################################################

VQ="/var/qmail"

exec env - PATH="$VQ/bin:/usr/local/bin:/usr/bin:/bin" \
qmail-start ./Maildir/

Ce script permet d'invoquer qmail-start. Qmail-start invoque qmail-send, qmail-lspawn, qmail-rspawn, et qmail-clean, sous leurs  propres uids et gids. Ces quatre "daemons" coopèrent pour délivrer les messages depuis la file d'attente (queue).

qmail-smtpd

Attention, ce script est très nettement plus lourd, et contient en commentaire toute sa documentation :

cat /var/qmail/supervise/qmail-smtpd/run

#!/bin/sh
#
# service-qmail-smtpd-run (formerly "run.smtp" and "run.smtp.sslserver")
# John Simpson <jms1@jms1.net> 2003-07-05
#
# Generic daemontools "run" script for qmail "smtp" or "smtpssl" service.
#
# Designed to work with the combined qmail patch file on my web site
# http://www.jms1.net/qmail/patches/
#
# SSL support requires the ucspi-ssl package
# http://www.superscript.com/ucspi-ssl/intro.html
#
# The various SSL/TLS and AUTH-related options are explained in the 
# script below, and http://qmail.jms1.net/tls-auth.shtml has a list of
# the sets of options that most people will need to use.
#
# 2005-10-17 jms1 - changed all "==" tests to "=". the script should now
#   work under the original bourne shell as well as bash.
#
# 2005-11-24 jms1 - (no code changed.) changed the filename of the 
#   script as stored on the http://qmail.jms1.net/ web site.
#
# 2005-12-17 jms1 - (no code changed.) added the comment (above) about
#   the web page with documentation about the "normal" sets of options.
#
# 2005-12-23 jms1 - added SMTP_CDB and SMTPSSL_CDB variables to set the
#   locations of the tcpserver access control files
#
# 2005-12-26 jms1 - added MFCHECK, SPFBEHAVIOR and the six AUTH_SET_*
#   variables available with the 6c2 patch. added a check for RECORDIO
#   which allows it to be commented out or deleted in the top of the file.
#   also added the QUSER variable so that people who need to run qmail-smtpd
#   as a user other than the standard "qmaild" user can do so more easily.
#   added comments for the first set of variables defined.
#
# 2006-01-02 jms1 - for 127.0.0.1 services, RBLSMTPD is now disabled 
#   along with the tcpserver authentication stuff.
# 
# 2006-02-06 jms1 - adding support for "greylisting". if you want to use 
#   this, you can use the "qgreylist" program, available here:
#   http://www.jonatkins.com/page/software/qgreylist
#   or my own "jgreylist" program, available here:
#   http://qmail.jms1.net/scripts/jgreylist.shtml
#
# 2006-03-21 jms1 - simplifying SMTP_CDB process, removed SMTPSSL_CDB
#   (just use SMTP_CDB for the one file which affects this one service.)
#   also made a few error messages more descriptive.
#
# 2006-04-12 jms1 - adding support for the AUTH_CDB patch
#
# 2006-04-21 jms1 - adding support for SPF_LOG and SPF_BLOCK_PLUS_ALL
#
# 2006-07-21 jms1 - fixing some typos, adding the AUTH_CDB stuff again (which
#   seems to have not made its way into the file for some reason)
#
# 2006-07-25 jms1 - commenting out the AUTH_CDB line (which should have
#   been commented out by default.) you should UN-comment this line if
#   you're going to use the AUTH_CDB functionality.
#
# 2006-08-17 jms1 - adding "-t0" to rblsmtpd command line. if a client
#   connects and they're blacklisted, this makes rblsmtpd just show them
#   the error message and immediately hang up. why waste the time on them?
#
# 2006-08-21 jms1 - finished the web page for my own greylisting program.
#   re-arranging the final command line so that the greylisting program is
#   called before rblsmtpd. why do RBL checks (which cost time and network
#   traffic) for an IP that you're only going to block anyway? (the greylist
#   check takes a lot less time.)
#
# 2006-10-19 jms1 - changing the order in the final command line so that
#   rblsmtpd (compiled C) runs before jgreylist (interpreted perl.) thanks
#   to "Lance" for the suggestion.
#
# 2006-12-19 jms1 - removing "relays.ordb.org" from the default list of RBLs,
#   since they have stopped providing their list.
#
# 2007-01-03 jms1 - adding variables to support newer features.
#
# 2007-01-16 jms1 - changing the script variable RBLSMTPD to RBLSMTPD_PROG
#   to avoid confusion about an "RBLSMTPD" environment variable (which this
#   script doesn't get involved with at all.) also added code to send a copy
#   of the actual service command line to the log just before starting.
#
# 2007-03-04 jms1 - adding comments for the MAXLOAD, MAXCONNIP, MAXCONNC,
#   and DIEMSG variables, which control how tcpserver works if you are
#   using the "tcpserver limits" patch, documented here:
#   http://linux.voyager.hr/ucspi-tcp/
#
# 2007-03-04 jms1 - moving LOCAL to the normal configuration section so its
#   value can be used for SMTPGREETING, DIEMSG, etc.
#
# 2007-04-08 jms1 - adding checks to not export empty variables. thanks to
#   John Johnstone for the suggestion.
#
###############################################################################
#
# Copyright (C) 2003-2007 John Simpson.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# or visit http://www.gnu.org/licenses/gpl.txt
#
###############################################################################

exec 2>&1

# location of /var/qmail directory
VQ="/var/qmail"

# explicitly set the path (for safety)
PATH="$VQ/bin:/usr/local/bin:/usr/bin:/bin"

# cdb file to use with the AUTH command. do not un-comment this
# unless you are actually using this functionality. (requires 6c5 or later)
#AUTH_CDB=$VQ/control/auth.cdb

# where to find the "checkpassword" program used to verify AUTH credentials
# (only used if AUTH_CDB is not set)
CHECKPW=~vpopmail/bin/vchkpw # Note 1

# what program to run for "qmail-smtpd"
SMTPD="qmail-smtpd"

# location of tcpserver access control file
SMTP_CDB="/etc/tcp/smtp.cdb" # Note 2

# userid that qmail-smtpd should run as
QUSER=qmaild # Note 1

# greylisting program
#GREYLIST="jgreylist"

# local hostname, read from control/me. should not need to modify this.
LOCAL=`head -1 $VQ/control/me`

# custom greeting, overrides control/smtpgreeting (requries 6c7 or later)
#SMTPGREETING="${LOCAL} NO UCE"

# inject an artificial delay of "x" seconds before the greeting. 30 seconds
# has been found to be very effective at killing spammers. (req 6cb/later)
#GREETDELAY=30

# clients who send anything before the initial greeting are violating RFC 821
# and therefore are probably spammers. this allows you to drop them without
# any further discussion. (requires 6cb or later)
#DROP_PRE_GREET=1

# specify IP to listen on, or 0 for "all interfaces"
IP=unset # Note 3

# specify port number. normally 25, or 465 for an SSL-secured server.
PORT=25

# listen for SSL or not?
SSL=0

# if you wish to only support TLS connections, rejecting mail if STARTTLS
# is not active.
# note that SSL=1 will force this to 0 within the program.
# do not use this and DENY_TLS at the same time.
FORCE_TLS=0

# if you wish to not allow TLS connections, even if the key file is there.
# note that SSL=1 will force this to 1 within the program.
# do not use this and FORCE_TLS at the same time.
DENY_TLS=0

# support SMTP AUTH or not?
AUTH=1 # Note 4

# do you require clients to AUTH before they can send mail?
REQUIRE_AUTH=0

# support SMTP AUTH over a non-secured connection?
#
# this is a VERY BAD IDEA, since it allows your users' email progrmas to
# send their passwords over the network in plain text... and all it takes
# is for a spammer to get ONE of your users' passwords and you become an
# open relay.
#
# for the same reason, allowing non-secured POP3 or IMAP is also a bad
# idea.
#
# are you absolutely sure you want to make your server insecure?
ALLOW_INSECURE_AUTH=0

# if you have a validrcptto.cdb file, how many invalid RCPT TO attempts
# do you wish to allow before hanging up on the client?
# if unset (and validrcptto.cdb exists) the default is 10.
VALIDRCPTTO_LIMIT=10

# if you're using validrcptto.cdb and you want to log what the RCPT TO
# values are and what values it found in the cdb file to match them,
# change this to 1. (requires 6a or higher)
# if you also want to see what entries are searched for within the cdb
# file, change this to 2. (requires 6c8 or higher)
VALIDRCPTTO_LOG=2

# this should work on most systems, if not you may need to manually set
# the location of your "/bin/true" binary (only needed for AUTH support)
TRUE=`which true`

# number of concurrent incoming connections to allow.
# "life with qmail" had this as a /var/qmail/control file, i prefer to
# configure it here.
MAX=30

# set this to the full path of your "recordio" binary if you want to use
# recordio. this should only be used for testing. note that this will end
# up logging the contents of peoples' emails and their AUTH passwords, so
# the log file should not be world-readable.
#RECORDIO="/usr/local/bin/recordio"

# if you wish to use RBL's to block or anti-block messages, set RBLSMTPD_PROG
# to the full path of your "rblsmtpd" binary (from the ucspi-tcp package.)
# RBL_BAD should contain any RBL lists we wish to use to block mail
# RBL_GOOD should contain any RBL lists we wish to use to anti-block mail
#   (that is, treat them as "good" even if they're listed on a "bad" list.)
#RBLSMTPD_PROG=/usr/local/bin/rblsmtpd
#RBL_BAD="zen.spamhaus.org dnsbl.njabl.org dnsbl.sorbs.net bl.spamcop.net"
#RBL_GOOD=""

# the MFCHECK verifies that an MX record exists for the domain portion of
# the envelope sender of a message (to reject obviously spoofed email
# addresses- easy for spammers to avoid but it's surprising just how many
# messages this still blocks.) normally this is configured using the
# "mfcheck" control file, but if you have multiple SMTP services and want
# just this one service to be different you can override the value from
# the file by changing the value here.
MFCHECK=1 # Note 5

# normally the SPF checking is configured using the "spfbehavior" control
# file, but the value can be overridden here if needed (if you have multiple
# SMTP services and want one or more to handle SPF differently, for example.)
# the values are:
#  0 do not check at all
#  1 check and create a Received-SPF header, but don't refuse
#  2 return temporary error in case of DNS lookup problems
#  3 reject messages where the SPF result is FAIL
#  4 reject messages where the SPF result is SOFTFAIL or FAIL
#  5 reject messages where the SPF result is NEUTRAL, SOFTFAIL, or FAIL
#  6 reject messages where the SPF result is anything other than PASS
SPFBEHAVIOR=1 # Note 6

# log the results of each SPF check
SPF_LOG=1

# some spammers have figured a way to get around SPF checking by creating
# SPF records for their own domains which contain the term "+all". this
# variable will enable code to treat this term as an automatic rejection.
SPF_BLOCK_PLUS_ALL=0

# if you wish to use domainkeys, set DOMAINKEYS=1 and edit the DKVERIFY
# value as needed.
#
# the DKVERIFY value is made up of letters, each of which tells the qmail-dk
# program whether a specific domainkeys result should be considered a hard
# error (using an UPPERCASE letter), a soft error (using a lowercase letter),
# or ignored (no letter at all.) the letters are...
#   A good signature
#   B bad signature  (sig does not match content- forgery, transmission error)
#   C no signature   (the majority of mail at this point)
#   D no key         (signature present but can't find key to verify)
#   E bad key        (found a key but it's no good)
#   F can't verify   (can't tell if signature is good or bad)
#   G syntax         (mis-formed signature header, good indicator of forgery)
#   H no resources   (out of memory, etc.)
#   I bad arguments  (qmail-dk program called incorrectly) (?)
#   J revoked        (the signing key has been revoked)
#   K internal error (bug in the code) (?)
# the normal default value is "DEGIJKfh" (i.e. F and H are soft errors, the
# others mentioned are hard errors, and ABC are not errors.) i choose to add
# "B" as a hard error- if soembody is forging domainkeys signatures, i don't
# want to accept them at all.
#
# if DKSIGN is set, the qmail-dk program will try to sign the message. if
# not, and if DKVERIFY is set, it will try to verify a signature on the
# message. otherwise, if it can find a key in "the default location" for the
# sender's domain, it will sign the message using that key. otherwise the
# program will do nothing.
#
# the DKSIGN variable is handled rather oddly- it forces a message to be
# signed and it also sets the location for a non-standard key. the value
# should specify the filename for the key- if the filename contains a "%"
# charcter, the sender's domain name will be substituted for it. if the value
# is not set, the default is "/etc/domainkeys/%/default".
# if the file exists but can't be read, or does not contain a valid private
# key, qmail-dk will return an error (and the mail log will show the usual
# "qq error" that everybody loves.)
#
# the private key files should be readable to the "qmaild" user only.
#
# note that if you wish to use domainkeys with qmail using my patches, you
# need AT LEAST the "6b" version of the combined patch, along with the
# corresponding domainkeys add-on patch. this web site has more information:
# http://www.jms1.net/qmail/patches/domainkeys.shtml
#
# NOTE: i am waiting to hear back from russell nelson about why the DKSIGN
# variable is serving two purposes, and how if somebody wanted to store
# their keys in a non-standard location, messages could not be signed
# unless the DKSIGN variable is specifically set. i'm not really sure if
# this qualifies as a "bug", which is why i'm waiting to see what russell
# has to say about it.
#
# for now, instead of storing the DKSIGN value directly, we will store it
# in an AUTH_SET_DKSIGN variable, so that if the user successfully does an
# AUTH command, the DKSIGN value will be set correctly and their message
# will be signed instead of verified. of course this means that no
# messages will be signed unless the client sends a successful AUTH
# command.
#
# and of course none of this means a thing unless you set DOMAINKEYS=1 below.

DOMAINKEYS=0
DKVERIFY=DEfGhIJK
AUTH_SET_DKSIGN=/etc/domainkeys/%/default

# under the "6c2" or newer version of the combined patch, certain environment
# variables can be changed when the client sends a successful AUTH command.
# you may wish to disable MFCHECK or DATABYTES, for example. the following
# environment variables will be re-read after a successful AUTH command:

#export AUTH_SET_MFCHECK=0
#export AUTH_SET_DATABYTES=0
#export AUTH_SET_SPFBEHAVIOR=1
#export AUTH_SET_VALIDRCPTTO_LIMIT=10
#export AUTH_SET_VALIDRCPTTO_LOG=1
#export AUTH_SET_SPF_LOG=1

# control how tcpserver works... reject connections when the load average   
# is above a certain level, if too many connections arrive at the same
# time from a given IP or class-c block, and specify a message to be sent
# if a connection is refused for one of these reasons.
#
# this requires the "tcpserver limits" patch for ucspi-tcp, available here:
# http://linux.voyager.hr/ucspi-tcp/

#export MAXLOAD=350		# reject if load avg over 3.50
#export MAXCONNIP=2		# careful, 0 means "always reject"
#export MAXCONNC=5		# careful, 0 means "always reject"
#export DIEMSG="421 ${LOCAL} Service temporarily unavailable"

###############################################################################
###############################################################################
###############################################################################
#
# THERE SHOULD BE NO NEED TO CHANGE ANYTHING BELOW THIS LINE. of course, the
# script is on your system and you're free to edit it however you want, but
# changing things below this point may cause strange things to happen. make
# sure you understand what you're doing if you change anything below...

QDUID=`id -u $QUSER`
QDGID=`id -g $QUSER`

if [ -z "$IP" -o "$IP" = "unset" ]
then
	echo "The IP variable is not set in the run script. Cannot start."
	sleep 5
	exit 1
fi

if [ -z "$QDUID" -o -z "$QDGID" -o -z "$MAX" -o -z "$LOCAL" \
	-o -z "$SSL" -o -z "$AUTH" ]
then
	echo "One of the variables QDUID, QDGID, MAX, LOCAL, SSL, or AUTH"
	echo "is not set in the run script. Cannot start."
	sleep 5
	exit 1
fi

if [ ! -f $VQ/control/rcpthosts ]
then
	echo Creating emtpy $VQ/control/rcpthosts file to prevent open relay.
	touch $VQ/control/rcpthosts
	chmod 644 $VQ/control/rcpthosts
fi

if [ -f $VQ/bin/qmail-scanner-queue ]
then
	export QMAILQUEUE=$VQ/bin/qmail-scanner-queue
elif [ -f $VQ/bin/qmail-scanner-queue.pl ]
then
	export QMAILQUEUE=$VQ/bin/qmail-scanner-queue.pl
elif [ -f $VQ/bin/qmail-spamassassin -a -f /usr/bin/spamassassin ]
then
	export QMAILQUEUE=$VQ/bin/qmail-spamassassin
fi

if [ "$SSL" = "1" ]
then
	if ! which sslserver > /dev/null 2>&1
	then
		echo ERROR: sslserver not found in PATH [$PATH]
		exit 1
	fi

	if [ ! -f $VQ/control/servercert.pem ]
	then
		echo ERROR: $VQ/control/servercert.pem does not exist
		exit 1
	fi
fi

if [ "$IP" = "127.0.0.1" ]
then
	export RELAYCLIENT=""
	RBLSMTPD_PROG=""
	ACMD=""
elif [ -z "${SMTP_CDB:-}" ]
then
	ACMD=""
else
	if [ ! -f "$SMTP_CDB" ]
	then
		echo ERROR: $SMTP_CDB does not exist
		exit 1
	fi

	ACMD="-x $SMTP_CDB"
fi

if [ "$AUTH" = "1" ]
then
	if [ -n "$AUTH_CDB" ]
	then
		if [ ! -f $AUTH_CDB ]
		then
			echo ERROR: AUTH_CDB file [$AUTH_CDB] does not exist
			exit 1
		fi

		export AUTH_CDB
		ARGS=""
	elif [ -n "$CHECKPW" ]
	then
		if [ ! -f $CHECKPW ]
		then
			echo ERROR: $CHECKPW [$CHECKPW] program does not exist
			exit 1
		fi

		if [ -z "$TRUE" ]
		then
			echo ERROR: TRUE is not set in the run script
			exit 1
		elif [ ! -e $TRUE ]
		then
			echo ERROR: $TRUE [$TRUE] is not an executable
			exit 1
		fi

		ARGS=" $LOCAL $CHECKPW $TRUE"
	else
		echo ERROR: AUTH=1 but no AUTH_CDB or CHECKPW
		exit 1
	fi
else
	ARGS=""
fi

########################################
# make RBL command (if needed)

RBLCMD=""

if [ -n "$RBLSMTPD_PROG" ]
then
	if [ -n "$RBL_GOOD" ]
	then
		for name in $RBL_GOOD
		do
			RBLCMD="$RBLCMD -a $name"
		done
	fi

	if [ -n "$RBL_BAD" ]
	then
		for name in $RBL_BAD
		do
			RBLCMD="$RBLCMD -r $name"
		done
	fi

	if [ -n "$RBLCMD" ]
	then
		RBLCMD="$RBLSMTPD_PROG -t0 $RBLCMD"
	fi
fi

########################################
# make domainkeys command (if needed)

if [ "$DOMAINKEYS" = "1" ]
then
	if [ -f "$VQ/bin/qmail-dk" ]
	then
		if [ -n "$QMAILQUEUE" ]
		then
			export DKQUEUE="$QMAILQUEUE"
		fi
		export AUTH_UNSET_DKVERIFY=1
		export QMAILQUEUE="$VQ/bin/qmail-dk"

		if [ -n "$DKVERIFY" ] ; then export DKVERIFY ; fi
		if [ -n "$DKSIGN"   ] ; then export DKSIGN   ; fi
	else
		echo ERROR: $VQ/bin/qmail-dk not found, cannot use domainkeys
	fi
fi

########################################
# handle variables which may not have been set, but need to exist even
# if they contain blank values

if [ -z "$RECORDIO" ]
then
	RECORDIO=""
fi

if [ -z "$GREYLIST" ]
then
	GREYLIST=""
fi

########################################
# do the deed

if [ -n "$SSL"                 ] ; then export SSL                 ; fi
if [ -n "$FORCE_TLS"           ] ; then export FORCE_TLS           ; fi
if [ -n "$DENY_TLS"            ] ; then export DENY_TLS            ; fi
if [ -n "$REQUIRE_AUTH"        ] ; then export REQUIRE_AUTH        ; fi
if [ -n "$ALLOW_INSECURE_AUTH" ] ; then export ALLOW_INSECURE_AUTH ; fi
if [ -n "$VALIDRCPTTO_LIMIT"   ] ; then export VALIDRCPTTO_LIMIT   ; fi
if [ -n "$VALIDRCPTTO_LOG"     ] ; then export VALIDRCPTTO_LOG     ; fi
if [ -n "$MFCHECK"             ] ; then export MFCHECK             ; fi
if [ -n "$SPFBEHAVIOR"         ] ; then export SPFBEHAVIOR         ; fi
if [ -n "$SPF_LOG"             ] ; then export SPF_LOG             ; fi
if [ -n "$SPF_BLOCK_PLUS_ALL"  ] ; then export SPF_BLOCK_PLUS_ALL  ; fi
if [ -n "$SMTPGREETING"        ] ; then export SMTPGREETING        ; fi
if [ -n "$GREETDELAY"          ] ; then export GREETDELAY          ; fi
if [ -n "$DROP_PRE_GREET"      ] ; then export DROP_PRE_GREET      ; fi

if [ "$SSL" = "1" ]
then
	export CERTFILE="$VQ/control/servercert.pem"
	export KEYFILE=""
	export DHFILE=""

	CMD="sslserver -e"
else
	CMD="tcpserver"
fi

CMD="$CMD -vR -l $LOCAL -c $MAX -u $QDUID -g $QDGID $ACMD $IP $PORT"
CMD="$CMD $RBLCMD $GREYLIST $RECORDIO $SMTPD $ARGS"

echo "command-line: exec $CMD 2>&1"
exec $CMD 2>&1

########################################
# this will only be reached if the exec fails

echo ERROR: command did not run correctly
exit 1

Ici, c'est franchement plus compliqué. Il est bien entendu vivement recommandé de passer du temps à analyser ce script de façon précise, mais fort heureusement, sa configuration par défaut fait le plus souvent l'affaire. Voyez tout de même les points surlignés :

Note 1 : vchkpw et qmail-smtpd

Le programme qui permettra de vérifier qu'un utilisateur existe, dans le cas de domaines virtuels, sera vchkpw, fourni par vpopmail. Ce programme sera invoqué ici par qmail-smtpd, qui, lui-même, est exécuté par l'utilisateur "qmaild". vchkpw, pour fonctionner correctement devra s'exécuter sous l'identité de l'utilisateur "vpopmail". Il y a donc à priori une contradiction. la solution simple est de faire fonctionner qmail-smtpd sous l'identité de "vpopmail" ce qui présente tout de même un risque en cas de compromission de qmail-smtpd.

Il sera probablement plus rigoureux de placer un suid sur vchkpw.

Note 2 : les "tcprules"

Nous avons vu que ces règles pouvaient être placées n'importe où. Ce script fixe leur emplacement :

/etc/tcp/smtp.cdb

C'est un emplacement logique, et autant le garder. Mais il faudra s'en souvenir par la suite.

Note 3 : Adresse d'écoute de qmail-smtpd

Aucune adresse n'est définie dans le script. Mettez 0 (toutes les interfaces) ou l'adresse IP de l'interface d'écoute.

Note  4 : autoriser le "roaming"

Par défaut, ce paramètre est à 0. Mettez-le à 1 si vous souhaitez que les utilisateurs ayant une adresse IP dynamique et qui désirent utiliser ce SMTP pour envoyer leur courrier puissent le faire, après authentification par vchkpw.

Note 5 : domain envelope sender

Lorsque cette option est active (elle l'est par défaut dans ce script), qmail refusera un message dont le domaine du "sender" ne possède pas de MX. La protection, bien que dérisoire, arrive tout de même à bloquer pas mal de spams.

Note 6 : spfbehavior

SPF est quelque chose comme un système  "reverse MX" fondé sur DNS pour définir des auteurs de messages autorisés en fonction du nom de domaine inscrit dans leur adresse d'émetteur. L'objectif est d'interdire des "senders" dont l'adresse est falsifiée. Malheureusement, ce système nécessite un enregistrement de type TXT spécifique sur les DNS et pour l'instant, peu de domaines l'utilisent.

Utilisé pour activer la recherche SPF. La valeur par défaut est 0 (off). Une valeur entre 0 et 6 est possible :

0 : Inactif, ne crée pas d'en-tête Received-SPF
1 : Crée seulement l'en-tête Received-SPF, non bloquant.
2 : Utilise "erreur temporaire" quand il y a des problèmes de résolution DNS.
3 : Rejette les mails lorsque SPF résout comme fail (deny)
4 : Rejette les mails lorsque SPF résout comme softfail
5 : Rejette les mails lorsque SPF résout comme neutral
6 : Rejette les mails lorsque SPF ne résout pas comme pass

Les valeurs plus grandes que 3 sont fortement déconseillées, vous voudrez probablement fonctionner avec 2 ou 3.

Important: Ce paramètre peut être surchargé en utilisant la variable d'environnement SPFBEHAVIOR, par exemple. depuis les règles du tcpserver.
Note: Si RELAYCLIENT est mis, les recherches SPF sont désactivées. (Ceci inclue aussi SMTP-AUTH et les patches similaires)

Dans ce script, spfbehavior est fixé à 1. A vous de voir si vous souhaitez être plus restrictif.

Les outils invoqués dans ces scripts (ou pouvant l'être)

softlimit

Cet outil n'est pas utilisé dans ce script, mais rien ne vous interdit de l'y intégrer : "softlimit runs another program with new resource limits" (la documentation officielle complète, comme seul D.J.B sait les faire, se trouve ici : http://cr.yp.to/daemontools/softlimit.html). En bref, il s'agit d'une protection destinée à éviter les "Deny of Service", en limitant les ressources allouées au processus appelé en cascade. Le processus en cascade n'est autre que...

tcpserver

Doc officielle : http://cr.yp.to/ucspi-tcp/tcpserver.html .

Il existe un grand nombre d'options dont certaines sont obligatoires. Constatez que c'est ici que le fichier /etc/tcp/smtp.cdb est invoqué, de même que sont définis les utilisateur et groupe sous lesquels fonctionnera qmail-smtpd.

Faites "man qmail-smtpd" pour tous les détails du fonctionnement de ce service.

Mise en place des scripts de gestion des logs

Jms propose un script générique qui stockera les logs dans les divers /var/qmail/supervise/<service>/log

cp /usr/local/src/tar/service-any-log-run /var/qmail/supervise/qmail-send/log/run
cp /usr/local/src/tar/service-any-log-run /var/qmail/supervise/qmail-smtpd/log/run

Rendons tous ces scripts exécutables :

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

Le script "service-any-log-run" est le suivant :

#!/bin/sh
#
# service-any-log-run (formerly "run.log")
# John Simpson <jms1@jms1.net> 2003-07-05
#
# Generic "run" script for daemontools log services. Allows up to 1024 log
# files to build up before they get rotated out of existence, and allows
# each file to become up to 1MB in size before they stop being used.
#
# 2005-04-11 jms1 - (no code changed.) changed the copyright notice to
# specify that the license is the GPL VERSION 2 ONLY. i'm not comfortable
# with the "or future versions" clause until i know what these "future
# versions" will look like.
#
# 2005-11-24 jms1 - (no code changed.) changed the filename as stored on
# the http://qmail.jms1.net/ web site.
#
# 2006-08-11 jms1 - added extra code to create a "log/lstatus" file which
# will contain the latest "status:" line.
#
###############################################################################
#
# Copyright (C) 2003-2006 John Simpson.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# or visit http://www.gnu.org/licenses/gpl.txt
#
###############################################################################

VQ="/var/qmail"

exec env - PATH="$VQ/bin:/usr/local/bin:/usr/bin:/bin" \
multilog t n1024 s1048576 ./main \
'-*' '+*ver: status:*' =lstatus

Je vous laisse vous plonger dans la documentation officielle de multilog pour en comprendre tous les détails. La partie surlignée indique l'emplacement où seront stockés les logs. Dans ce cas, si nous utilisons ce script pour le service qmail-smtpd, par exemple, nous aurons les logs dans le répertoire :

/var/qmail/supervise/qmail-smtpd/log/main.

Ce n'est pas un lieu bien intuitif, mais finalement pourquoi pas ? A vous de voir en fonction de votre architecture.

Presque tout est en place. En réalité, svscan observe la structure des services à superviser dans le répertoire /service, qui pour l'instant n'existe pas. Le moment venu, il suffira d'y créer des liens symboliques vers les répertoires qmail-* de /var/qmail/supervise.

Les daemontools gèrent les services de façon très "collante", c'est leur mission. Si un service meurt, il est automatiquement relancé. A ce propos, il est d'ailleurs nécessaire de faire ici un bon gros avertissement :

Avant de confier aux daemontools la gestion d'un service, assurez-vous que votre script de lancement ne comporte aucune erreur. Si c'était le cas, "supervise" faisant (bêtement ?) son travail essayera inlassablement de relancer le script, ce qui peut très rapidement saturer vos logs.

Comme il faut bien pouvoir arrêter ou démarrer un service si le besoin s'en fait sentir, la commande "svc" nous sera utile. Elle n'est pas très pratique à manipuler, aussi un script a été créé pour réaliser quelques actions courantes de façon simple. Ce script, qui s'appelle "qmailctl". Il en existe plusieurs variantes sur le vaste internet. Récupérons une variante proposée par life with qmail :

cd /usr/local/src/tar
wget http://www.lifewithqmail.org/qmailctl-script-dt70
cp /usr/local/src/tar/qmailctl-script-dt70 /var/qmail/bin/qmailctl
chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin

Voici ce script :

#!/bin/sh

# For Red Hat chkconfig
# chkconfig: - 80 30
# description: the qmail MTA

PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH

QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`

case "$1" in
  start)
    echo "Starting qmail"
    if svok /service/qmail-send ; then
      svc -u /service/qmail-send /service/qmail-send/log
    else
      echo "qmail-send supervise not running"
    fi
    if svok /service/qmail-smtpd ; then
      svc -u /service/qmail-smtpd /service/qmail-smtpd/log
    else
      echo "qmail-smtpd supervise not running"
    fi
    if [ -d /var/lock/subsys ]; then
      touch /var/lock/subsys/qmail
    fi
    ;;
  stop)
    echo "Stopping qmail..."
    echo "  qmail-smtpd"
    svc -d /service/qmail-smtpd /service/qmail-smtpd/log
    echo "  qmail-send"
    svc -d /service/qmail-send /service/qmail-send/log
    if [ -f /var/lock/subsys/qmail ]; then
      rm /var/lock/subsys/qmail
    fi
    ;;
  stat)
    svstat /service/qmail-send
    svstat /service/qmail-send/log
    svstat /service/qmail-smtpd
    svstat /service/qmail-smtpd/log
    qmail-qstat
    ;;
  doqueue|alrm|flush)
    echo "Flushing timeout table and sending ALRM signal to qmail-send."
    /var/qmail/bin/qmail-tcpok
    svc -a /service/qmail-send
    ;;
  queue)
    qmail-qstat
    qmail-qread
    ;;
  reload|hup)
    echo "Sending HUP signal to qmail-send."
    svc -h /service/qmail-send
    ;;
  pause)
    echo "Pausing qmail-send"
    svc -p /service/qmail-send
    echo "Pausing qmail-smtpd"
    svc -p /service/qmail-smtpd
    ;;
  cont)
    echo "Continuing qmail-send"
    svc -c /service/qmail-send
    echo "Continuing qmail-smtpd"
    svc -c /service/qmail-smtpd
    ;;
  restart)
    echo "Restarting qmail:"
    echo "* Stopping qmail-smtpd."
    svc -d /service/qmail-smtpd /service/qmail-smtpd/log
    echo "* Sending qmail-send SIGTERM and restarting."
    svc -t /service/qmail-send /service/qmail-send/log
    echo "* Restarting qmail-smtpd."
    svc -u /service/qmail-smtpd /service/qmail-smtpd/log
    ;;
  cdb)
    tcprules /etc/tcp/smtp.cdb /etc/tcp/smtp.tmp < /etc/tcp/smtp
    chmod 644 /etc/tcp/smtp.cdb
    echo "Reloaded /etc/tcp/smtp."
    ;;
  help)
    cat <<HELP
   stop -- stops mail service (smtp connections refused, nothing goes out)
  start -- starts mail service (smtp connection accepted, mail can go out)
  pause -- temporarily stops mail service (connections accepted, nothing leaves)
   cont -- continues paused mail service
   stat -- displays status of mail service
    cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
 reload -- sends qmail-send HUP, rereading locals and virtualdomains
  queue -- shows status of queue
   alrm -- same as doqueue
  flush -- same as doqueue
    hup -- same as reload
HELP
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
    exit 1
    ;;
esac

exit 0

La partie surlignée est à modifier comme indiqué, en fonction des choix précédents, le reste étant utilisable en l'état.

Si vous avez eu le courage d'analyser en détail ce script, tant mieux. Sinon, nous aurons l'occasion de le voir à l'oeuvre plusieurs fois dans la suite de cet exposé.

Conclusion

Nous avons un Qmail en place et presque prêt à démarrer. Cependant, compte tenu du cahier des charges, nous devons encore installer Vpopmail, avant de faire démarrer l'usine.


Précédente ] Accueil ] Suivante ]

Osez installer Qmail
mis à jour le 27/04/2007
 ©  Christian Caleca