FreeBSD: Dovecot-Sieve muss vor Postfix installiert werden, sonst wird Dovecot ohne Sieve-Unterstützung als Abhängigkeit automatisch installiert!
portinstall -prO mail/dovecot-sieve
This port assumes you are familiar with Dovecot and have it installed and running on the system you have installed this plugin on.
You can enable the plugin with this directive in your dovecot.conf:
protocol lda {
# Support for dynamically loadable plugins. mail_plugins is
# a space separated list of plugins to load.
mail_plugins = sieve # ... other plugins like quota
}
Further information on configuration can be found at:
http://Wiki.Dovecot.org/LDA/Sieve
#!/bin/bash
RECHNERNAME="$(hostname -f)"
EMAIL="email@adresse.de"
STAAT="DE"
LAND="Hessen"
STADT="Frankfurt"
ORGANISATION="Firma"
ABTEILUNG="Abteilung"
ZEITRAUM="12000" # Gültigkeitszeitraum
BITLANG="16384" # Schlüssellänge
openssl req -rand /dev/urandom -sha1 -new -x509 -newkey rsa:${BITLANG} -nodes -keyout /etc/ssl/private/dovecot.pem -keyform PEM -out /etc/ssl/certs/dovecot.pem -outform PEM -subj "/emailAddress=${EMAIL}/C=${STAAT}/ST=${LAND}/L=${STADT}/O=${ORGANISATION}/OU=${ABTEILUNG}/CN=${RECHNERNAME}" -days ${ZEITRAUM}
if [ -r "/etc/ssl/private/dovecot.pem" ] ; then
echo "/etc/ssl/private/dovecot.pem $(openssl rsa -noout -modulus -in /etc/ssl/private/dovecot.pem | openssl md5)"
fi
if [ -r "/etc/ssl/certs/dovecot.pem" ] ; then
echo "/etc/ssl/certs/dovecot.pem $(openssl x509 -noout -modulus -in /etc/ssl/certs/dovecot.pem | openssl md5)"
openssl x509 -noout -subject -issuer -dates -in /etc/ssl/certs/dovecot.pem
fi
> vi /etc/dovecot/dovecot.conf
... ssl = yes disable_plaintext_auth = no ssl_key_file = /etc/ssl/private/dovecot.pem ssl_cert_file = /etc/ssl/certs/dovecot.pem mail_location = maildir:~/Maildir maildir_copy_with_hardlinks = yes mail_access_groups = mail
> vi /etc/dovecot/conf.d/10-ssl.conf
... ssl_key = </etc/ssl/private/dovecot.pem ssl_cert = </etc/ssl/certs/dovecot.pem ...
> vi /etc/dovecot/conf.d/10-mail.conf
... mail_location = maildir:~/Maildir maildir_copy_with_hardlinks = yes mail_access_groups = mail ...
Diese Informationen finden Sie in der aktuellen Version in FreeBSD unter /usr/local/share/doc/dovecot/wiki
> telnet erde 143 Trying 192.168.2.1... Connected to erde.lan. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready. a login fritz geheimespasswort a OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in
> openssl s_client -starttls imap -connect mail.domain.de:imap
...
---
SSL handshake has read 2059 bytes and written 345 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1
Cipher : DHE-RSA-AES256-SHA
Session-ID: 86CB36C8E92940338EAEBEE527A3F405EC59DDE3BA8EEECCEE53936125F482D2
Session-ID-ctx:
Master-Key: E4E56A1ABB2DB18B40B8D35A4063F707FD21D3E9FB8DF4CC8F1D7BB0AB37F3906E0A0755AC2B429226D0BDB8624F06FE
Key-Arg : None
Start Time: 1381866348
Timeout : 300 (sec)
Verify return code: 18 (self signed certificate)
---
. OK Pre-login capabilities listed, post-login capabilities have more.
DONE
Eine sehr häufige Fehlerquelle, bei der Einrichtung von Dovecot + Postfix wobei Dovecot-SASL zur Authentifizierung verwendet wird, ist das User-Modell von Dovecot. Zumindest, wenn man mit mehr als einem User arbeiten möchte. Hier werden drei verschiedenen User benötigt.
dovecot wird für interne Aufgaben verwendet. Er sollte keinen Zugriff auf Dateien oder irgend etwas anderes haben. Dieser User sollte komplett isoliert sein. Er sollte nur zu seiner dovecot-Gruppe gehören, zu der niemand sonst gehören sollte. Diese Gruppe sollte keinen Zugriff auf Dateien oder irgend etwas anderes haben, außer zu den internen Dingen, die Dovecot selber erstellt.
dovecot wird für keinerlei Mailprozess verwendet - speichere niemals die User-Mails unter dem User dovecot und fühge den dovecot-User zu keiner keiner anderen Gruppe hinzu, auch nicht zur Gruppe "mail".
Du kannst einen oder mehrere Systemuser für den Zugriff auf die User-Mails verwenden. Die gebräuchlichen Konfigurationen können in zwei Kategorien unterteilt werden:
Wie auch immer, es ist auch möglich jede Konfiguration zu fahren, die zwischen diesen beiden Kategorien liegt. Zum Beispiel ist es auch möglich für jede Domain einen eigenen System-User zu verwenden.
Dovecot's user-Datenbank (siehe UserDatabase.txt) konfiguriert die Aufrufe der UIDs von den System-Usern. Hierüber gibt es noch einige wissenswerte Dinge:
System-Gruppen (GIDs) arbeiten sehr ähnlich zu dem, wie es bei den UIDs beschrieben wurde: Du kannst Namen an Stelle von nummerischen IDs verwenden und die verwendete GID muss nicht in der "/etc/group" stehen.
System-Gruppen sind nützlich, denn wenn sich mehrere User eine Mailbox teilen wollen, dann brauchen sie nur der selben Gruppe anzugehören. Zur Zeit stellt Dovecot nichts besonderes mit den GIDs an, also kannst Du alle User in eine einzige Gruppe packen oder auch jedem seine eigene Gruppe geben
Benutzt Du viele UIDs und möchtest eine gemeinsame Mailbox erstellen (siehe SharedMailboxes.txt), dann setze die Gruppen sauber auf um die Konfiguration sicherer zu gestallten. Zum Beispiel hast Du zwei Gruppen und jede dieser Gruppen teilt ihre Mailbox nur mit ihren Mitgliedern, dann sollte jede dieser Gruppen eine eigene GID bekommen. Die jeweilige Mailbox muss dann der entsprechenden Gruppe gehören und die Rechte "0660" haben. So kann kein Gruppenmitglied in die Mailbox der anderen Gruppe rein sehen.
Zur Zeit unterstützt Dovecot nur das festlegen der primären Gruppe, aber wenn Deine "userdb" folgendes zurück gibt System-User <Extrafeld> (siehe UserDatabase.ExtraFields.txt), dann werden die nicht-primären Gruppe aus der "/etc/group" für den User gelesen. In einer zukünftigen Version wird es möglich sein, alle GIDs in der Konfiguration festzulegen.
auth default {
...
user = root
}
Der "auth user" legt den System-User fest, unter dem der Prozess "dovecot-auth" läuft. Dieser User muss Zugriff zur Passwortdatenbank (PasswordDatabase.txt) und Benutzerdatenbank (UserDatabase.txt) haben. Dieser Benutzer wird für nichts anderes verwendet. Normalerweise verwendet man root, da er garantiert Zugriff auf alle Passwortdatenbanken hat.
Verwendest Du eine "Virtual-User"-Konfiguration, dann gibt es wirklich keinen Grund hier root zu verwenden. Stattdessen kannst Du einen neuen "auth user" erstellen (z.B. doveauth). Wenn Du SQL oder LDAP verwendest, dann muss dieser "auth user" keinen Zugriff auf irgendwelche Konfigurationsdateien von Dovecot haben, denn Dovecot selbst läuft als root.
"PAM" (siehe PasswordDatabase.PAM.txt) und "shadow" (siehe PasswordDatabase.txt) - passdb's sind gewöhnlich so konfiguriert, dass sie die Datei "/etc/shadow" lesen. Selbst das verlangt keinen root-Zugriff, wenn man den "auth user" zur Gruppe shadow hinzufügt und die Datei "/etc/shadow" für die Gruppe lesbar ist.
dovecot -n
# 1.1.11: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.31-14-server x86_64 Ubuntu 9.10
log_timestamp: %Y-%m-%d %H:%M:%S
protocols: imap imaps pop3 pop3s
login_dir: /var/run/dovecot/login
login_executable(default): /usr/lib/dovecot/imap-login
login_executable(imap): /usr/lib/dovecot/imap-login
login_executable(pop3): /usr/lib/dovecot/pop3-login
mail_privileged_group: mail
mail_executable(default): /usr/lib/dovecot/imap
mail_executable(imap): /usr/lib/dovecot/imap
mail_executable(pop3): /usr/lib/dovecot/pop3
mail_plugin_dir(default): /usr/lib/dovecot/modules/imap
mail_plugin_dir(imap): /usr/lib/dovecot/modules/imap
mail_plugin_dir(pop3): /usr/lib/dovecot/modules/pop3
auth default:
passdb:
driver: pam
userdb:
driver: passwd
sdiff /etc/dovecot/dovecot.conf /etc/dovecot/dovecot-postfix.conf
...
protocols = imap imaps pop3 pop3s | protocols = imap pop3 imaps pop3s managesieve
...
#disable_plaintext_auth = yes | disable_plaintext_auth = yes
...
#ssl_disable = no | ssl_disable = no
...
#ssl_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem | ssl_cert_file = /etc/ssl/certs/ssl-mail.pem
#ssl_key_file = /etc/ssl/private/ssl-cert-snakeoil.key | ssl_key_file = /etc/ssl/private/ssl-mail.key
...
#ssl_cipher_list = ALL:!LOW:!SSLv2 | ssl_cipher_list = ALL:!LOW:!SSLv2:ALL:!aNULL:!ADH:!eNULL:!EXP
...
#mail_location = | mail_location = maildir:~/Maildir
...
protocol imap { protocol imap {
...
#mail_max_userip_connections = 10 | mail_max_userip_connections = 10
...
#login_greeting_capability = no | login_greeting_capability = yes
...
#imap_client_workarounds = | imap_client_workarounds = outlook-idle delay-newmail
} }
...
protocol pop3 { protocol pop3 {
...
#mail_max_userip_connections = 3 | mail_max_userip_connections = 3
...
#pop3_client_workarounds = | pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
} }
...
#protocol lda { | protocol lda {
# Address to use when sending rejection mails. # Address to use when sending rejection mails.
#postmaster_address = postmaster@example.com | postmaster_address = postmaster
# Hostname to use in various parts of sent mails, eg. in Me # Hostname to use in various parts of sent mails, eg. in Me
# Default is the system's real hostname. # Default is the system's real hostname.
#hostname = #hostname =
# Support for dynamically loadable plugins. mail_plugins is # Support for dynamically loadable plugins. mail_plugins is
# list of plugins to load. # list of plugins to load.
#mail_plugins = | mail_plugins = cmusieve
#mail_plugin_dir = /usr/lib/dovecot/modules/lda #mail_plugin_dir = /usr/lib/dovecot/modules/lda
# If user is over quota, return with temporary failure inst # If user is over quota, return with temporary failure inst
# bouncing the mail. # bouncing the mail.
#quota_full_tempfail = no | quota_full_tempfail = yes
# Format to use for logging mail deliveries. You can use va # Format to use for logging mail deliveries. You can use va
# %$ - Delivery status message (e.g. "saved to INBOX") # %$ - Delivery status message (e.g. "saved to INBOX")
# %m - Message-ID # %m - Message-ID
# %s - Subject # %s - Subject
# %f - From address # %f - From address
#deliver_log_format = msgid=%m: %$ | deliver_log_format = msgid=%m: %$
# Binary to use for sending mails. # Binary to use for sending mails.
#sendmail_path = /usr/lib/sendmail #sendmail_path = /usr/lib/sendmail
# Subject: header to use for rejection mails. You can use t # Subject: header to use for rejection mails. You can use t
# as for rejection_reason below. # as for rejection_reason below.
#rejection_subject = Automatically rejected mail #rejection_subject = Automatically rejected mail
# Human readable error message for rejection mails. You can # Human readable error message for rejection mails. You can
# %n = CRLF, %r = reason, %s = original subject, %t = reci # %n = CRLF, %r = reason, %s = original subject, %t = reci
#rejection_reason = Your message to <%t> was automatically | rejection_reason = Your message to <%t> was automatically r
# UNIX socket path to master authentication server to find # UNIX socket path to master authentication server to find
#auth_socket_path = /var/run/dovecot/auth-master #auth_socket_path = /var/run/dovecot/auth-master
#} | }
...
#auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL | auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM
...
auth default { auth default {
...
mechanisms = plain | mechanisms = plain login
...
#socket listen { | socket listen {
#master { #master {
# Master socket provides access to userdb information. # Master socket provides access to userdb information.
# used to give Dovecot's local delivery agent access to # used to give Dovecot's local delivery agent access to
# can find mailbox locations. # can find mailbox locations.
#path = /var/run/dovecot/auth-master #path = /var/run/dovecot/auth-master
#mode = 0600 #mode = 0600
# Default user/group is the one who started dovecot-aut # Default user/group is the one who started dovecot-aut
#user = #user =
#group = #group =
#} #}
#client { | client {
# The client socket is generally safe to export to ever # The client socket is generally safe to export to ever
# is to export it to your SMTP server so it can do SMTP # is to export it to your SMTP server so it can do SMTP
# using it. # using it.
#path = /var/run/dovecot/auth-client | path = /var/spool/postfix/private/dovecot-auth
#mode = 0660 | mode = 0660
#} | user = postfix
#} | group = postfix
> }
> }
} }
am Ende der Datei geben wir die gewünschten Protokolle an sowie den Pfad zu den Schlüsseln:
> vi /etc/dovecot/dovecot.conf ... protocols = imap sieve ssl_key = </etc/ssl/private/dovecot.pem ssl_cert = </etc/ssl/certs/dovecot.pem mail_location = maildir:~/Maildir maildir_copy_with_hardlinks = yes
hier wird der unverschlüsselte IMAP-Port deaktiviert, SSL eingeschaltet und der verschlüsselte IMAPS-Port aktiviert:
> vi /etc/dovecot/conf.d/10-master.conf
...
service imap-login {
inet_listener imap {
#port = 143
port = 0
}
inet_listener imaps {
port = 993
ssl = yes
}
...