Benutzer-Werkzeuge

Webseiten-Werkzeuge


tachtler:dovecot_authentifizierung_-_sql

Dies ist eine alte Version des Dokuments!


Dovecot Authentifizierung - SQL

Diese Dokumentation ist nach dem Kurs: Dovecot bei www.heinlein-support.de - Peer Heinlein entstanden. Hier noch einmal meinen Dank für die Informationen und das ☛ Buch: Dovecot

:!: HINWEIS - Die Nachfolgende Konfiguration von Dovecot setzt eine lauffähige Installation von Dovecot sowie eine lauffähige Installation von Postfix Admin voraus, wie unter nachfolgenden internen Links beschrieben !!!

Dovecot ist ein Open-Source-IMAP-und POP3-E-Mail-Server für Linux bzw. UNIX-ähnlichen Systeme, entwickelt mit dem Hauptaugenmerk auf Sicherheit. Dovecot ist eine ausgezeichnete Wahl für kleine und große Installationen. Dovecot ist schnell und einfach zu installieren, erfordert keine besonderen Voraussetzungen und ist Ressourcenschonend.

Dovecot wird von Timo Sirainen entwickelt.

Beschreibung Externer Link
Homepage http://dovecot.org
Dokumentation http://dovecot.org/documentation.html
Wiki Dovecot2 http://wiki2.dovecot.org/

Ab hier werden root-Rechte zur Ausführung der nachfolgenden Befehle benötigt. Um root zu werden geben Sie bitte folgenden Befehl ein:

$ su -
Password: 

Vorbereitung

Um die Benutzer gegen eine SQL-Datenbank authentifizieren zu können, müsste logischerweise erst eine SQL-Datenbank vorhanden sein, in der auch die entsprechende Tabelle enthalten ist.

Nachfolgender externe Link beschreibt die Einrichtung von Dovecot und die Authentifizierung gegen eine SQL-Datenbank:

Beschreibung Externer Link
AuthDatabase/SQL http://wiki2.dovecot.org/AuthDatabase/SQL

Installation CentOS 6

Aber auch die im rpm-Paket - dovecot - enthaltene Beispiel-Konfigurationsdatei, gibt Hinweise, wie eine Tabelle zur Authentifizierung gegen eine SQL-Datenbank auszusehen hat.

Nachfolgender interne Link beschreibt die Installation von Dovecot unter Verwendung des ATrpms-Repositories:

Das so installierte rpm-Paket - dovecot enthält nachfolgende Beispiel-Konfigurationsdatei in nachfolgend beschriebenen Verzeichnis und mit nachfolgend beschriebenem Namen:

  • /usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext

Installation CentOS 7

Nachfolgender interne Link beschreibt die Installation von Dovecot unter Verwendung des internen Links zur Einbindung des mailserver.guru - CentOS 7-Repositories:

Nachdem das Drittanbieter-Repository

erfolgreich eingebunden wurde, kann mit nachfolgendem Befehl, das rpm-Paket - dovecot-mysql installiert werden:

# yum install dovecot-mysql
Loaded plugins: changelog, priorities
base                                                     | 3.6 kB     00:00     
epel                                                     | 4.4 kB     00:00     
extras                                                   | 3.4 kB     00:00     
mailserver.guru-os                                       | 2.9 kB     00:00     
updates                                                  | 3.4 kB     00:00     
103 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package dovecot-mysql.x86_64 1:2.2.18-1.el7.centos will be installed
--> Finished Dependency Resolution

Changes in packages about to be updated:


Dependencies Resolved

================================================================================
 Package         Arch     Version                    Repository            Size
================================================================================
Installing:
 dovecot-mysql   x86_64   1:2.2.18-1.el7.centos      mailserver.guru-os    78 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 78 k
Installed size: 19 k
Is this ok [y/d/N]: y
Downloading packages:
dovecot-mysql-2.2.18-1.el7.centos.x86_64.rpm               |  78 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:dovecot-mysql-2.2.18-1.el7.centos.x86_64                   1/1 
  Verifying  : 1:dovecot-mysql-2.2.18-1.el7.centos.x86_64                   1/1 

Installed:
  dovecot-mysql.x86_64 1:2.2.18-1.el7.centos                                    

Complete!

Mit nachfolgendem Befehl kann überprüft werden, welche Inhalte mit den Paket dovecot-mysql installiert wurden.

# rpm -qil dovecot-mysql
Name        : dovecot-mysql
Epoch       : 1
Version     : 2.2.18
Release     : 1.el7.centos
Architecture: x86_64
Install Date: Mon 13 Jul 2015 09:21:00 PM CEST
Group       : System Environment/Daemons
Size        : 19536
License     : MIT and LGPLv2
Signature   : RSA/SHA1, Thu 21 May 2015 11:19:08 PM CEST, Key ID 60ecfb9e8195aea0
Source RPM  : dovecot-2.2.18-1.el7.centos.src.rpm
Build Date  : Thu 21 May 2015 11:17:58 PM CEST
Build Host  : vml000200.dmz.nausch.org
Relocations : (not relocatable)
Packager    : Django <django@mailserver.guru>
URL         : http://www.dovecot.org/
Summary     : MySQL back end for dovecot
Description :
This package provides the MySQL back end for dovecot-auth etc.
/usr/lib64/dovecot/auth/libdriver_mysql.so
/usr/lib64/dovecot/dict/libdriver_mysql.so
/usr/lib64/dovecot/libdriver_mysql.so

