217 lines
5.9 KiB
Markdown
217 lines
5.9 KiB
Markdown
**Cette page a été importée automatiquement de notre ancien wiki mais n'a pas encore été révisée.**
|
|
|
|
## Howto Amavis
|
|
|
|
~~~
|
|
# apt install amavisd-new arc arj zoo pax bzip2 cabextract rpm lzop clamav-daemon
|
|
~~~
|
|
|
|
La configuration se trouve dans _/etc/amavis/conf.d/_ et se modifie/surcharge (autant que possible) dans le fichier _50-user_.
|
|
Voici les directives que l'on pourra modifier :
|
|
|
|
~~~
|
|
# Correction d'un bug sous Lenny
|
|
$mailfrom_notify_admin = "postmaster\@$mydomain";
|
|
$mailfrom_notify_recip = "postmaster\@$mydomain";
|
|
$mailfrom_notify_spamadmin = "postmaster\@$mydomain";
|
|
|
|
# Liste des domaines considérés comme locaux
|
|
#@local_domains_acl = qw(.);
|
|
@local_domains_acl = (".example.net","example.com");
|
|
|
|
# On customise la ligne ajoutée dans les entêtes
|
|
$X_HEADER_LINE = "by Amavis at $mydomain";
|
|
|
|
# Notifications de fichiers bannis / virus
|
|
$virus_admin = "postmaster\@$mydomain";
|
|
|
|
# Pour recevoir des bounces (mails originals) des fichiers bloqués / virus
|
|
#$banned_quarantine_to = "banned\@$mydomain";
|
|
#$virus_quarantine_to = "virus\@$mydomain";
|
|
|
|
# Note tueuse
|
|
$sa_tag2_level_deflt = 6.31;
|
|
# Pour un comportement "normal" de SA
|
|
$sa_tag_level_deflt = -1999;
|
|
$sa_kill_level_deflt = 1999;
|
|
$sa_dsn_cutoff_level = -99;
|
|
$sa_spam_subject_tag = '[SPAM]';
|
|
|
|
# log
|
|
$log_level = 2;
|
|
|
|
# En fonction besoin/ressources, on a juste le nbre de process
|
|
$max_servers = 10;
|
|
|
|
~~~
|
|
|
|
Le comportement des notifications par défaut est de :
|
|
|
|
* notifier l'expéditeur (?) et $virus_admin lors de la présence d'un fichier banni, mail non délivré
|
|
* notifier $virus_admin lors de la présence d'un virus, mail non délivré
|
|
* Évidemment pour les spams, personne n'est notifié
|
|
|
|
Note : Si le domaine de l'expéditeur est dans @local_domains_acl, alors l'expéditeur est toujours notifié !
|
|
|
|
Pour activer l'antivirus et/ou l'antispam, on décommentera les lignes adéquats dans le fichier _15-content_filter_mode_...
|
|
|
|
Avant d'activer l'antivirus ClamAV, on ajoutera l'utilisateur _clamav_ dans le groupe _amavis_ pour autoriser clamd à lire dans /var/lib/amavis
|
|
et l'inverse pour autoriser amavisd à lancer clamscan (et lire dans /var/lib/clamav) :
|
|
|
|
~~~
|
|
# adduser clamav amavis
|
|
# adduser amavis clamav
|
|
~~~
|
|
|
|
Il faut aussi modifier ce paramètre dans /etc/clamav/clamd.conf :
|
|
|
|
~~~
|
|
AllowSupplementaryGroups true
|
|
~~~
|
|
|
|
Pour activer Amavis avec Postfix, on ajoutera dans le fichier _master.cf_ :
|
|
|
|
~~~
|
|
smtp-amavis unix - - y - 2 lmtp
|
|
-o lmtp_data_done_timeout=1200
|
|
-o lmtp_send_xforward_command=yes
|
|
|
|
127.0.0.1:10025 inet n - y - - smtpd
|
|
-o content_filter=
|
|
-o local_recipient_maps=
|
|
-o relay_recipient_maps=
|
|
-o smtpd_restriction_classes=
|
|
-o smtpd_delay_reject=no
|
|
-o smtpd_client_restrictions=permit_mynetworks,reject
|
|
-o smtpd_helo_restrictions=
|
|
-o smtpd_sender_restrictions=
|
|
-o smtpd_recipient_restrictions=permit_mynetworks,reject
|
|
-o smtpd_data_restrictions=reject_unauth_pipelining
|
|
-o smtpd_end_of_data_restrictions=
|
|
-o mynetworks=127.0.0.0/8
|
|
-o strict_rfc821_envelopes=yes
|
|
-o smtpd_error_sleep_time=0
|
|
-o smtpd_soft_error_limit=1001
|
|
-o smtpd_hard_error_limit=1000
|
|
-o smtpd_client_connection_count_limit=0
|
|
-o smtpd_client_connection_rate_limit=0
|
|
-o receive_override_options=no_header_body_checks,no_unknown_recipient_checks
|
|
|
|
pre-cleanup unix n - n - 0 cleanup
|
|
-o virtual_alias_maps=
|
|
-o canonical_maps=
|
|
-o sender_canonical_maps=
|
|
-o recipient_canonical_maps=
|
|
-o masquerade_domains=
|
|
-o always_bcc=
|
|
-o sender_bcc_maps=
|
|
-o recipient_bcc_maps=
|
|
~~~
|
|
|
|
Pour éviter les doublons, il est conseillé d'ajouter l'option _-o cleanup_service_name=pre-cleanup_
|
|
aux services _smtp_, _cleanup_, _submission_ et _smtps_.
|
|
|
|
Et dans _main.cf_ :
|
|
|
|
~~~
|
|
content_filter = smtp-amavis:[127.0.0.1]:10024
|
|
~~~
|
|
|
|
### Ressortir un mail de quarantaine
|
|
|
|
Lorsqu'un mail est mis en quarantaine, amavisd logue un message du style :
|
|
|
|
~~~
|
|
amavis[31262]: (31262-05) Blocked BANNED [...] quarantine: 5/banned-5VspXCi2iNIn, [...]
|
|
~~~
|
|
|
|
Pour le ressortir de la quarantaine et le renvoyer au destinataire :
|
|
|
|
~~~
|
|
# amavisd-release 5/banned-5VspXCi2iNIn
|
|
~~~
|
|
|
|
#### Erreur "Can't connect to UNIX socket"
|
|
|
|
Il est possible que la chaussette d'Amavis soit située dans /var/run à la place de /var/lib, dans ce cas il suffit de modifier la socket dans /etc/amavis/conf.d/25-amavis_helpers :
|
|
|
|
~~~
|
|
$unix_socketname = "/var/lib/amavis/amavisd.sock";
|
|
~~~
|
|
|
|
### Whitelister une adresse mail
|
|
|
|
Rajouter ceci dans le fichier _/etc/amavis/conf.d/50-user_ :
|
|
|
|
~~~
|
|
@whitelist_sender_maps = ( new_RE(
|
|
qr'jdoe@example.com$'i,
|
|
));
|
|
~~~
|
|
|
|
## Intégration LDAP
|
|
|
|
Rajouter le schéma de `https://amavis.org/LDAP.schema.txt` en le convertissant en LDIF.
|
|
|
|
```
|
|
$ cd /tmp
|
|
$ wget https://amavis.org/LDAP.schema.txt
|
|
$ mkdir /tmp/ldif
|
|
$ echo 'include /tmp/LDAP.schema.txt' >> /tmp/slap.conf
|
|
# slaptest -f /tmp/slap.conf -F /tmp/ldif/
|
|
```
|
|
|
|
Changer les attributs :
|
|
|
|
```
|
|
dn: cn={0}ldap
|
|
objectClass: olcSchemaConfig
|
|
cn: {0}ldap
|
|
```
|
|
|
|
Par (avec le bon numéro `ls /etc/ldap/slapd.d/cn\=config/cn\=schema/cn\=\{*`) :
|
|
|
|
```
|
|
dn: cn={5}amavis
|
|
objectClass: olcSchemaConfig
|
|
cn: {5}amavis
|
|
```
|
|
|
|
Supprimer à la fin :
|
|
|
|
```
|
|
entryUUID: 4437d7ae-914f-1036-9cdf-cd9cc71d539a
|
|
creatorsName: cn=config
|
|
createTimestamp: 20170227154345Z
|
|
entryCSN: 20170227154345.031267Z#000000#000#000000
|
|
modifiersName: cn=config
|
|
modifyTimestamp: 20170227154345Z
|
|
```
|
|
|
|
Supprimer la ligne cr32 :
|
|
|
|
```
|
|
# CRC32 32ff7a5a
|
|
```
|
|
|
|
Le copier dans le dossier des schémas :
|
|
|
|
```
|
|
# install -v -o openldap -g openldap -m 640 /tmp/ldif/cn\=config/cn\=schema/cn\=\{0\}ldap.ldif /etc/ldap/slapd.d/cn\=config/cn\=schema/cn\=\{5\}amavis.ldif
|
|
```
|
|
|
|
Puis redémarrer slapd.
|
|
|
|
On pourra ensuite ajouter ceci dans la configuration amavis :
|
|
|
|
```
|
|
$enable_ldap = 1;
|
|
$default_ldap = {
|
|
hostname => '127.0.0.1', tls => 0,
|
|
base => 'cn=%d,dc=mail,dc=domain,dc=tld', scope => 'sub',
|
|
query_filter => '(&(mailacceptinggeneralid=%m)(accountActive=TRUE))'
|
|
};
|
|
|
|
```
|
|
|
|
> **Note**: La `query_filter` est propre au schéma Evolix. |