xypseudo
Goto Top

Postfix im chroot mit SASL unter Debian betreiben

Gestestet mit dem Debian/Sarge-Image von Alturo, 1&1 sowie Schlund+Partner.

Als erstes müssen verschiedene Pakete installiert werden:

apt-get install postfix postfix-tls sasl2-bin libsasl2 libsasl2-modules

Zur Postfix-Konfiguration.

In der Datei /etc/postfix/main.cf sind folgende Einträge hinzuzufügen/ändern:

mynetworks=*IP_des_Servers*/32, 127.0.0.1/8

# Relay
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination

In der /etc/postfix/master.cf sind folgende Einträge zu machen/ändern:

smtp inet n - - - - smtpd -o pam
587 inet n - - - - smtpd -o pam

Diese sind erforderlich, damit Postfix beim versenden von Mails die smtp-Auth mittels pam auf Port 25 UND 587 überprüft.
Um besser debuggen zu können ist auch folgende Option möglich; aber bitte beachten, dass diese einem das mail.log schnell zum platzen bringen kann :o):

smtp inet n - - - - smtpd -v -o pam
587 inet n - - - - smtpd -v -o pam

Der Rest des Files hat bei mir folgenden Inhalt:

pickup    fifo  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      fifo  n       -       -       300     1       qmgr
#qmgr     fifo  n       -       -       300     1       oqmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
smtp      unix  -       -       -       -       -       smtp
relay     unix  -       -       -       -       -       smtp
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
#
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# maildrop. See the Postfix MAILDROP_README file for details.
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -d -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}

Da Postfix im chroot läuft (unter /var/spool/postfix) muss der saslauthd das auch tun (nicht als chroot laufen, aber in dem Verzeichnis :o)). Dazu modifiziert man dessen init-Script (/etc/init.d/saslauthd) und erweitert dieses um folgenden Eintrag:

PARAMS="-m /var/spool/postfix/var/run/saslauthd"  

Damit der saslauthd nun auch arbeiten kann, ist es noch erforderlich, das Verzeichnis anzulegen:

mkdir /var/spool/postfix/var/run/saslauthd

Damit der saslauthd nun auch startet muss noch in der Datei (ggf. anlegen!) /etc/default/saslauthd folgendes stehen:

# This needs to be uncommented before saslauthd will be run automatically
START=yes

# You must specify the authentication mechanisms you wish to use.
# This defaults to "pam" for PAM support, but may also include  
# "shadow" or "sasldb", like this:  
# MECHANISMS="pam shadow"  

MECHANISMS="pam"  

Und man muss ihm noch in der Datei /etc/postfix/sasl/smtpd.conf mitteilen, wie er authentifizieren soll:

pwcheck_method: saslauthd
mech_list: PLAIN LOGIN

Wenn nun der saslauthd läuft, findet man in dem Verzeichnis auch folgende files vor (nur wenn er an ist ;o)):

tweety:/var/spool/postfix/var/run# l saslauthd/
insgesamt 64K
drwxr-xr-x 2 root root 53 Jan 23 08:12 ./
drwxr-xr-x 3 root root 22 Jan 23 07:53 ../
srwxrwxrwx 1 root root 0 Jan 23 08:12 mux=
-rw------- 1 root root 0 Jan 23 08:12 mux.accept
-rw------- 1 root root 6 Jan 23 08:12 saslauthd.pid
tweety:/var/spool/postfix/var/run#

Schaltet man ihn aus, verschwinden die Files auf magische weise *g*.

ABSOLUT EXTREM WICHTIG (hat mich lange auf trab gehalten!!!):
Das Verzeichnis /var/spool/postfix/var/run/saslauthd muss der Gruppe postfix angehören oder 755 haben, da sich postfix sonst nicht über sasl authentifizieren kann.

Nun sollte auch schon alles tun :o)
Falls nicht - Nicht verzeifeln. Als erstes AUFMERKSAM Log-Files lesen. Wenn diese auch mit Verbose-Logging (ist oben erklärt, wie man das anschaltet) keinen Aufschluss geben, Folgendes versuchen:

Bei mir hat sich das debugging folgendermassen bewährt.
Ich habe einen Client konfiguriert, ne mail geschickt, das Passwort aber NICHT! gespeichert. Dann beim Anmelden vom Clienten an den Server (während die Session also offen war) mit "ps fauxw" die pid vom smtp suchen. Sollte in etwa so aussehen:

root 604 0.0 0.4 3044 1152 ? Ss 01:07 0:00 /usr/lib/postfix/master
postfix 612 0.0 0.4 3080 1212 ? S 01:07 0:00 \_ qmgr -l -t fifo -u -c
postfix 4269 0.0 0.4 3052 1176 ? S 07:21 0:00 \_ pickup -l -t fifo -u -c
postfix 4709 1.5 0.9 5420 2304 ? S 08:44 0:00 \_ smtpd -n smtp -t inet -u -c -o pam
postfix 4710 0.5 0.4 3048 1096 ? S 08:44 0:00 \_ proxymap -t unix -u

Diese dann mit dem Befehl "strace -p $pid" (die pid von smtpd!) angucken, wenn man das nächste mal ein Passwort eintippt. So habe ich z.B. herausgefunden, dass der Ordner /var/spool/postfix/var/run/saslauthd die falsche Berechtigung hatte...
strace ggf. mit

apt-get install strace

installieren ;o)

Anmerkungen: Confixx sollte damit ganz problemlos tun. Die angegebene Modifikation habe ich immer NACH der installation von Confixx(3.irgendwas) durchgeführt. Eine Modifikation der /etc/postfix/main.cf sollte zum verfeinern auf jeden Fall noch nachträglich erfolgen, meine genannten Einträge dienen nur dazu, dass es mit SASL tut. Wenn dann alles tut, muss noch das file
/root/confixx/admin/subs/postfix_install.pl
ausgeführt werden, damit confixx auch mit den neuen änderungen arbeitet.

Das Startscript /etc/init.d/saslauthd tut nun irgendwie nimmer richtig stoppen. Um den saslauthd zu killen habe ich immer mittels "ps
fauxw | grep sasl" die pids gesucht und mit einem "kill -9 $pid" von hand gekillt. Das anschliessende starten hingegen tut problemlos.
Falls noch jemand dazu eine Idee hat -> her damit, dann füge ich das noch hinzu :o)
Das lag an dem Parameter PID in der /etc/init.d/saslauthd, da muss noch der pfad zur PID geändert werden auf das chroot, dann tut es :o)
(also ins chroot, sprich /var/spool/postfix/var/run/saslauthd...)

Ich hoffe, dass das Hoto von nutzen sein wird.
Hat mich fast 3 Wochen meines Lebens gekostet.


gruss, pseudo

Content-Key: 24625

Url: https://administrator.de/contentid/24625

Printed on: April 19, 2024 at 06:04 o'clock

Member: xcomse
xcomse Feb 13, 2006 at 01:58:03 (UTC)
Goto Top
Das ganze fuer Confixx 3.x in 9 Schritten (Debian 3.1):

1.) apt-get install postfix postfix-tls sasl2-bin libsasl2-modules

2.) postconf -e 'mydestination = $myhostname, localhost.$mydomain, $mydomain'
postconf -e 'smtpd_helo_required = yes'
postconf -e 'smtpd_helo_restrictions = reject_invalid_hostname'
postconf -e 'smtpd_recipient_restrictions = permit_mynetworks, reject_unknown_recipient_domain, permit_sasl_authenticated, reject_unauth_destination'
postconf -e 'smtpd_sender_restrictions = reject_unknown_address'
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'smtpd_sasl_security_options = noanonymous'
postconf -e 'smtpd_sasl_local_domain ='
postconf -e 'smtp_sasl_auth_enable = no'
postconf -e 'broken_sasl_auth_clients = yes'

3.) vi /etc/postfix/sasl/smtpd.conf

saslauthd_path: /var/run/saslauthd/mux
pwcheck_method: saslauthd
mech_list: plain login

4.) adduser postfix sasl
5.) mkdir -p /var/spool/postfix/var/run/saslauthd
6.) dpkg-statoverride --add root sasl 710 /var/spool/postfix/var/run/saslauthd

7.) vi /etc/default/saslauthd

START=yes
MECHANISMS="shadow"
PARAMS="-m /var/spool/postfix/var/run/saslauthd"
PWDIR="/var/spool/postfix/var/run/saslauthd"
PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"

8.) /etc/init.d/saslauthd start (Gibt einen Hinweis aus)
9.) /etc/init.d/postfix restart