Postfix - SASL2 PAM authenticatie?

Pagina: 1
Acties:

  • maleadt
  • Registratie: Januari 2006
  • Laatst online: 26-01 20:38
:w

Ik heb een Postfix server draaiende, die ik net geconfigureerd heb om GMail als relay server te gebruiken. Dit werkt perfect, een mail sturen via SMTP komt mooi bij z'n doel aan. Maar op geen open-relay server te zijn, wou ik PLAIN/LOGIN auth voor SMTP inschakelen, en dat dan later via een TLS beveiligde verbinding aanbieden.

Echter loopt het al fout bij die eerste stap. Voor het gemak wil ik geen gebruik maken van MySQL backend, maar van een gewone user authentication. Daarom bevat /etc/pam.d/smtp het volgende:
code:
1
2
auth required system-auth
account required system-auth


Vervolgens heb ik saslauth geinstalleerd, en die geconfigureerd om PAM te gebruiken, dit door /etc/defaults/saslauth te wijzigin zodat het volgende er in voorkomt:
code:
1
MECHANISMS="pam"

Tot hier werkt alles ok. Het bewijst ervan: na saslauth te starten werkt authentificatie via testsaslauthd
code:
1
2
Serenity:/tmp# testsaslauthd -u tim -p wachtwoord
0: OK "Success."


Vervolgens heb ik een SASL2 applicatie gedefinieerd (smtdp), en /usr/lib/sasl2/smtpd.conf de volgende inhoud gegeven:
code:
1
2
3
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
log_level: 5


Om Postfix SASL2 authentificatie te laten gebruiken, heb ik in /etc/postfix/main.cf het volgende staan:
code:
1
2
3
4
5
6
# SASL server parameters
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = Serenity
smtpd_sasl_application_name = smtpd
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated, reject

