Courier-imap
 27/04/2007
 Christian CALECA 
Liste des cours

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


Le serveur IMAP

Passons maintenant au serveur IMAP. Il existe plusieurs serveurs qui permettent de gérer les boîtes aux lettres au format Maildir. Dovecot, dont la version 1.0 vient d'être publiée au moment où ces lignes sont écrites, est un bon serveur. Qui plus est, il sait utiliser la base de données des utilisateurs dont nous disposons dans vpopmail. J'ai pu faire quelques essais qui semblent concluents. Courier-IMAP semble cependant le plus approprié (en tous les cas, le plus éprouvé) au couple qmail/vpopmail.

Les deux serveurs existent dans la distribution Debian (et probablement dans toutes les autres). Malheureusement, pour des considérations d'incompatibilités de licences avec vpopmail, aussi bien dovecot que courier-imap sont fournis sans le support de vpopmail. Il nous faudra une fois de plus passer par les sources.

Nous allons ici détailler l'installation de courier-imap.

Courier propose une solution complète de messagerie. Nous n'avons pas besoin de tout. Les archives courier-authlib et courier-imap nous suffiront dans un premier temps.

Courier-imap utilise "fam" (File Alteration Monitor). Certaines distributions installent fam par défaut et d'autres non, dont la Debian. Expect n'est pas indispensable, mais nécessaire si nous souhaitons installer sqwebmail par la suite, pour que les utilisateurs puissent changer leur mot de passe :

apt-get install fam expect

La compilation des diverses archives de courier sont assez rigoureuses et ne doivent pas être réalisées sous  l'identité "root". 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" (mais nous avons déjà réglé ce problème) :

su sysop
cd /usr/local/src/tar
wget http://prdownloads.sourceforge.net/courier/courier-authlib-0.59.3.tar.bz2
wget http://prdownloads.sourceforge.net/courier/courier-imap-4.1.3.tar.bz2

Installation de courier-authlib

Il est indispensable de commencer par celui-ci.

cd ..
tar xjf tar/courier-authlib-0.59.3.tar.bz2
cd courier-authlib-0.59.3

./configure --help cous donnera toutes les options de compilation accessibles. Ces suivantes devraient suffire à nos besoins. Pour la suite, il sera nécessaire que le démon d'authentification soit lancé sous l'identité de vpopmail, de même qu'il sera plus cohérent de trouver les configurations dans /etc.

./configure --with-mailuser=vpopmail \
            --with-mailgroup=vchkpw \
            --with-authvchkpw \
            --sysconfdir=/etc/courier
make

Il peut se faire, avec cette version de courier-authlib, que la compilation s'interrompe avec un message d'erreur sur le fichier authvchkpw.c :

authvchkpw.c: In function 'auth_vchkpw':
authvchkpw.c:86: warning: implicit declaration of function 'auth_vchkpw_login'
authvchkpw.c: At top level:
authvchkpw.c:103: error: static declaration of 'auth_vchkpw_login' follows non-static declaration
authvchkpw.c:86: error: previous implicit declaration of 'auth_vchkpw_login' was here
authvchkpw.c: In function 'auth_vchkpw_changepass':

Cette erreur est due à l'appel d'une fonction qui n'est pas encore déclarée, et gcc ne semble pas tolérer cette "liberté". Dans ce cas, appliquer ce patch sur authvchkpw.c :

--- courier-authlib-0.59.3/authvchkpw.c 2007-04-22 20:53:30.000000000 +0200
+++ courier-authlib-0.59.3b/authvchkpw.c        2007-04-25 17:53:58.908980669 +0200
@@ -55,16 +55,19 @@
        return (*i->callback_func)(a, i->callback_arg);
 }

 #if HAVE_HMACLIB

 #include        "libhmac/hmac.h"
 #include        "cramlib.h"

+static int auth_vchkpw_login(const char *service, char *authdata,
+        int (*callback_func)(struct authinfo *, void *), void *callback_arg);
+

 static int auth_vchkpw_cram(const char *service,
                            const char *authtype, char *authdata,
                            int (*callback_func)(struct authinfo *, void *),
                            void *callback_arg)
 {
         struct  cram_callback_info      cci;

Créez un fichier nommé par exemple /usr/local/src/patch.diff qui contient ce patch et :

cd /usr/local/src/courier-authlib-0.59.3
patch < ../patch.diff

Et reprendre la configuration puis la compilation.

La construction est terminée, il faut maintenant l'installer (sous l'identité "root", cette fois-ci) :