Das installierte rpm-Paket - dovecot enthält dafür nachfolgende Beispiel-Konfigurationsdatei in nachfolgend beschriebenen Verzeichnis und mit nachfolgend beschriebenem Namen:

  • /usr/share/doc/dovecot-2.2.18/example-config/dovecot-sql.conf.ext

:!: HINWEIS - Nachfolgend soll jedoch NICHT die Standard-Tabelle mit einer SQL-Datenbank genutzt werden !!!

Postfix Admin

Wenn schon die Benutzerverwaltung und die Authentifizierung von Dovecot gegen eine SQL-Datenbank erfolgen soll, wäre auch eine z.B. Web-Anwendung zur Verwaltung der SQL-Datenbank von Vorteil.

Eine Möglichkeit eine Web-Anwendung zur Verwaltung der SQL-Datenbank, welche zur Authentifizierung von Dovecot genutzt werden kann einzusetzen, ist die Verwendung von Postfix Admin.

Unter nachfolgendem internen Link ist die Installation und Konfiguration von Postfix Admin beschrieben, wie sie auch hier zum Einsatz kommen soll.

:!: WICHTIG - Ohne eine Installation von Postfix Admin wie unter oben stehendem internen Link beschrieben, sind die weiteren Konfigurationen nur bedingt anwendbar !!!

Konfiguration

Konfigurationsdatei

Nach der erfolgreichen Installation von Dovecot und zur Authentifizierung gegen eine SQL-Datenbank, muss noch nachfolgende Konfigurationsdatei aus dem installierten rpm-Paket dovecot in das nachfolgende Konfigurationsverzeichnis von Dovecot kopiert werden, was mit nachfolgendem Befehl durchführt werden kann:

CentOS 6

# cp -a /usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext /etc/dovecot

CentOS 7

# cp -a /usr/share/doc/dovecot-2.2.18/example-config/dovecot-sql.conf.ext /etc/dovecot

Anschließend kann mit nachfolgendem Befehl überprüft werden, ob dies erfolgreich durchgeführt wurde:

# ls -l /etc/dovecot
total 40
drwxr-xr-x 2 root root    4096 Jul 12 09:25 conf.d
-rw-r--r-- 1 root root    4509 Jul 10 14:04 dovecot.conf
-rw-r--r-- 1 root root    4380 Jun  2  2014 dovecot.conf.orig
-rw-r--r-- 1 root root    5612 Jun  2  2014 dovecot-sql.conf.ext
-rw-r----- 1 root dovecot   41 Jul  9 13:34 master-users
-rw-r--r-- 1 root root     135 Jul 11 09:05 ssl-parameters.conf
-rw-r----- 1 root dovecot  564 Jul  9 16:49 users

/etc/dovecot/dovecot-sql.conf.ext

Bei den Einstellungen der Konfigurationsdatei, soll von nachfolgenden Gegebenheiten ausgegangen werden:

  1. Im Postfix Admin existiert eine Domain: tachtler.net
  2. Im Postfix Admin wurde ein Benutzer mit dem Benutzernamen/Mailbox klaus@tachtler.net angelegt
  3. Zur Anmeldung an Dovecot wird die e-Mail-Adresse verwendet
  4. Die Verwaltung der Postfächer (Mailbox) wird unter Zuhilfenahme eines Dummy-Benutzers (vmail) als Authentifizierungsbenutzer durchgeführt, wie unter nachfolgendem internen Link beschrieben

verwendet wird.

Nachfolgend noch einmal in einer Tabelle dargestellt

Gegebenheit Wert
Postfix Admin Domain tachtler.net
Postfix Admin Benutzer(name)/Mailbox klaus@tachtler.net
Dovecot Anmeldename klaus@tachtler.net (e-Mail-Adresse vollständig,nicht nur der localpart)
Dovecot Dummy-Benutzer (vmail) interner Link Dovecot CentOS 6 - Konfiguration Authentifizierung - Authentifizierungsbenutzer
interner Link Dovecot CentOS 7 - Konfiguration Authentifizierung - Authentifizierungsbenutzer

Normalerweise trennt Dovecot die beiden Abfragen

  • passdb - Abfrage des Benutzernamens und Passwort-Vergleich
  • userdb - Abfrage der Benutzer spezifischen Einstellung z.B. home, uid, gid, usw.

so dass auch zwei SQL-Abfragen nötig sind.

:!: WICHTIG - Hier kann jedoch optimiert werden, so dass Dovecot nur eine SQL-Abfrage benötigt, um die passdb- und userdb-Daten zu ermitteln. Dies wird mit einer Einstellung Namens prefetch erreicht.

Hier die komplette Konfigurationsdatei - /etc/dovecot/dovecot-sql.conf.ext - optimiert - (prefetch), unter Verwendung der SQL-Datenbank und der Tabellen von Postfix Admin:

# This file is commonly accessed via passdb {} or userdb {} section in
# conf.d/auth-sql.conf.ext
 