Dit zou Postfix moeten instrueren om SASL2 te gebruiken, en meerbepaald de smtpd applicatie.
Maar hier loopt het ergens fout ;( want als ik telnet naar m'n SMTP server en een EHLO call, krijg ik het volgende:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Serenity:/tmp# nc localhost 25
220 Serenity ESMTP Postfix (Debian/GNU)
EHLO maleadt
250-Serenity
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH CRAM-MD5 NTLM LOGIN PLAIN DIGEST-MD5
250-AUTH=CRAM-MD5 NTLM LOGIN PLAIN DIGEST-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

Wat dus al niet meer overeenkomt met de "AUTH MECH = PLAIN LOGIN" die ik in SASL2's smtpd.conf staan heb.

Maar Postfix kiest er niet alleen de verkeerde authentificatie mechanismes uit, ze werken ook niet. Als ik postfix chrooted draai (daartoe heb ik Debian's postfix init script moeten veranderen zodat het /etc/sasl2db naar de chrooted omgeving kopieert), krijg ik bij poging tot authentificatie het volgende:
code:
1
2
3
4
5
6
7
8
9
Feb 28 20:57:20 Serenity postfix/smtpd[4997]: connect from unknown[192.168.0.10]
Feb 28 20:57:23 Serenity postfix/smtpd[4997]: warning: SASL authentication failure: no secret in database
Feb 28 20:57:23 Serenity postfix/smtpd[4997]: warning: unknown[192.168.0.10]: SASL CRAM-MD5 authentication failed: authentication failure
Feb 28 20:57:23 Serenity postfix/smtpd[4997]: warning: SASL authentication failure: no secret in database
Feb 28 20:57:23 Serenity postfix/smtpd[4997]: warning: unknown[192.168.0.10]: SASL NTLM authentication failed: authentication failure
Feb 28 20:57:23 Serenity postfix/smtpd[4997]: warning: SASL authentication failure: Password verification failed
Feb 28 20:57:23 Serenity postfix/smtpd[4997]: warning: unknown[192.168.0.10]: SASL PLAIN authentication failed: authentication failure
Feb 28 20:57:23 Serenity postfix/smtpd[4997]: warning: unknown[192.168.0.10]: SASL LOGIN authentication failed: authentication failure
Feb 28 20:57:25 Serenity postfix/smtpd[4997]: disconnect from unknown[192.168.0.10]

De "no secrets in database" doet me vermoeden dat sasl2db eigenlijk geen nuttige informatie bevat, wat me doet vermoeden dat er een fout zit in smtpd.conf die SASL2 moet linken met saslauth (dat wel perfect werkt). Maar ik zie de fout niet :P

Als ik postfix non-chrooted draai (en /etc/sasl2db leesbaar gemaakt heb voor postfix), is de error ietwat anders:
code:
1
2
3
4
5
6
7
8
9
Feb 28 21:00:58 Serenity postfix/smtpd[6258]: connect from unknown[192.168.0.10]
Feb 28 21:01:00 Serenity postfix/smtpd[6258]: warning: SASL authentication failure: no secret in database
Feb 28 21:01:00 Serenity postfix/smtpd[6258]: warning: unknown[192.168.0.10]: SASL CRAM-MD5 authentication failed: authentication failure
Feb 28 21:01:00 Serenity postfix/smtpd[6258]: warning: SASL authentication failure: no secret in database
Feb 28 21:01:00 Serenity postfix/smtpd[6258]: warning: unknown[192.168.0.10]: SASL NTLM authentication failed: authentication failure
Feb 28 21:01:00 Serenity postfix/smtpd[6258]: warning: SASL authentication failure: Password verification failed
Feb 28 21:01:00 Serenity postfix/smtpd[6258]: warning: unknown[192.168.0.10]: SASL PLAIN authentication failed: authentication failure
Feb 28 21:01:00 Serenity postfix/smtpd[6258]: warning: unknown[192.168.0.10]: SASL LOGIN authentication failed: authentication failure
Feb 28 21:01:02 Serenity postfix/smtpd[6258]: disconnect from unknown[192.168.0.10]


Dus al weet ik ongeveer waar het misloopt, vind ik de echte fout maar niet. Omdat het misschien nuttig kan zijn, hier de rest van mijn main.cf (postfix configuration):
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS client parameters
smtp_tls_loglevel = 1
# smtp_enforce_tls = yes    # Commented out as doing site per site (see below)
smtp_tls_per_site = hash:/etc/postfix/tls_per_site
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_tls_cert_file = /etc/postfix/Serenity-cert.pem
smtp_tls_key_file = /etc/postfix/Serenity-key.pem
smtp_tls_session_cache_database = btree:/var/run/smtp_tls_session_cache
smtp_use_tls = yes
tls_random_source = dev:/dev/urandom

# TLS server parameters
smtpd_tls_CAfile = /etc/postfix/cacert.pem
smtpd_tls_cert_file = /etc/postfix/Serenity-cert.pem
smtpd_tls_key_file = /etc/postfix/Serenity-key.pem
smtpd_tls_received_header = yes
smtpd_tls_session_cache_database = btree:/var/run/smtpd_tls_session_cache
smtpd_use_tls = yes
tls_daemon_random_source = dev:/dev/urandom

# SASL client parameters
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous

# SASL server parameters
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = Serenity
smtpd_sasl_application_name = smtpd
broken_sasl_auth_clients = yes
# permit_mynetworks, 
smtpd_recipient_restrictions = permit_sasl_authenticated, reject 

# General parameters
myhostname = Serenity
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = maleadt.no-ip.org, Serenity, localhost
mynetworks = 127.0.0.0/8 192.168.0.0/24 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
enable_original_recipient = yes

# SMTP configuration
relayhost = [smtp.gmail.com]:587
transport_maps = hash:/etc/postfix/transport


Alvast bedankt voor de informatie, ik besef dat het aardig wat [code ] blocks zijn om te lezen :)
maleadt

  • maleadt
  • Registratie: Januari 2006
  • Laatst online: 26-01 20:38
Eerst de authentificatie methode veranderd van een aparte pam.d socket, naar het reeds aanwezige authentificatiesysteem van Courier, maar dan op de makkelijke manier: saslauth configureren om via IMAP de credentials te testen (MECHANISMS="rimap -O 127.0.0.1"), aangezien het alternatief (sasl2 rechtstreeks met courier's authdaemond laten communiceren) patchen van sasl2-bin's source vereist. Maar helaas, nog altijd (diezelfde) geweigerde authentificatie.

Vervolgens ergens een gouden hint tegengekomen: smtpd.conf moet in /etc/postfix/sasl staan, en niet in de standaard /usr/lib/sasl2 directory 8-) na dat gedaan te hebben kreeg ik vage permission errors omdat postfix niet met saslauthd kon communiceren, maar dat is verholpen door de postfix user aan de sasl-group toe te voegen.
code:
1
2
3
4
5
6
7
Feb 28 22:36:18 Serenity postfix/smtpd[24593]: connect from unknown[192.168.0.10]
Feb 28 22:36:21 Serenity postfix/smtpd[24593]: warning: SASL authentication failure: cannot connect to saslauthd server: Permission denied
Feb 28 22:36:21 Serenity postfix/smtpd[24593]: warning: SASL authentication failure: Password verification failed
Feb 28 22:36:21 Serenity postfix/smtpd[24593]: warning: unknown[192.168.0.10]: SASL PLAIN authentication failed: generic failure
Feb 28 22:36:21 Serenity postfix/smtpd[24593]: warning: SASL authentication failure: cannot connect to saslauthd server: Permission denied
Feb 28 22:36:21 Serenity postfix/smtpd[24593]: warning: unknown[192.168.0.10]: SASL LOGIN authentication failed: generic failure
Feb 28 22:36:23 Serenity postfix/smtpd[24593]: disconnect from unknown[192.168.0.10]


En toen werkte het ineens allemaal :) Postfix communiceert nu correct met saslauthd, die op zijn beurt via Courier de credentials controleert. Misschien wat omslachtig, maar nu steunt alles tenminste op 1 backend authentificatie systeem wat het makkelijk maakt iets toe te voegen.

EDIT:
nog een opmerking, ik heb wel "permit_mynetworks" aand postfix' moeten toevoegen aan smtpd sasl configuratie parameter, om fetchmail zonder bijhorende authentificatie mail te kunnen laten sturen naar local users.

[ Voor 5% gewijzigd door maleadt op 28-02-2009 22:54 ]