exit
cd /usr/local/src/courier-authlib-0.59.3
make install-strip
make install-configure
make install-man
mkdir /var/lock/subsys

La construction a généré un fichier de démarrage pour le sysvinit. Dans un premier temps, faisons simple et utilisons-le :

cp courier-authlib.sysvinit /etc/init.d/courier-authlib
chmod 755 /etc/init.d/courier-authlib

Configuration de courier-authlib :

Dans le fichier /etc/courier/authlib/authdaemonrc, trouvez ces lignes, et modifiez le paramètre "authmodulelist" comme indiqué :

# The authentication modules that are linked into authdaemond.  The
# default list is installed.  You may selectively disable modules simply
# by removing them from the following list.  The available modules you
# can use are: authcustom authcram authuserdb authvchkpw authldap authpgsql authmysql authpam

authmodulelist="authvchkpw"

Vérifions que tout ceci fonctionne :

 /etc/init.d/courier-authlib start

et voyons :

ps aux | grep courier
root     22078  0.0  0.0   1568   392 ?        S    18:25   0:00 /usr/local/sbin/courierlogger 
                                                                 -pid=/usr/local/var/spool/authdaemon/pid 
                                                                 -start /usr/local/libexec/courier-authlib/authdaemond
root     22079  0.0  0.1   2084   640 ?        S    18:25   0:00 /usr/local/libexec/courier-authlib/authdaemond
root     22080  0.0  0.0   2084   260 ?        S    18:25   0:00 /usr/local/libexec/courier-authlib/authdaemond
root     22081  0.0  0.0   2084   260 ?        S    18:25   0:00 /usr/local/libexec/courier-authlib/authdaemond
root     22082  0.0  0.0   2084   260 ?        S    18:25   0:00 /usr/local/libexec/courier-authlib/authdaemond
root     22083  0.0  0.0   2084   260 ?        S    18:25   0:00 /usr/local/libexec/courier-authlib/authdaemond
root     22084  0.0  0.0   2084   260 ?        S    18:25   0:00 /usr/local/libexec/courier-authlib/authdaemond

Pour que le démarrage soit automatique au boot, nous verrons plus tard comment s'y prendre avec les daemontools.

Installation de courier-imap

su sysop
cd /usr/local/src/
tar xjf tar/courier-imap-4.1.3.tar.bz2
cd courier-imap-4.1.3/

Là encore, il y a de nombreuses options de configuration, mais les suivantes nous suffiront sans doute :

./configure --sysconfdir=/etc/courier
make

Reste à installer :

exit
cd /usr/local/src/courier-imap-4.1.3/
make install-strip
make install-configure
make install-man

La bonne nouvelle

Comme son nom ne le laisse pas forcément supposer, l'archive courier-imap fournit non seulement un serveur IMAP, mais aussi un serveur IMAPS (SSL), la possibilité d'utiliser IMAP avec le support de TLS, et de même pour POP3 et POP3S. Nous avons donc la possibilité de construire un système de récupération des messages qui correspondra à tous les désirs.

N'entrons pas ici dans les détails de "IMAP startTlS" ni de "IMAP over SSL", mais tout de même précisons ceci :

Il en va de même pour POP.

Bien entendu, il est vivement conseillé d'utiliser la seconde ou la troisième méthode plutôt que la première.

Configuration de courier-imap :

/etc/courier a été peuplé d'un certain nombre de fichiers de configuration. Nous allons dans un premier temps nous intéresser à /etc/courier/imapd

Dans un premier essai tout du moins, les options par défaut devraient suffire. Il faut tout de même signaler que ce service doit démarrer. Trouvez l'option "IMAPDSTART" qui par défaut est à "NO" et mettez-la à "YES" :

IMAPDSTART=YES

Le fichier imapd devrait ressembler à ceci :