# This file is opened as root, so it should be owned by root and mode 0600.
#
# http://wiki2.dovecot.org/AuthDatabase/SQL
#
# For the sql passdb module, you'll need a database with a table that
# contains fields for at least the username and password. If you want to
# use the user@domain syntax, you might want to have a separate domain
# field as well.
#
# If your users all have the same uig/gid, and have predictable home
# directories, you can use the static userdb module to generate the home
# dir based on the username and domain. In this case, you won't need fields
# for home, uid, or gid in the database.
#
# If you prefer to use the sql userdb module, you'll want to add fields
# for home, uid, and gid. Here is an example table:
#
# CREATE TABLE users (
#     username VARCHAR(128) NOT NULL,
#     domain VARCHAR(128) NOT NULL,
#     password VARCHAR(64) NOT NULL,
#     home VARCHAR(255) NOT NULL,
#     uid INTEGER NOT NULL,
#     gid INTEGER NOT NULL,
#     active CHAR(1) DEFAULT 'Y' NOT NULL
# );
 
# Database driver: mysql, pgsql, sqlite
# Tachtler
driver = mysql
 
# Database connection string. This is driver-specific setting.
#
# HA / round-robin load-balancing is supported by giving multiple host
# settings, like: host=sql1.host.org host=sql2.host.org
#
# pgsql:
#   For available options, see the PostgreSQL documention for the
#   PQconnectdb function of libpq.
#   Use maxconns=n (default 5) to change how many connections Dovecot can
#   create to pgsql.
#
# mysql:
#   Basic options emulate PostgreSQL option names:
#     host, port, user, password, dbname
#
#   But also adds some new settings:
#     client_flags           - See MySQL manual
#     ssl_ca, ssl_ca_path    - Set either one or both to enable SSL
#     ssl_cert, ssl_key      - For sending client-side certificates to server
#     ssl_cipher             - Set minimum allowed cipher security (default: HIGH)
#     ssl_verify_server_cert - Verify that the name in the server SSL certificate
#                              matches the host (default: no)
#     option_file            - Read options from the given file instead of
#                              the default my.cnf location
#     option_group           - Read options from the given group (default: client)
# 
#   You can connect to UNIX sockets by using host: host=/var/run/mysql.sock
#   Note that currently you can't use spaces in parameters.
#
# sqlite:
#   The path to the database file.
#
# Examples:
#   connect = host=192.168.1.1 dbname=users
#   connect = host=sql.example.com dbname=virtual user=virtual password=blarg
#   connect = /etc/dovecot/authdb.sqlite
#
# Tachtler
connect = host=mysql.tachtler.net dbname=postfix user=postfixuser password=geheim
 
# Default password scheme.
#
# List of supported schemes is in
# http://wiki2.dovecot.org/Authentication/PasswordSchemes
#
#default_pass_scheme = MD5
# Tachtler
default_pass_scheme = PLAIN
 
# passdb query to retrieve the password. It can return fields:
#   password - The user's password. This field must be returned.
#   user - user@domain from the database. Needed with case-insensitive lookups.
#   username and domain - An alternative way to represent the "user" field.
#
# The "user" field is often necessary with case-insensitive lookups to avoid
# e.g. "name" and "nAme" logins creating two different mail directories. If
# your user and domain names are in separate fields, you can return "username"
# and "domain" fields instead of "user".
#
# The query can also return other fields which have a special meaning, see
# http://wiki2.dovecot.org/PasswordDatabase/ExtraFields
#
# Commonly used available substitutions (see http://wiki2.dovecot.org/Variables
# for full list):
#   %u = entire user@domain
#   %n = user part of user@domain
#   %d = domain part of user@domain
# 
# Note that these can be used only as input to SQL query. If the query outputs
# any of these substitutions, they're not touched. Otherwise it would be
# difficult to have eg. usernames containing '%' characters.
#
# Example:
#   password_query = SELECT userid AS user, pw AS password \
#     FROM users WHERE userid = '%u' AND active = 'Y'
#
#password_query = \
#  SELECT username, domain, password \
#  FROM users WHERE username = '%n' AND domain = '%d'
 
