Installation d`un serveur de mails PostfixOpenLDAPCourier
Transcription
Installation d`un serveur de mails PostfixOpenLDAPCourier
Installation d'un serveur de mails PostfixOpenLDAPCourier V3.0 – (C) 2004 Cyril LAMY Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation license, Version 1.1 or any later version published by the Free Software Foundation; with no invariant sections, with no frontcover texts, and with no backcover texts. A copy of this license could be found at http://www.gnu.org 1 Introduction Cette documentation montre comment installer simplement un serveur de mails sous Linux (Mandrake 10 mais devrait fonctionner sans trop d'adaptations sur d'autres distributions). Les logiciels utilisés sont le serveur smtp PostFix (www.postfix.org), courierimap (www.courier mta.org) pour le serveur imap/pop et Openldap pour gerer les comptes mails. Nous fonctionnerons avec deux répertoires principaux : /usr/local/sources dans lequel nous decompacterons les sources et effectuerons les compilations et /usr/local/logiciels dans lequel s'installerons les programmes compilés. NB : Les lignes de compilations comportant un \ en fin de ligne signifient que la commande se poursuit sur la ligne suivante et que le saut de ligne n'est présent que pour des raisons de mise en page. 2 Installations des librairies DB 4.1 Télécharger les librairies Db 4.1.25 depuis www.sleepycat.com dans /usr/local/sources et les compiler : cd /usr/local/sources wget http://www.sleepycat.com/update/snapshot/db-4.1.25.tar.gz tar zxf db-4.1.25.tar.gz cd db-4.1.25 wget http://www.sleepycat.com/update/4.1.25/patch.4.1.25.1 patch -p0 < patch.4.1.25.1 cd build_unix/ ../dist/configure –prefix=/usr/local/logiciels/db4 make make install Ajouter /usr/local/logiciels/db4/lib à votre /etc/ld.so.conf et lancer ldconfig 3 Installations d'OpenLDAP Télécharger openldap depuis openldap.org dans /usr/local/sources. cd /usr/local/sources wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.1.29.tgz tar zxf openldap-2.1.29.tgz cd openldap-2.1.29 CPPFLAGS="-I/usr/local/logiciels/db4/include" \ LDFLAGS="-L/usr/local/logiciels/db4/lib" ./configure --with-threads \ --with-readline --enable-syslog --enable-aci –with-ldbm-api=berkeley \ --prefix=/usr/local/logiciels/openldap2 \ --libexecdir=/usr/local/logiciels/openldap2/sbin --enable-cleartext \ --enable-crypt –sysconfdir=/etc make depend make make install Ajouter /usr/local/logiciels/openldap2/lib dans /etc/ld.so.conf 4 Configuration d'OpenLdap Editer un fichier /etc/openldap/schema/mail.schema attributetype ( 1.3.6.1.4.1.14077.1.2.1.3 NAME 'maildrop' DESC 'Chemin de stockage des mails' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.14077.1.2.1.5 NAME 'mailquota' DESC 'quota de mails' SYNTAX 1.3.6.1.4.1.1466.115.121.1.44 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.14077.1.2.1.7 NAME 'mailforward' DESC 'Redirection de mail' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) attributetype ( 1.3.6.1.4.1.14077.1.2.1.9 NAME 'redlist' DESC 'Liste rouge' SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 ) # Definition des classes d'objet objectclass ( 1.3.6.1.4.1.14077.1.2.2.1 NAME 'mailuser' DESC 'pour le mail' MUST ( mail $ uid ) MAY ( maildrop $ mailquota $ mailforward $ redlist) ) objectclass ( 1.3.6.1.4.1.14077.1.2.2.11 NAME 'mailperson' DESC 'Un utilisateur de mail et pam' SUP ( person $ top $ organizationalPerson $ mailuser ) STRUCTURAL MUST ( uid $ mail $ sn $ givenname $ cn $ userPassword ) MAY ( mailquota $ loginShell $ uidNumber $ gidNumber $ homedirectory $ redlist $ gecos $ telephonenumber $ maildrop $ mailforward $ mailquota ) ) Nous allons gerer un arbre dc=mondomaine,dc=org. Editer le fichier /etc/openldap/slapd.conf : # See slapd.conf(5) for details on configuration options. # This file should NOT be world readable. # include /etc/openldap/schema/core.schema include /etc/openldap/schema/cosine.schema include /etc/openldap/schema/inetorgperson.schema include /etc/openldap/schema/nis.schema include /etc/openldap/schema/openldap.schema include /etc/openldap/schema/mail.schema # Define global ACLs to disable default read access. # Do not enable referrals until AFTER you have a working directory # service AND an understanding of referrals. #referral ldap://root.openldap.org pidfile argsfile /usr/local/logiciels/openldap2/var/slapd.pid /usr/local/logiciels/openldap2/var/slapd.args ####################################################################### # ldbm database definitions ####################################################################### database suffix rootdn bdb "dc=mondomaine,dc=org" "cn=Admin,dc=mondomaine,dc=org" # Cleartext passwords, especially for the rootdn, should # be avoid. See slappasswd(8) and slapd.conf(5) for details. # Use of strong authentication encouraged. rootpw secret # The database directory MUST exist prior to running slapd AND # should only be accessible by the slapd and slap tools. # Mode 700 recommended. directory /usr/local/logiciels/openldap2/var/openldap-data # Indices to maintain index objectClass eq index mail eq access to attr=userPassword by self write by anonymous auth by dn="cn=Admin,dc=mondomaine,dc=org" write access to * by dn="cn=Admin,dc=mondomaine,dc=org" write by * read allow bind_v2 Il nous reste a fixer un mot de passe pour l'admin. Editer un fichier generecrypt.pl : #!/usr/bin/perl # Ce script permet de crypter un mot de passe pour openldap $decode = <STDIN>; chomp($decode); $salt = ''; $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]; $pwd=crypt($decode,$salt); printf "{crypt}$pwd\n"; Le lancer, rentrer un mot de passe pour l'administrateur ldap et valider et remplacer dans le fichier / etc/openldap/slapd.conf la ligne rootpw secret Par le résultat obtenu via le script perl. Exemple : rootpw {crypt}dOewO.u0fCroQ Nous allons ensuite éditer le fichier arbre.ldif et y inserer deux utilisateurs. dn: dc=mondomaine,dc=org objectClass: top objectClass: Organization objectClass: dcObject dc: mondomaine o: Mon organisation structuralObjectClass: Organization dn: uid=toto1,dc=mondomaine,dc=org objectClass: top objectClass: mailperson cn: Monsieur Toto sn: Toto uid: toto1 mail: [email protected] maildrop: /mail/toto1/ mailquota: 10000000 givenName: Monsieur redlist: 0 userpassword: {crypt}PkOHQB5goa5CY dn: uid=toto2,dc=mondomaine,dc=org objectClass: top objectClass: mailperson cn: Madame Toto sn: Toto uid: toto2 mail: [email protected] maildrop: /mail/toto2/ mailquota: 10000000 givenName: Madame redlist: 0 userpassword: {crypt}itsQBuDmTms66 Intégrons le fichier arbre.ldif et lançons openldap : /usr/local/logiciels/openldap2/sbin/slapadd -f /etc/openldap/slapd.conf \ -l ./arbre.ldif /usr/local/logiciels/openldap2/sbin/slapd -f /etc/openldap/slapd.conf 5 Compilation de courierimap cd /usr/local/sources/ wget http://umn.dl.sourceforge.net/sourceforge/courier/courier-imap3.0.3.tar.bz2 tar jxf courier-imap-3.0.3.tar.bz2 wget ftp://ftp.gnu.vbs.at/gdbm/gdbm-1.8.3.tar.gz tar zxf gdbm-1.8.3.tar.gz cd cd gdbm-1.8.3 ./configure make make install Ajouter /usr/local/lib/ dans /etc/ld.so.conf et lancer ldconfig cd .. wget http://www.openssl.org/source/openssl-0.9.7d.tar.gz tar zxf openssl-0.9.7d.tar.gz cd openssl-0.9.7d ./config make make install cd ../courier-imap-3.0.3 CPPFLAGS="-I/usr/local/logiciels/openldap2/include/ \ -I/usr/local/ssl/include/" \ LDFLAGS="-L/usr/local/ssl/lib \ -L/usr/local/logiciels/openldap2/lib" \ ./configure --prefix=/usr/local/logiciels/courier-imap --without-authmysql \ --without-authpgsql --without-authpwd --without-authshadow --without-authpam \ --without-authcram --without-authvchkpw --without-authdaemon –with-authldap \ –enable-unicode --enable-workarounds-for-imap-client-bugs \ --disable-root-check –with-redhat make make install 6. Création automatique des comptes mails Il est intéressant de pouvoir créer automatiquement les maildirs des utilisateurs. Pour cela, nous allons créer l'utilisateur propriétaire des maildirs que nous appelerons vmail groupadd vmail useradd -g vmail vmail mkdir /mail chown vmail:vmail /mail Nous allons ensuite créer un script perl qui se chargera de la création des maildirs. Edition ce fichier /usr/bin/createmaildir.pl : #!/usr/bin/perl use Net::LDAP; use Socket; use Sys::Hostname; # Création des maildirs d'apres l'annuaire LDAP # Variables importantes # UID de l'utilisateur Vmail; $uid=505; #GID du groupe Vmail $gid=500; #Adresse serveur ldap $ip='127.0.0.1'; #Base de l'arbre ldap $base="dc=mondomaine,dc=org"; #Filtre de recherche $filtre="(objectclass=mailperson)"; #Chemin de mkdir $mdir="/bin/mkdir"; #Chemin de chown $cdir="/bin/chown"; #Chemin de maildirmake $maildirmake="/usr/local/logiciels/courier-imap/bin/maildirmake"; # fin des variables importantes $host = hostname(); $ldap = Net::LDAP->new( $ip ) or die "$@"; $mesg = $ldap->bind; $mesg = $ldap->search( base => $base, filter => $filtre ); $mesg->code && die $mesg->error; $now_string = localtime; print "---- Creation des maildirs ($now_string sur $host) ----\n\n"; foreach $entry ($mesg->all_entries) { $maildrop=$entry->get_value('maildrop'); $login=$entry->get_value('mail'); chomp($maildrop); if ($maildrop ne "") { if (not($maildrop =~ /.*\/$/)) { print "[ ERREUR $login ($maildrop) \n"; ] slash final manquant dans le champ maildrop de $maildrop=$maildrop."/"; } if (not(-e $maildrop)) { $cmd=$mdir." -p ".$maildrop; system($cmd); $cmd=$maildirmake." ".$maildrop."Maildir"; system($cmd); # -q 10000000S -> Quota de boite (10Mo) $cmd=$maildirmake." -q 10000000S ".$maildrop."Maildir"; system($cmd); $cmd=$cdir." -R ".$uid.":".$gid." ".$maildrop; system($cmd); printf("[ CREATE OK ] creation de boite mail $maildrop effectuee pour $login\n"); } else { printf("[ MAILDIR PRESENTE ] repertoire $maildrop de $login\n"); } } } $mesg = $ldap->unbind; print "---- fin de creation des maildirs ($now_string sur $host) ----\n\n"; Edtion la crontab du root pour que le script se lance toutes les heures : chmod +x /usr/bin/createmaildir.pl crontab -e -u root Et y rajouter la ligne : 00 * * * * /usr/bin/createmaildir.pl Pour tester le script, executons le : /usr/bin/createmaildir.pl Et nous devons avoir en sortie : ---- Creation des maildirs (Thu sur localhost) ---- [ CREATE OK ] creation de boite mail /mail/toto1/ effectuee pour [email protected] [ CREATE OK ] creation de boite mail /mail/toto2/ effectuee pour [email protected] ---- fin de creation des maildirs (Thu sur localhost) ---- Et donc avec un ls al /mail, nous voyons que les répertoires on effectivement été crées et que les boites appartiennent à l'utilisateur vmail : drwxr-xr-x 4 root root 4096 avr 1 15:01 ./ drwxr-xr-x 20 root root 4096 avr 1 14:50 ../ drwxr-xr-x 3 vmail vmail 4096 avr 1 15:01 toto1/ drwxr-xr-x 3 vmail vmail 4096 avr 1 15:01 toto2/ 7. Configuration de courierimap cd cp cp cp cp cp /usr/local/logiciels/courier-imap/etc authldaprc.dist authldaprc pop3d.dist pop3d imapd.dist imapd pop3d-ssl.dist pop3d-ssl imapd-ssl.dist imapd-ssl Et editer le fichier authldaprc : LDAP_SERVER 127.0.0.1 LDAP_PORT 389 LDAP_BASEDN dc=mondomaine, dc=org LDAP_TIMEOUT 5 LDAP_AUTHBIND 1 LDAP_MAIL mail LDAP_FILTER (objectClass=mailperson) LDAP_DOMAIN mondomaine.org LDAP_GLOB_UID vmail LDAP_GLOB_GID vmail LDAP_HOMEDIR maildrop LDAP_MAILDIRQUOTA mailquota LDAP_FULLNAME cn LDAP_CRYPTPW userPassword LDAP_DEREF never Editer le fichier pop3d : PIDFILE=/var/run/pop3d.pid MAXDAEMONS=40 MAXPERIP=4 AUTHMODULES="authldap" AUTHMODULES_ORIG="authcustom authuserdb authldap" DEBUG_LOGIN=0 POP3AUTH="" POP3AUTH_ORIG="LOGIN CRAM-MD5 CRAM-SHA1" POP3AUTH_TLS="" POP3AUTH_TLS_ORIG="LOGIN PLAIN" PORT=110 ADDRESS=0 TCPDOPTS="-nodnslookup -noidentlookup" POP3DSTART=YES MAILDIRPATH=Maildir Editer le fichier imapd : ADDRESS=0 PORT=143 MAXDAEMONS=40 MAXPERIP=4 PIDFILE=/var/run/imapd.pid TCPDOPTS="-nodnslookup -noidentlookup" AUTHMODULES="authldap" AUTHMODULES_ORIG="authcustom authuserdb authldap" DEBUG_LOGIN=0 IMAP_CAPABILITY="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE" IMAP_KEYWORDS=1 IMAP_CAPABILITY_ORIG="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA AUTH=CRAM-MD5 AUTH=CRAM-SHA1 IDLE" 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_ULIMITD=65536 IMAP_USELOCKS=1 IMAP_SHAREDINDEXFILE=/usr/local/logiciels/courier-imap/etc/shared/index IMAP_ENHANCEDIDLE=0 IMAP_TRASHFOLDERNAME=Trash IMAP_EMPTYTRASH=Trash:7 IMAP_MOVE_EXPUNGE_TO_TRASH=0 SENDMAIL=/usr/bin/sendmail HEADERFROM=X-IMAP-Sender IMAPDSTART=YES MAILDIRPATH=Maildir Test de la configuration (en bleu, les commandes tapées) : /usr/local/logiciels/courier-imap/libexec/pop3d.rc start telnet 127.0.0.1 110 Trying 127.0.0.1... Connected to localhost (127.0.0.1). Escape character is '^]'. +OK Hello there. user monsieur.toto +OK Password required. pass toto +OK logged in. quit +OK Bye-bye. Connection closed by foreign host. 8. Compilation du serveur smtp Postfix cd /usr/local/sources/ wget ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix2.0.19.tar.gz tar zxf postfix-2.0.19.tar.gz wget http://web.onda.com.br/nadal/postfix/VDA/postfix-2.0.19.patch.gz gunzip postfix-2.0.19.patch.gz patch -p0 < postfix-2.0.19.patch cd postfix-2.0.19 Editer le fichier makedefs et remplacer toutes les occurrences de /usr/include/db.h par /usr/local/logiciels/db4/include/db.h make makefiles CCARGS="-pipe -I/usr/local/logiciels/db4/include \ -L/usr/local/logiciels/db4/lib -DHAS_LDAP -DNO_PCRE \ -I/usr/local/logiciels/openldap2/include/" \ AUXLIBS="-L/usr/local/logiciels/openldap2/lib -lldap -llber -lpthread" make groupadd postfix groupadd postgrp useradd -g postfix -s /bin/false postfix sh postfix-install Aux questions, mettre les réponse par défaut sauf pour : setgid_group : postgrp sample_directory : /etc/postfix/samples readme_directory : /etc/postfix/readme 9. Configuration de postfix : Ajouter dans le fichier /etc/postfix/main.cf : myhostname = mamachine.mondomaine.org mydomain = mondomaine.org myorigin = mondomaine.org # Remplacer par vos IP mynetworks = 192.168.0.0/24, 127.0.0.1/32 mydestination = $myhostname, $mydomain, localhost.$mydomain local_transport = virtual local_recipient_maps = $virtual_mailbox_maps virtual_maps = hash:/etc/postfix/virtual,ldap:ldapforward virtual_mailbox_base = / virtual_mailbox_maps = ldap:ldapsource # uid/gid de l'utilisateur vmail virtual_minimum_uid = 505 virtual_uid_maps = static:505 virtual_gid_maps = static:500 virtual_mailbox_limit = 15000000 virtual_mailbox_limit_inbox = no virtual_mailbox_limit_maps = ldap:ldapsize virtual_mailbox_limit_override = yes virtual_maildir_extended = yes virtual_maildir_suffix = Maildir/ virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota virtual_create_maildirsize = yes virtual_mailbox_lock = fcntl ldapsource_server_host = localhost ldapsource_server_port = 389 ldapsource_search_base = dc=mondomaine,dc=org ldapsource_timeout = 10 ldapsource_query_filter = (mail=%s) ldapsource_scope = sub ldapsource_result_attribute = maildrop ldapsize_server_host = localhost ldapsize_server_port = 389 ldapsize_search_base = dc=mondomaine,dc=org ldapsize_timeout = 10 ldapsize_query_filter = (mail=%s) ldapsize_scope = sub ldapsize_result_attribute = mailquota ldapforward_server_host = localhost ldapforward_server_port = 389 ldapforward_search_base = dc=mondomaine,dc=org ldapforward_timeout = 10 ldapforward_query_filter = (mail=%s) ldapforward_scope = sub ldapforward_result_attribute = mailforward smtpd_sender_restrictions = reject_unknown_sender_domain, reject_non_fqdn_sender smtpd_client_restrictions = permit_mynetworks default_process_limit = 100 10.Lancement des services : Lancement d'openldap : /usr/local/logiciels/openldap2/sbin/slapd -f /etc/openldap/slapd.conf Lancement de postfix : postmap /etc/postfix/virtual (à faire la 1ere fois pour recompiler les alias) /usr/sbin/postfix start Lancement de courierimap : /usr/local/logiciel/courier-imap/libexec/pop3d.rc start /usr/local/logiciel/courier-imap/libexec/imapd.rc start A cet instant, le serveur mail est fonctionnel ... 11.Pour aller plus loin ... : Activation du popS et imapS : Editer le fichier /usr/local/logiciels/courierimap/etc/imapdssl : SSLPORT=993 SSLADDRESS=0 IMAPDSSLSTART=YES IMAPDSTARTTLS=YES IMAP_TLS_REQUIRED=0 COURIERTLS=/usr/local/logiciels/courier-imap/bin/couriertls TLS_PROTOCOL=SSL3 TLS_STARTTLS_PROTOCOL=TLS1 TLS_CERTFILE=/usr/local/logiciels/courier-imap/share/imapd.pem TLS_VERIFYPEER=NONE TLS_CACHEFILE=/usr/local/logiciels/courier-imap/var/couriersslcache TLS_CACHESIZE=524288 SSLPIDFILE=/var/run/imapd-ssl.pid Editer le fichier /usr/local/logiciels/courierimap/etc/pop3dssl : SSLPORT=995 SSLADDRESS=0 SSLPIDFILE=/var/run/pop3d-ssl.pid POP3DSSLSTART=YES POP3_STARTTLS=YES POP3_TLS_REQUIRED=0 COURIERTLS=/usr/local/logiciels/courier-imap/bin/couriertls TLS_PROTOCOL=SSL3 TLS_STARTTLS_PROTOCOL=TLS1 TLS_CERTFILE=/usr/local/logiciels/courier-imap/share/pop3d.pem TLS_VERIFYPEER=NONE TLS_CACHEFILE=/usr/local/logiciels/courier-imap/var/couriersslcache TLS_CACHESIZE=524288 Compléter les fichier imapd.cnf et pop3d.cnf en y mettant vos parametres pour le certificat SSL. Génerer les certificats : cd /usr/local/logiciels/courier-imap/sbin ./mkimapdcert ./mkpop3dcert Lancer les services avec : cd /usr/local/logiciels/courier-imap/libexec ./pop3d-ssl.rc start ./imapd-ssl.rc start Installation d'un antivirus : L'antivirus sera clamav (www.clamav) sous licence GPL cd /usr/local/sources wget http://www.gzip.org/zlib/zlib-1.2.1.tar.gz tar zxf zlib-1.2.1.tar.gz ./configure make make install ldconfig cd /usr/local/sources wget http://unc.dl.sourceforge.net/sourceforge/clamav/clamav-0.68.tar.gz tar zxf clamav-0.68.tar.gz groupadd clamav useradd -g clamav -s /bin/false -c "Clam Antivirus" clamav ./configure –sysconfdir=/etc make make install groupadd vscan useradd -g vscan -s /bin/false vscan touch /var/log/clam-update.log chmod 600 /var/log/clam-update.log chown clamav /var/log/clam-update.log Editer /etc/clamav.conf : ENLEVER LA COMMANDE « EXAMPLE» et ajouter une ligne : User vscan Editer la crontab du root avec la commande : crontab -e -u root Et y ajouter un ligne : 0 * * * * /usr/local/bin/freshclam --quiet -l /var/log/clam-update.log Ceci permettra de mettre a jour les signatures toutes les heures. Installation d'amavisdnew : cd /usr/local/sources wget http://www.ijs.si/software/amavisd/amavisd-new-20030616-p8.tar.gz tar zxf amavisd-new-20030616-p8.tar.gz cd amavisd-new-20030616 mkdir required cd required wget ftp://ftp.warwick.ac.uk/pub/compression/compress-4.0.1.tar.gz tar zxf compress-4.0.1.tar.gz gcc compress.c -o compress cp compress /usr/bin wget ftp://ftp.ibiblio.org/pub/Linux/utils/compress/nomarch-1.3.tar.gz tar zxf nomarch-1.3.tar.gz cd nomarch-1.3 make make install cd .. rm -rf /usr/local/sources/amavisd-new-20030616/required/* wget http://www2m.biglobe.ne.jp/~dolphin/lha/prog/lha-114i.tar.gz tar zxf lha-114i.tar.gz cd lha-114i make make install wget ftp://ftp.kiarchive.ru/pub/unix/arcers/unarj-2.43.tgz tar zxf unarj-2.43.tgz cd unarj-2.43 make cp unarj /usr/bin cd .. wget http://testcase.newmail.ru/files/arjl_310 chmod +x arjl_310 ./arjl_310 wget http://www.rarsoft.com/rar/rarlinux-3.3.0.tar.gz tar zxf rarlinux-3.3.0.tar.gz cd rar cp unrar /usr/bin cp rar /usr/bin cd /usr/local/sources/amavisd-new-20030616/required rm -rf /usr/local/sources/amavisd-new-20030616/required/* wget http://ftp.silug.org/pub/debian/pool/non-free/z/zoo/zoo_2.10.orig.tar.gz tar zxf zoo_2.10.orig.tar.gz wget http://ftp.silug.org/pub/debian/pool/non-free/z/zoo/zoo_2.10-10.diff.gz gunzip zoo_2.10-10.diff.gz patch -p0 < zoo_2.10-10.diff cd zoo-2.10.orig/ make linux cp zoo /usr/bin cp fiz /usr/bin Amavis nécessite l'installation de plusieurs modules perl : cd /usr/local/sources/amavisd-new-20030616/required rm -rf /usr/local/sources/amavisd-new-20030616/required/* wget http://search.cpan.org/CPAN/authors/id/K/KA/KANE/Archive-Tar-1.08.tar.gz tar zxf Archive-Tar-1.08.tar.gz cd Archive-Tar-1.08 perl Makefile.PL make make install cd .. wget http://www.cpan.org/authors/id/P/PM/PMQS/Compress-Zlib-1.33.tar.gz tar zxf Compress-Zlib-1.33.tar.gz cd Compress-Zlib-1.33 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/N/NE/NEDKONZ/Archive-Zip1.10.tar.gz tar zxf Archive-Zip-1.10.tar.gz cd Archive-Zip-1.10 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/E/ER/ERYQ/IO-stringy-2.109.tar.gz tar zxf IO-stringy-2.109.tar.gz cd IO-stringy-2.109 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWARTZ/Unicode-Map0.112.tar.gz tar zxf Unicode-Map-0.112.tar.gz cd Unicode-Map-0.112 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/Unicode-String2.07.tar.gz tar zxf Unicode-String-2.07.tar.gz cd Unicode-String-2.07 perl Makefile.PL make make install cd .. wget http://www.mimedefang.org/static/MIME-tools-5.411a-RP-Patched-02.tar.gz tar zxf MIME-tools-5.411a-RP-Patched-02.tar.gz cd MIME-tools-5.411a-RP-Patched-02 perl Makefile.PL make make install cd .. wget http://www.cpan.org/authors/id/D/DO/DOUGW/Convert-TNEF-0.17.tar.gz tar zxf Convert-TNEF-0.17.tar.gz cd Convert-TNEF-0.17 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/M/ML/MLEHMANN/Convert-UUlib1.01.tar.gz tar zxf Convert-UUlib-1.01.tar.gz cd Convert-UUlib-1.01 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/MIME-Base64-3.01.tar.gz tar zxf MIME-Base64-3.01.tar.gz cd MIME-Base64-3.01 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/M/MA/MARKOV/MailTools-1.62.tar.gz tar zxf MailTools-1.62.tar.gz cd MailTools-1.62 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/B/BB/BBB/Net-Server-0.87.tar.gz tar zxf Net-Server-0.87.tar.gz cd Net-Server-0.87 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/libnet-1.18.tar.gz perl Makefile.PL make make install cd .. wget http://www.cpan.org/authors/id/G/GA/GAAS/Digest-MD5-2.33.tar.gz tar zxf Digest-MD5-2.33.tar.gz cd Digest-MD5-2.33 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/J/JH/JHI/Time-HiRes-1.56.tar.gz cd Time-HiRes-1.56 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/M/MH/MHARNISCH/Syslog-0.97.tar.gz tar zxf Syslog-0.97.tar.gz cd Syslog-0.97 perl Makefile.PL make make install cd .. wget http://search.cpan.org/CPAN/authors/id/F/FE/FELICITY/Mail-SpamAssassin2.63.tar.gz tar zxf Mail-SpamAssassin-2.63.tar.gz cd Mail-SpamAssassin-2.63 perl Makefile.PL make make install cd .. mkdir /var/amavis mkdir /var/virusmails chown vscan:vscan /var/amavis/ chown vscan:vscan /var/virusmails/ cd /usr/local/sources/amavisd-new-20030616 cp amavisd.conf /etc mkdir /usr/local/logiciels/amavisd cp amavisd /usr/local/logiciels/amavisd/ chmod 755 /usr/local/logiciels/amavisd/amavisd Editer le fichier /etc/amavisd.conf et modifier : (config minimale, éditer suivant les besoins ...) $mydomain = 'mondomaine.org'; $daemon_user = 'vscan'; # (no default; $daemon_group = 'vscan'; # (no default; $final_spam_destiny = D_PASS; $sa_spam_subject_tag = '***SPAM*** '; customary: vscan or amavis) customary: vscan or amavis) Dans cette configuration, les virus seront bloqués et les spams parviendrons à leur destinataires avec un sujet modifié. Editer le fichier /etc/postfix/virtual et y ajouter : [email protected] [email protected] Et reconstruire le fichier : postmap /etc/postfix/virtual Editer le fichier /etc/postfix/master.cf (rappel : ne pas mettre les \, ils signifient de ne pas aller a la ligne) smtp-amavis unix disable_dnslookups=yes 127.0.0.1:10025 inet - n -o content_filter= - n - 2 smtp -o smtp_data_done_timeout=1200 -o \ n - - smtpd \ \ -o local_recipient_maps= \ -o relay_recipient_maps= \ -o smtpd_restriction_classes= \ -o smtpd_client_restrictions= -o smtpd_helo_restrictions= \ \ -o smtpd_sender_restrictions= \ -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 \ -o strict_rfc821_envelopes=yes Editer le fichier /etc/postfix/main.cf et y ajouter : content_filter = smtp-amavis:[127.0.0.1]:10024 Lancer amavis : /usr/local/logiciels/amavisd/amavisd -c /etc/amavisd.conf Relancer Postfix /usr/sbin/postfix stop /usr/sbin/postfix start En envoyant un mail, on voit dans les entête que le champ : XVirusScanned: by amavisdnew at mondomaine.org est rajouté, et donc qu'amavis fonctionne correctement. Installation d'un Webmail : Nous considérons que Apache+Php (avec module imap,ldap,xml,mysql)+MySql est déjà installé sur le système. cd /usr/local/sources/ wget http://ftp.horde.org/pub/horde/horde-2.2.3.tar.gz tar zxf horde-2.2.3.tar.gz mv horde-2.2.3 /var/www/html/ cd /var/www/html/ ln -s horde-2.2.3 horde cd /usr/share/ wget http://ftp.horde.org/pub/pear/pear-1.3.tar.gz tar zxf pear-1.3.tar.gz cd /var/www/html/horde/config for fichier in *.dist; do cp -v $fichier `basename $fichier .dist`; done Editer le fichier /var/www/html/horde/scripts/db/mysql_create.sql PASSWORD('motdepassehorde') Et injecter le script : mysql user=root password < mysql_create.sql Et relancer le serveur : /etc/init.d/mysql restart Editer le fichier horde.php $conf['auth']['driver'] = 'imap'; $conf['prefs']['params']['phptype'] = 'mysql'; $conf['prefs']['params']['hostspec'] = 'localhost'; $conf['prefs']['params']['username'] = 'horde'; $conf['prefs']['params']['password'] = 'motdepassehorde'; $conf['prefs']['params']['database'] = 'horde'; $conf['prefs']['params']['table'] = 'horde_prefs'; $conf['mailer']['type'] = 'smtp'; Editer le fichier lang.php $nls['defaults']['language'] = 'fr_FR'; Editer le fichier registry.php $this->registry['auth']['login'] = 'imp'; $this->registry['auth']['logout'] = 'imp'; Installation d'imp : cd /usr/local/sources/ wget ftp://ftp.horde.org/pub/imp/imp-3.2.3.tar.gz tar zxf imp-3.2.3.tar.gz mv imp-3.2.3 /var/www/html/horde ln -s imp-3.2.3 imp cd imp/config/ for fichier in *.dist; do cp -v $fichier `basename $fichier .dist`; done Editer le fichier servers.php et ne laisser qu'un serveur : $servers['imap'] = array( 'name' => 'IMAP Server', 'server' => '127.0.0.1', 'protocol' => 'imap/notls', 'port' => 143, 'folders' => 'INBOX.', 'namespace' => '', 'maildomain' => 'mondomaine.org', 'smtphost' => '127.0.0.1', 'realm' => 'mondomaine.org', 'preferred' => 'true' ); Editer le fichier /etc/httpd/conf/httpd2.conf Alias /horde /var/www/html/horde/ Alias /horde/ /var/www/html/horde/ DocumentRoot /var/www/html/horde/imp Et relancer le service : /etc/init.d/httpd restart