ADDRESS=0
PORT=143
MAXDAEMONS=40
MAXPERIP=4
PIDFILE=/var/run/imapd.pid
TCPDOPTS="-nodnslookup -noidentlookup"
LOGGEROPTS="-name=imapd"
IMAP_CAPABILITY="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE"
IMAP_KEYWORDS=1
IMAP_ACL=1
IMAP_CAPABILITY_ORIG="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA \
                                AUTH=CRAM-MD5 AUTH=CRAM-SHA1 AUTH=CRAM-SHA256 IDLE"
IMAP_PROXY=0
IMAP_PROXY_FOREIGN=0
IMAP_IDLE_TIMEOUT=60
IMAP_CAPABILITY_TLS="$IMAP_CAPABILITY AUTH=PLAIN"
IMAP_CAPABILITY_TLS_ORIG="$IMAP_CAPABILITY_ORIG AUTH=PLAIN"
IMAP_DISABLETHREADSORT=0
IMAP_CHECK_ALL_FOLDERS=0
IMAP_OBSOLETE_CLIENT=0
IMAP_UMASK=022
IMAP_ULIMITD=65536
IMAP_USELOCKS=1
IMAP_SHAREDINDEXFILE=/etc/courier/shared/index
IMAP_ENHANCEDIDLE=0
IMAP_TRASHFOLDERNAME=Trash
IMAP_EMPTYTRASH=Trash:7
IMAP_MOVE_EXPUNGE_TO_TRASH=0
SENDMAIL=/usr/sbin/sendmail
HEADERFROM=X-IMAP-Sender
IMAPDSTART=YES

Essais

cp courier-imap.sysvinit /etc/init.d/courier-imap
chmod 755 /etc/init.d/courier-imap
/etc/init.d/courier-imap start

Il ne devrait pas y avoir de problème :

# netstat -a | grep :imap
tcp        0      0 *:imap2                 *:*                     LISTEN

Et allons voir avec notre sylpheed-claws s'il est possible d'accéder en IMAP.

Un petit message, d'abord, pour qu'il y ait quelque chose dans la boîte :

janus:~# mail postmaster@maison.mrs
Subject: test courier-imap
Ca marche !
.
Cc:

Et dans sylpheed-claws :

postmaster

Et en imap, nous pouvons créer sur les serveur des dossiers de classement de nos messages :

postmaster

L'avantage du format Maildir, c'est qu'il est possible de créer plusieurs niveaux de sous-répertoires. Voyons ce que ceci a donné du côté de Vpopmail :

janus:/home/vpopmail/domains/maison.mrs/postmaster/Maildir# ls -l
total 12
-rw------- 1 vpopmail vchkpw 45 2006-03-02 14:58 1141307937.qw
drwx------ 2 vpopmail vchkpw 93 2006-03-18 17:10 courierimapkeywords
-rw-r--r-- 1 vpopmail vchkpw 23 2006-02-25 18:55 courierimapsubscribed
-rw-r--r-- 1 vpopmail vchkpw 45 2006-03-18 17:03 courierimapuiddb
drwx------ 2 vpopmail vchkpw 44 2006-03-18 17:03 cur
drwx------ 2 vpopmail vchkpw 6 2006-03-18 17:03 new
drwx------ 2 vpopmail vchkpw 6 2006-03-18 17:10 tmp

Mais où sont les répertoires créés ?

janus:/home/vpopmail/domains/maison.mrs/postmaster/Maildir# ls -la
total 16
drwx------ 13 vpopmail vchkpw 4096 2006-03-18 17:10 .
drwx------ 3 vpopmail vchkpw 35 2006-02-25 16:22 ..
-rw------- 1 vpopmail vchkpw 45 2006-03-02 14:58 1141307937.qw
drwx------ 6 vpopmail vchkpw 103 2006-03-18 17:10 .Archives
drwx------ 5 vpopmail vchkpw 77 2006-03-18 17:10 .Archives.2005
drwx------ 5 vpopmail vchkpw 77 2006-03-18 17:10 .Archives.2006
drwx------ 2 vpopmail vchkpw 93 2006-03-18 17:10 courierimapkeywords
-rw-r--r-- 1 vpopmail vchkpw 23 2006-02-25 18:55 courierimapsubscribed
-rw-r--r-- 1 vpopmail vchkpw 45 2006-03-18 17:03 courierimapuiddb
drwx------ 2 vpopmail vchkpw 44 2006-03-18 17:03 cur
drwx------ 6 vpopmail vchkpw 103 2006-03-18 17:00 .Drafts
drwx------ 2 vpopmail vchkpw 6 2006-03-18 17:03 new
drwx------ 6 vpopmail vchkpw 103 2006-03-18 17:00 .Queue
drwx------ 6 vpopmail vchkpw 126 2006-03-18 17:01 .Sent
drwx------ 2 vpopmail vchkpw 6 2006-03-18 17:10 tmp
drwx------ 6 vpopmail vchkpw 126 2006-03-18 17:01 .Trash