# userdb query to retrieve the user information. It can return fields:
#   uid - System UID (overrides mail_uid setting)
#   gid - System GID (overrides mail_gid setting)
#   home - Home directory
#   mail - Mail location (overrides mail_location setting)
#
# None of these are strictly required. If you use a single UID and GID, and
# home or mail directory fits to a template string, you could use userdb static
# instead. For a list of all fields that can be returned, see
# http://wiki2.dovecot.org/UserDatabase/ExtraFields
#
# Examples:
#   user_query = SELECT home, uid, gid FROM users WHERE userid = '%u'
#   user_query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%u'
#   user_query = SELECT home, 501 AS uid, 501 AS gid FROM users WHERE userid = '%u'
#
#user_query = \
#  SELECT home, uid, gid \
#  FROM users WHERE username = '%n' AND domain = '%d'
# Tachtler - CentOS 6
user_query = SELECT 10000 AS uid, 10000 as gid, '/var/spool/vmail/%Ld/%Ln' AS home, concat('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%Lu' AND active = 1
# Tachtler - CentOS 7
user_query = SELECT 10000 AS uid, 10000 as gid, '/srv/vmail/%Ld/%Ln' AS home, concat('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%Lu' AND active = 1
 
# If you wish to avoid two SQL lookups (passdb + userdb), you can use
# userdb prefetch instead of userdb sql in dovecot.conf. In that case you'll
# also have to return userdb fields in password_query prefixed with "userdb_"
# string. For example:
#password_query = \
#  SELECT userid AS user, password, \
#    home AS userdb_home, uid AS userdb_uid, gid AS userdb_gid \
#  FROM users WHERE userid = '%u'
# Tachtler - CentOS 6
password_query = SELECT username AS user, password, 10000 AS userdb_uid, 10000 as userdb_gid, '/var/spool/vmail/%Ld/%Ln' AS userdb_home, concat('*:bytes=', quota) AS userdb_quota_rule FROM mailbox WHERE username = '%Lu' AND active = 1
# Tachtler - CentOS 7
password_query = SELECT username AS user, password, 10000 AS userdb_uid, 10000 as userdb_gid, '/srv/vmail/%Ld/%Ln' AS userdb_home, concat('*:bytes=', quota) AS userdb_quota_rule FROM mailbox WHERE username = '%Lu' AND active = 1
 
# Query to get a list of all usernames.
#iterate_query = SELECT username AS user FROM users
# Tachtler
iterate_query = SELECT username AS user FROM mailbox WHERE active = 1

Nachfolgend nun alle wichtigen Zeilen der Konfigurationsdatei - /etc/dovecot/dovecot-sql.conf.ext - optimiert - (prefetch), unter Verwendung der SQL-Datenbank und der Tabellen von Postfix Admin ermittelt mit nachfolgendem Befehl: (Nur relevante Ausschnitte)

# grep -B 1 -v '^$\|^\s*\#' /etc/dovecot/dovecot-sql.conf.ext
# Tachtler
driver = mysql
--
# Tachtler
connect = host=mysql.tachtler.net dbname=postfix user=postfixuser password=geheim
--
# Tachtler
default_pass_scheme = PLAIN
--
# Tachtler - CentOS 6
user_query = SELECT 10000 AS uid, 10000 as gid, '/var/spool/vmail/%Ld/%Ln' AS home, concat('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%Lu' AND active = 1
# Tachtler - CentOS 7
user_query = SELECT 10000 AS uid, 10000 as gid, '/var/spool/vmail/%Ld/%Ln' AS home, concat('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%Lu' AND active = 1
--
# Tachtler - CentOS 6
password_query = SELECT username AS user, password, 10000 AS userdb_uid, 10000 as userdb_gid, '/var/spool/vmail/%Ld/%Ln' AS userdb_home, concat('*:bytes=', quota) AS userdb_quota_rule FROM mailbox WHERE username = '%Lu' AND active = 1
# Tachtler - CentOS 7
password_query = SELECT username AS user, password, 10000 AS userdb_uid, 10000 as userdb_gid, '/var/spool/vmail/%Ld/%Ln' AS userdb_home, concat('*:bytes=', quota) AS userdb_quota_rule FROM mailbox WHERE username = '%Lu' AND active = 1
--
# Tachtler
iterate_query = SELECT username AS user FROM mailbox WHERE active = 1

Erklärungen:

Treiber zur verwendeten SQL-Datenbank:

driver = mysql

Verbindungsdaten zur verwendeten SQL-Datenbank:

connect = host=mysql.tachtler.net dbname=postfix user=postfixuser password=geheim

Zu verwendendes Passwort Schema, welches auch CRAM-MD5 und DIGEST-MD5 unterstützt:

default_pass_scheme = PLAIN

Ermittlung aller benötigten Benutzerdaten z.B. bei der e-Mail-Einlieferung durch LMTP, wie

  • userdb - uid - UserID
  • userdb - gid - GruppenID
  • userdb - home - Verzeichnis in dem die (hier Maildir)-Struktur liegt
  • userdb - quota - Quota, zusammengesetzten aus einer Zeichenkette und einem Datenbankfeld

CentOS 6

user_query = SELECT 10000 AS uid, 10000 as gid, '/var/spool/vmail/%Ld/%Ln' AS home, concat('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%Lu' AND active = 1

CentOS 7

user_query = SELECT 10000 AS uid, 10000 as gid, '/srv/vmail/%Ld/%Ln' AS home, concat('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%Lu' AND active = 1

* %Ld = domain = tachtler.net (in Kleinschrift) | %Ln = localpart = klaus (in Kleinschrift) | %Lu = localpart@domain = klaus@tachtler.net (in Kleinschrift)

:!: WICHTIG - Trotz der Verwendung von prefetch muss auch noch eine „normaleuserdb-Abfrage konfiguriert sein !!!

Ermittlung aller benötigten Benutzerdaten zur Anmeldung, wie

  • passdb - user(name) - Anmeldename (hier e-Mail-Adresse)
  • passdb - password - Passwort
  • userdb - uid - UserID
  • userdb - gid - GruppenID
  • userdb - home - Verzeichnis in dem die (hier Maildir)-Struktur liegt
  • userdb - quota - Quota, zusammengesetzten aus einer Zeichenkette und einem Datenbankfeld

CentOS 6

password_query = SELECT username AS user, password, 10000 AS userdb_uid, 10000 as userdb_gid, '/var/spool/vmail/%Ld/%Ln' AS userdb_home, concat('*:bytes=', quota) AS userdb_quota_rule FROM mailbox WHERE username = '%Lu'

CentOS 7

password_query = SELECT username AS user, password, 10000 AS userdb_uid, 10000 as userdb_gid, '/srv/vmail/%Ld/%Ln' AS userdb_home, concat('*:bytes=', quota) AS userdb_quota_rule FROM mailbox WHERE username = '%Lu'

* %Ld = domain = tachtler.net (in Kleinschrift) | %Ln = localpart = klaus (in Kleinschrift) | %Lu = localpart@domain = klaus@tachtler.net (in Kleinschrift)

Ermittlung aller Benutzer durch den doveadm user-Befehl:

iterate_query = SELECT username AS user FROM mailbox

/etc/dovecot/conf.d/auth-sql.conf.ext

Grundsätzlich müssen an dieser Konfigurationsdatei keine Veränderungen durchgeführt werden, außer es wird zur Optimierung der SQL-Datenbank-Zugriffe die Einstellung prefetch verwendet.

Nachfolgend die komplette Konfigurationsdatei - /etc/dovecot/conf.d/auth-sql.conf.ext - optimiert - (prefetch):

# Authentication for SQL users. Included from 10-auth.conf.
#
# <doc/wiki/AuthDatabase.SQL.txt>
 
passdb {
  driver = sql
 
  # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
  args = /etc/dovecot/dovecot-sql.conf.ext
}
 
# "prefetch" user database means that the passdb already provided the
# needed information and there's no need to do a separate userdb lookup.
# <doc/wiki/UserDatabase.Prefetch.txt>
# Tachtler - enabled -
userdb {
  driver = prefetch
}
 
userdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf.ext
}
 
# If you don't have any user-specific settings, you can avoid the user_query
# by using userdb static instead of userdb sql, for example:
# <doc/wiki/UserDatabase.Static.txt>
#userdb {
  #driver = static
  #args = uid=vmail gid=vmail home=/var/vmail/%u
#}

Erklärungen:

Aktiviert die Möglichkeit prefetch nutzen zu können:

# "prefetch" user database means that the passdb already provided the
# needed information and there's no need to do a separate userdb lookup.
# <doc/wiki/UserDatabase.Prefetch.txt>
# Tachtler - enabled -
userdb {
  driver = prefetch
}

:!: WICHTIG - Trotz der Verwendung von prefetch muss auch noch eine „normaleuserdb-Abfrage konfiguriert sein !!!

:!: HINWEIS - Dies ist notwendig, da nach der Anmeldung auch noch userdb-Abfragen z.B. durch den Empfang von e-Mails per LMTP oder Einlieferung via dovecot-lda ausgelöst werden!

/etc/dovecot/conf.d/10-auth.conf

Dovecot bringt in der Konfigurationsdatei

  • /etc/dovecot/conf.d/10-auth.conf

ganz am Ende der Konfigurationsdatei vorbereitete include-Dateien mit, welche für die verschiedenen Authentifizierungsquellen bereits grundlegend vorkonfiguriert sind und nur nun angepasst werden müssen.

Hier muss der Eintrag

!include auth-system.conf.ext

auskommentiert werden, bzw. der Eintrag

!include auth-passwdfile.conf.ext

auskommentiert werden, falls bisher dieses Authentifizierungsverfahren genutzt wurde und der Eintrag

#!include auth-sql.conf.ext

aktiviert werden

Vorher (Standard): (Nur relevanter Ausschnitt):

...
!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
#!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext

ggf. Stand mit Authentifizierungsverfahren passwd-file wie unter nachfolgenden internen Link

beschrieben.

Vorher (passwd-file): (Nur relevanter Ausschnitt):

...
# Tachtler
# default: !include auth-system.conf.ext
# !include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
# Tachtler
# default: #!include auth-passwdfile.conf.ext
!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext

Nachher: (Nur relevanter Ausschnitt):

...
# Tachtler
# default: !include auth-system.conf.ext
# !include auth-system.conf.ext
# Tachtler
# default: #!include auth-sql.conf.ext
!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
#!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext

Neustart

Bevor der der dovecot-Daemon/Dienst neu gestartet werden soll, ist eine Überprüfung der korrekten Konfiguration durch nachfolgenden Befehl, zu empfehlen

# doveconf -n
# 2.2.18: /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.8 (0c4ae064f307+)
# OS: Linux 3.10.0-229.7.2.el7.x86_64 x86_64 CentOS Linux release 7.1.1503 (Core)  
auth_debug = yes
auth_debug_passwords = yes
auth_master_user_separator = *
auth_mechanisms = plain digest-md5 cram-md5 login
auth_verbose = yes
hostname = imap.tachtler.net
listen = *
mail_debug = yes
mail_location = maildir:~/Maildir
mail_plugins = " quota acl zlib mail_log notify"
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate
mbox_write_locks = fcntl
namespace {
  list = children
  location = maildir:%%h/Maildir:INDEX=%h/shared/%%u:CONTROL=%h/shared/%%u
  prefix = shared/%%u/
  separator = /
  subscriptions = yes
  type = shared
}
namespace inbox {
  inbox = yes
  location = 
  mailbox Drafts {
    auto = subscribe
    special_use = \Drafts
  }
  mailbox Junk {
    auto = subscribe
    special_use = \Junk
  }
  mailbox Sent {
    auto = subscribe
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    auto = subscribe
    special_use = \Trash
  }
  prefix = INBOX/
  separator = /
}
passdb {
  args = /etc/dovecot/master-users
  driver = passwd-file
  master = yes
  pass = yes
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  acl = vfile
  acl_shared_dict = file:/var/lib/dovecot/db/shared-mailboxes.db
  mail_log_fields = uid box msgid size from
  quota = maildir:User quota
  quota_grace = 10%%
  quota_rule = *:storage=1G
  quota_rule2 = INBOX/Trash:storage=+100M
  quota_status_nouser = DUNNO
  quota_status_overquota = 552 5.2.2 Mailbox is over quota
  quota_status_success = DUNNO
  quota_warning = storage=95%% quota-warning 95 %u
  quota_warning2 = storage=80%% quota-warning 80 %u
  sieve = file:~/sieve;active=~/.dovecot.sieve
  zlib_save = gz
  zlib_save_level = 6
}
postmaster_address = postmaster@tachtler.net
protocols = imap lmtp sieve
service auth {
  unix_listener auth-userdb {
    group = vmail
    user = vmail
  }
}
service imap-login {
  process_min_avail = 1
  service_count = 0
}
service lmtp {
  inet_listener lmtp {
    address = 192.168.0.80
    port = 24
  }
}
service managesieve-login {
  inet_listener sieve {
    address = 192.168.0.80
    port = 4190
  }
}
service quota-status {
  client_limit = 1
  executable = quota-status -p postfix
  inet_listener {
    address = 192.168.0.80
    port = 12340
  }
}
service quota-warning {
  executable = script /usr/local/bin/quota-warning.sh
  unix_listener quota-warning {
    user = vmail
  }
  user = vmail
}
ssl_cert = </etc/pki/dovecot/certs/CAcert-class3-wildcard_all_in_one.crt
ssl_cipher_list = ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
ssl_dh_parameters_length = 2048
ssl_key = </etc/pki/dovecot/private/tachtler.net.key
ssl_prefer_server_ciphers = yes
ssl_protocols = !SSLv2 !SSLv3
userdb {
  driver = prefetch
}
userdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
verbose_proctitle = yes
protocol lmtp {
  mail_plugins = " quota acl zlib mail_log notify sieve"
}
protocol imap {
  mail_max_userip_connections = 50
  mail_plugins = " quota acl zlib mail_log notify imap_quota imap_acl imap_zlib"
}
protocol sieve {
  mail_max_userip_connections = 50
}

:!: HINWEIS - die Konfiguration des dovecot-Daemon/Dienst konnte korrekt gelesen werden, wenn die Konfiguration erscheint, was letztendlich zwar nicht bedeutet, das Sie auch korrekt ist, aber syntaktische Fehler ausschließt !!!

Danach kann der dovecot-Server mit nachfolgendem Befehle neu gestartet werden:

# service dovecot restart
Stopping Dovecot Imap:                                     [  OK  ]
Starting Dovecot Imap:                                     [  OK  ]

bzw.

# systemctl restart dovecot

Login-Test mit doveadm

Um zu Überprüfen, ob eine Anmeldung als Benutzer möglich ist, kann nachfolgender Befehl genutzt werden:

# doveadm auth test klaus@tachtler.net
Password:
passdb: klaus@tachtler.net auth succeeded
extra fields:
  user=klaus@tachtler.net

Dies würde nachfolgende Einträge in der Log-Datei

  • /var/log/maillog

zur Anzeige bringen, wenn das Log-Ausgabe wie in diesem internen Link beschrieben

gesetzt wurde: (Nur relevanter Ausschnitt):

... dovecot: master: Dovecot v2.2.18 starting up for imap, lmtp, sieve (core dumps disabled)
... dovecot: auth: Debug: Loading modules from directory: /usr/lib64/dovecot/auth
... dovecot: auth: Debug: Module loaded: /usr/lib64/dovecot/auth/libdriver_mysql.so
... dovecot: auth: Debug: Module loaded: /usr/lib64/dovecot/auth/libdriver_sqlite.so
... dovecot: auth: Debug: Read auth token secret from /var/run/dovecot/auth-token-secret.dat
... dovecot: auth: Debug: passwd-file /etc/dovecot/master-users: Read 1 users in 0 secs
... dovecot: auth: Debug: auth client connected (pid=25782)
... dovecot: auth: Debug: auth client connected (pid=0)
... dovecot: auth: Debug: client in: AUTH  1       PLAIN   service=doveadm resp=AGtsYXVzQHRhY2h0bGVyLm5ldABnZWhlaW0= (previous base64 data may contain sensitive data)
... dovecot: auth-worker(25792): Debug: Loading modules from directory: /usr/lib64/dovecot/auth
... dovecot: auth-worker(25792): Debug: Module loaded: /usr/lib64/dovecot/auth/libdriver_mysql.so
... dovecot: auth-worker(25792): Debug: Module loaded: /usr/lib64/dovecot/auth/libdriver_sqlite.so
... dovecot: auth-worker(25792): Debug: passwd-file /etc/dovecot/master-users: Read 1 users in 0 secs
... dovecot: auth-worker(25792): Debug: sql(klaus@tachtler.net): query: SELECT username AS user, password, 10000 AS userdb_uid, 10000 as userdb_gid, '/srv/vmail/tachtler.net/klaus' AS userdb_home, concat('*:bytes=', quota) AS userdb_quota_rule FROM mailbox WHERE username = 'klaus@tachtler.net' AND active = 1
... dovecot: auth: Debug: client passdb out: OK    1       user=klaus@tachtler.net

Ausgabe Benutzerdaten

Mit nachfolgendem Befehl, gibt Dovecot eine Liste aller ihm bekannten Benutzer aus:

# doveadm user '*'
klaus@tachtler.net
petra@tachtler.net

Dies würde nachfolgende Einträge in der Log-Datei

  • /var/log/maillog

zur Anzeige bringen, wenn das Log-Ausgabe wie in diesem internen Link beschrieben

gesetzt wurde: (Nur relevanter Ausschnitt):

... dovecot: auth: Debug: master in: LIST  1       user=*  service=doveadm
... dovecot: auth-worker(25799): Debug: Loading modules from directory: /usr/lib64/dovecot/auth
... dovecot: auth-worker(25799): Debug: Module loaded: /usr/lib64/dovecot/auth/libdriver_mysql.so
... dovecot: auth-worker(25799): Debug: Module loaded: /usr/lib64/dovecot/auth/libdriver_sqlite.so
... dovecot: auth-worker(25799): Debug: passwd-file /etc/dovecot/master-users: Read 1 users in 0 secs
... dovecot: auth-worker(25799): Debug: sql(*): SELECT username AS user FROM mailbox WHERE active = 1

Um zu Überprüfen, welche Benutzerdaten Dovecot bekannt sind, kann nachfolgender Befehl genutzt werden:

# doveadm user klaus@tachtler.net
field	value
uid	10000
gid	10000
home	/srv/vmail/tachtler.net/klaus
mail	maildir:~/Maildir
quota_rule	*:bytes=1024000000

# doveadm user petra@tachtler.net
field	value
uid	10000
gid	10000
home	/srv/vmail/tachtler.net/petra
mail	maildir:~/Maildir
quota_rule	*:bytes=1024000000

Dies würde nachfolgende Einträge in der Log-Datei

  • /var/log/maillog

zur Anzeige bringen, wenn das Log-Ausgabe wie in diesem internen Link beschrieben

gesetzt wurde: (Nur relevanter Ausschnitt):

... dovecot: auth: Debug: master in: USER  1       klaus@tachtler.net      service=doveadm      
... dovecot: auth: Debug: prefetch(klaus@tachtler.net): passdb didn't return userdb entries, trying the next userdb
... dovecot: auth-worker(25809): Debug: Loading modules from directory: /usr/lib64/dovecot/auth
... dovecot: auth-worker(25809): Debug: Module loaded: /usr/lib64/dovecot/auth/libdriver_mysql.so
... dovecot: auth-worker(25809): Debug: Module loaded: /usr/lib64/dovecot/auth/libdriver_sqlite.so
... dovecot: auth-worker(25809): Debug: passwd-file /etc/dovecot/master-users: Read 1 users in 0 secs
... dovecot: auth-worker(25809): Debug: sql(klaus@tachtler.net): SELECT 10000 AS uid, 10000 as gid, '/srv/vmail/tachtler.net/klaus' AS home, concat('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = 'klaus@tachtler.net' AND active = 1
... dovecot: auth: Debug: userdb out: USER 1       klaus@tachtler.net      uid=10000       gid=10000       home=/srv/vmail/tachtler.net/klaus      quota_rule=*:bytes=1024000000
... dovecot: auth: Debug: master in: USER  1       petra@tachtler.net      service=doveadm      
... dovecot: auth: Debug: prefetch(petra@tachtler.net): passdb didn't return userdb entries, trying the next userdb
... dovecot: auth-worker(25809): Debug: sql(petra@tachtler.net): SELECT 10000 AS uid, 10000 as gid, '/srv/vmail/tachtler.net/petra' AS home, concat('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = 'petra@tachtler.net' AND active = 1
... dovecot: auth: Debug: userdb out: USER 1       petra@tachtler.net      uid=10000       gid=10000       home=/srv/vmail/tachtler.net/petra      quota_rule=*:bytes=1024000000

Login-Test mit Client

Dies würde nachfolgende Einträge in der Log-Datei

  • /var/log/maillog

zur Anzeige bringen, wenn das Log-Ausgabe wie in diesem internen Link beschrieben

gesetzt wurde: (Nur relevanter Ausschnitt):

... dovecot: auth: Debug: client in: AUTH  1       PLAIN   service=imap    secured session=z/KzOscaRQAKBwBQ        lip=192.168.0.80   rip=192.168.0.80   lport=143       rport=53061     resp=AGtsYXVzQHRhY2h0bGVyLm5ldABzdWFsazFsYWt1JDA= (previous base64 data may contain sensitive data)
... dovecot: auth-worker(25839): Debug: Loading modules from directory: /usr/lib64/dovecot/auth
... dovecot: auth-worker(25839): Debug: Module loaded: /usr/lib64/dovecot/auth/libdriver_mysql.so
... dovecot: auth-worker(25839): Debug: Module loaded: /usr/lib64/dovecot/auth/libdriver_sqlite.so
... dovecot: auth-worker(25839): Debug: passwd-file /etc/dovecot/master-users: Read 1 users in 0 secs
... dovecot: auth-worker(25839): Debug: sql(klaus@tachtler.net,192.168.0.80): query: SELECT username AS user, password, 10000 AS userdb_uid, 10000 as userdb_gid, '/srv/vmail/tachtler.net/klaus' AS userdb_home, concat('*:bytes=', quota) AS userdb_quota_rule FROM mailbox WHERE username = 'klaus@tachtler.net' AND active = 1
... dovecot: auth: Debug: client passdb out: OK    1       user=klaus@tachtler.net
... dovecot: auth: Debug: master in: REQUEST       2495873025      25782   1       a6ee3669274b8f8852481160f01f25df        session_pid=25841       request_auth_token   
... dovecot: auth: Debug: prefetch(klaus@tachtler.net,192.168.0.80,<z/KzOscaRQAKBwBQ>): success
... dovecot: auth: Debug: master userdb out: USER  2495873025      klaus@tachtler.net      uid=10000       gid=10000       home=/srv/vmail/tachtler.net/klaus      quota_rule=*:bytes=1024000000   auth_token=6f1219393aa147f3bec2544ba7509aa6553081f0
... dovecot: imap-login: Login: user=<klaus@tachtler.net>, method=PLAIN, rip=192.168.0.80, lip=192.168.0.80, mpid=25841, secured, session=<z/KzOscaRQAKBwBQ>
... dovecot: imap(klaus@tachtler.net): Debug: Loading modules from directory: /usr/lib64/dovecot
... dovecot: imap(klaus@tachtler.net): Debug: Module loaded: /usr/lib64/dovecot/lib01_acl_plugin.so
... dovecot: imap(klaus@tachtler.net): Debug: Module loaded: /usr/lib64/dovecot/lib02_imap_acl_plugin.so
... dovecot: imap(klaus@tachtler.net): Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
... dovecot: imap(klaus@tachtler.net): Debug: Module loaded: /usr/lib64/dovecot/lib11_imap_quota_plugin.so
... dovecot: imap(klaus@tachtler.net): Debug: Module loaded: /usr/lib64/dovecot/lib15_notify_plugin.so
... dovecot: imap(klaus@tachtler.net): Debug: Module loaded: /usr/lib64/dovecot/lib20_mail_log_plugin.so
... dovecot: imap(klaus@tachtler.net): Debug: Module loaded: /usr/lib64/dovecot/lib20_zlib_plugin.so
... dovecot: imap(klaus@tachtler.net): Debug: Module loaded: /usr/lib64/dovecot/lib30_imap_zlib_plugin.so
... dovecot: imap(klaus@tachtler.net): Debug: Added userdb setting: plugin/quota_rule=*:bytes=1024000000
... dovecot: imap(klaus@tachtler.net): Debug: Effective uid=10000, gid=10000, home=/srv/vmail/tachtler.net/klaus
... dovecot: imap(klaus@tachtler.net): Debug: Quota root: name=User quota backend=maildir args=
... dovecot: imap(klaus@tachtler.net): Debug: Quota rule: root=User quota mailbox=* bytes=1024000000 messages=0
... dovecot: imap(klaus@tachtler.net): Debug: Quota rule: root=User quota mailbox=INBOX/Trash bytes=+104857600 messages=0
... dovecot: imap(klaus@tachtler.net): Debug: Quota warning: bytes=972800000 (95%) messages=0 reverse=no command=quota-warning 95 klaus@tachtler.net
... dovecot: imap(klaus@tachtler.net): Debug: Quota warning: bytes=819200000 (80%) messages=0 reverse=no command=quota-warning 80 klaus@tachtler.net
... dovecot: imap(klaus@tachtler.net): Debug: Quota grace: root=User quota bytes=102400000 (10%)
... dovecot: imap(klaus@tachtler.net): Debug: Namespace inbox: type=private, prefix=INBOX/, sep=/, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:~/Maildir
... dovecot: imap(klaus@tachtler.net): Debug: maildir++: root=/srv/vmail/tachtler.net/klaus/Maildir, index=, indexpvt=, control=, inbox=/srv/vmail/tachtler.net/klaus/Maildir, alt=
... dovecot: imap(klaus@tachtler.net): Debug: acl: initializing backend with data: vfile
... dovecot: imap(klaus@tachtler.net): Debug: acl: acl username = klaus@tachtler.net 
... dovecot: imap(klaus@tachtler.net): Debug: acl: owner = 1
... dovecot: imap(klaus@tachtler.net): Debug: acl vfile: Global ACLs disabled 
... dovecot: imap(klaus@tachtler.net): Debug: Namespace : type=shared, prefix=shared/%u/, sep=/, inbox=no, hidden=no, list=children, subscriptions=yes location=maildir:%h/Maildir:INDEX=/srv/vmail/tachtler.net/klaus/shared/%u:CONTROL=/srv/vmail/tachtler.net/klaus/shared/%u
... dovecot: imap(klaus@tachtler.net): Debug: shared: root=/var/run/dovecot, index=, indexpvt=, control=, inbox=, alt=
... dovecot: imap(klaus@tachtler.net): Debug: acl: initializing backend with data: vfile
... dovecot: imap(klaus@tachtler.net): Debug: acl: acl username = klaus@tachtler.net 
... dovecot: imap(klaus@tachtler.net): Debug: acl: owner = 0
... dovecot: imap(klaus@tachtler.net): Debug: acl vfile: Global ACLs disabled 
... dovecot: imap(klaus@tachtler.net): Debug: Namespace : type=private, prefix=, sep=, inbox=no, hidden=yes, list=no, subscriptions=no location=fail::LAYOUT=none
... dovecot: imap(klaus@tachtler.net): Debug: none: root=, index=, indexpvt=, control=, inbox=, alt=
... dovecot: imap(klaus@tachtler.net): Disconnected: Logged out in=9 out=436
Diese Website verwendet Cookies. Durch die Nutzung der Website stimmen Sie dem Speichern von Cookies auf Ihrem Computer zu. Außerdem bestätigen Sie, dass Sie unsere Datenschutzbestimmungen gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website.Weitere Information
tachtler/dovecot_authentifizierung_-_sql.1436818071.txt.gz · Zuletzt geändert: 2015/07/13 22:07 von klaus