Ils sont cachés...

Nous avons bien avancé, mais nous n'avons à priori aucun système de chiffrement. Pour la suite de la configuration, il nous faut regarder de plus près le fichier imapd-ssl.

SSLPORT=993
SSLADDRESS=0
SSLPIDFILE=/var/run/imapd-ssl.pid
SSLLOGGEROPTS="-name=imapd-ssl"
IMAPDSSLSTART=YES
IMAPDSTARTTLS=YES
IMAP_TLS_REQUIRED=0
COURIERTLS=/usr/lib/courier-imap/bin/couriertls
TLS_PROTOCOL=SSL3
TLS_STARTTLS_PROTOCOL=TLS1
TLS_CERTFILE=/usr/lib/courier-imap/share/imapd.pem
TLS_VERIFYPEER=NONE
TLS_CACHEFILE=/usr/lib/courier-imap/var/couriersslcache
TLS_CACHESIZE=524288
MAILDIRPATH=Maildir

Le certificat imapd.pem

Ce certificat a été créé lors de l'installation, mais avec des informations qui vont empoisonner les clients. Sans aller jusqu'à créer un certificat signé par une autorité, nous pouvons tout de même recréer un nouveau certificat auto signé, avec au moins le nom du serveur que vos clients emploieront.

Editez le fichier /etc/courier/imapd.cnf pour qu'il ressemble à quelque chose de ce genre :

RANDFILE = /usr/lib/courier-imap/share/imapd.rand

[ req ]
default_bits = 1024
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no

[ req_dn ]
C=FR
ST=PACA
L=Marseille
O=Courier Mail Server
OU=Automatically-generated IMAP SSL key
CN=janus.maison.mrs
emailAddress=postmaster@maison.mrs


[ cert_type ]
nsCertType = server
rm /usr/lib/courier-imap/share/imapd.pem
/usr/lib/courier-imap/sbin/mkimapdcert

Attention, ce certificat (ne) sera valable (qu')un an. Si vous voulez en modifier la durée, éditez le script /usr/lib/courier-imap/sbin/mkimapdcert.

Dans notre configuration, c'est l'utilisateur vpopmail qui va devoir lire le certificat. Nous devons nous assurer que ce sera possible :

chown vpopmail:vchkpw /usr/lib/courier-imap/share/imapd.pem
/etc/init.d/courier-imap restart

Vous devriez pouvoir maintenant accéder en IMAP "simple", en IMAP "TLS" (port 143) ou encore en IMAP "SSL" (port 995).

Démarrage par les daemontools

Vous préfèrerez peut-être confier la supervision du daemon d'authentification aux daemontools. Dans ce cas, le plus simple est d'utiliser les scripts de jms.

Courier-authlib

cd /usr/local/src/tar
wget http://qmail.jms1.net/scripts/service-courier-authlib-run
mkdir -m 755 /var/qmail/supervise/courier-authlib
cp service-courier-authlib-run /var/qmail/supervise/courier-authlib/run
chmod 755 /var/qmail/supervise/courier-authlib/run

Ce script contient initialement ceci :

#! /bin/sh
#
# service-courier-authlib-run
# John Simpson <jms1@jms1.net> 2006-03-09
#
# "run" script for making courier-authlib run under daemontools
#
###############################################################################
#
# Copyright (C) 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
#
###############################################################################

conf="/etc/authlib/authdaemonrc"
prog="/usr/libexec/courier-authlib/authdaemond"

if [ ! -f $conf ]
then
        echo $conf does not exist
        sleep 5
        exit 1
fi

if [ ! -e $prog ]
then
        echo $prog does not exist or is not executable
        sleep 5
        exit 1
fi

set -a
. $conf
exec $prog 2>&1

echo exec $prog failed
sleep 5
exit 1

Mais dans notre configuration, les variables surlignées sont à modifier comme suit :

conf="/etc/courier/authlib/authdaemonrc"
prog="/usr/local/libexec/courier-authlib/authdaemond"

Pour les logs :

mkdir -m 755 /var/qmail/supervise/courier-authlib/log
cp service-any-log-run /var/qmail/supervise/courier-authlib/log/run
chmod 755 /var/qmail/supervise/courier-authlib/log/run

Et faisons démarrer le tout :

ln -s /var/qmail/supervise/courier-authlib /service/

Courier-imap

Là encore, une fois, jms va nous aider à le faire. Attention toutefois, si le script sysvinit gère à lui seul les serveurs imapd et imapd-ssl, avec les daemontools, il faudra les gérer séparément :

pour imapd

cd /usr/local/src/tar
wget http://qmail.jms1.net/scripts/service-imap-run
mkdir -m 755 /var/qmail/supervise/courier-imap
cp service-courier-imap-run /var/qmail/supervise/courier-imap/run
chmod 755 /var/qmail/supervise/courier-imap/run

Voici le script initial :

#!/bin/sh
#
# service-imap-run
# John Simpson <jms1@jms1.net> 2005-11-24
#
###############################################################################
#
# Copyright (C) 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
#
###############################################################################

exec 2>&1
set -a		# causes all shell variables to be exported
		# may be an issue if /bin/sh is not bash

prefix=/usr/lib/courier-imap
exec_prefix=/usr/lib/courier-imap
bindir=${exec_prefix}/bin
libexecdir=/usr/lib/courier-imap/libexec

TLS_CACHEFILE=""
. ${prefix}/etc/imapd-ssl
. ${prefix}/etc/imapd

# un-comment this section ONLY if you are using courier-imap 3.x or earlier
#LIBAUTHMODULES=""
#for f in `echo $AUTHMODULES`
#do
#	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/libexec/authlib/$f"
#done

# any overrides can be done here
#ADDRESS=
#PORT=

exec tcpserver -v -c 40 -R $ADDRESS $PORT \
	${exec_prefix}/sbin/imaplogin	\
	$LIBAUTHMODULES 		\
	${exec_prefix}/bin/imapd Maildir

Compte tenu de notre configuration, ce script ne peut être utilisé en l'état, d'autant qu'il ne permet pas l'usage de la commande StartTLS. En voici une version modifiée en fonction de notre installation :

#!/bin/sh
#
# service-imap-run
# John Simpson <jms1@jms1.net> 2005-11-24
#
###############################################################################
#
# Copyright (C) 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
#
###############################################################################
#
# Modified by Christian Caleca <prof@grenouille.com> 2006-04-23
#
# Use only with courier-imap-4.x or later
#

exec 2>&1
set -a # causes all shell variables to be exported
# may be an issue if /bin/sh is not bash

sysconf_dir=/etc/courier
exec_prefix=/usr/lib/courier-imap
bindir=${exec_prefix}/bin
libexecdir=/usr/lib/courier-imap/libexec

TLS_CACHEFILE=""
. ${sysconf_dir}/imapd-ssl
. ${sysconf_dir}/imapd

USERID=`id -u vpopmail`
GROUPID=`id -g vpopmail`

# any overrides can be done here
#ADDRESS=
#PORT=

# for startTLS support
export IMAP_STARTTLS=$IMAPDSTARTTLS
export TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL


exec tcpserver -v -c 40 -R -u"$USERID" -g"$GROUPID" $ADDRESS $PORT \
${exec_prefix}/sbin/imaplogin \
${exec_prefix}/bin/imapd Maildir

Copions le script précédent dans le fichier /var/qmail/supervise/courier-imap/run et gérons les logs :

cp /usr/local/src/tar/service-any-log-run /var/qmail/supervise/courier-imap/log/run
chmod 755 /var/qmail/supervise/courier-imap/log/run

Et finalement, créons le lien pour faire démarrer le service :

ln -s /var/qmail/supervise/courier-imap /service/

Pour imapd-ssl

Le script fourni pad jms est le suivant :

#!/bin/sh
#
# service-imapssl-run
# John Simpson <jms1@jms1.net> 2005-11-24
#
###############################################################################
#
# Copyright (C) 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
#
###############################################################################

exec 2>&1
set -a		# causes all shell variables to be exported
		# may be an issue if /bin/sh is not bash

prefix=/usr/lib/courier-imap
exec_prefix=/usr/lib/courier-imap
bindir=${exec_prefix}/bin
libexecdir=/usr/lib/courier-imap/libexec

TLS_CACHEFILE=""
. ${prefix}/etc/imapd
. ${prefix}/etc/imapd-ssl

# un-comment this section ONLY if you are using courier-imap 3.x or earlier
#LIBAUTHMODULES=""
#for f in `echo $AUTHMODULES`
#do
#	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/libexec/authlib/$f"
#done

# overrides can be done here
#SSLADDRESS=
#SSLPORT=
#IMAPDSSLSTART=
#IMAPDSTARTTLS=
#IMAP_TLS_REQUIRED=

if test "$TLS_CACHEFILE" != ""
then
	rm -f $TLS_CACHEFILE
fi

export IMAP_TLS=1

ulimit -v $IMAP_ULIMITD

exec tcpserver -v -c $MAXDAEMONS -R $SSLADDRESS $SSLPORT \
	$COURIERTLS -server -tcpd	\
	${exec_prefix}/sbin/imaplogin	\
	$LIBAUTHMODULES			\
	${exec_prefix}/bin/imapd Maildir

Ici encore, nous devons quelque peu le modifier :

#!/bin/sh
#
# service-imapssl-run
# John Simpson <jms1@jms1.net> 2005-11-24
#
###############################################################################
#
# Copyright (C) 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
#
###############################################################################
#
# Modified by Christian Caleca <prof@grenouille.com> 2006-04-23
#
# Use only with courier-imap-4.x or later
#

exec 2>&1
set -a # causes all shell variables to be exported
# may be an issue if /bin/sh is not bash

sysconf_dir=/etc/courier
exec_prefix=/usr/lib/courier-imap
bindir=${exec_prefix}/bin
libexecdir=/usr/lib/courier-imap/libexec

TLS_CACHEFILE=""
. ${sysconf_dir}/imapd-ssl
. ${sysconf_dir}/imapd

USERID=`id -u vpopmail`
GROUPID=`id -g vpopmail`

# overrides can be done here
#SSLADDRESS=
#SSLPORT=
#IMAPDSSLSTART=
#IMAPDSTARTTLS=
#IMAP_TLS_REQUIRED=

if test "$TLS_CACHEFILE" != ""
then
rm -f $TLS_CACHEFILE
fi

export IMAP_TLS=1

ulimit -v $IMAP_ULIMITD

exec tcpserver -v -c $MAXDAEMONS -R -u"$USERID" -g"$GROUPID" $SSLADDRESS $SSLPORT \
$COURIERTLS -server -tcpd \
${exec_prefix}/sbin/imaplogin \
${exec_prefix}/bin/imapd Maildir

Créons l'arborescence nécessaire :

mkdir -p /var/qmail/supervise/courier-imap-ssl/log

Copions le script précédent dans le fichier /var/qmail/supervise/courier-imap-ssl/run, puis :

chmod 755 /var/qmail/supervise/courier-imap-ssl/run
cp /usr/local/src/tar/service-any-log-run /var/qmail/supervise/courier-imap-ssl/log/run
chmod 755 /var/qmail/supervise/courier-imap-ssl/log/run

Et finalement, créons le lien pour faire démarrer le service :

ln -s /var/qmail/supervise/courier-imap-ssl /service/

Une vérification comme une autre :

# netstat -a | grep :imap
tcp        0      0 *:imaps                 *:*                     LISTEN
tcp        0      0 *:imap2                 *:*                     LISTEN

Notre serveur IMAP devrait fonctionner dans tous les modes.


Précédente ] [ Accueil ] [ Suivante ]