postfix smtp auth ldapbol (saslauthd problema)

Udv!

Szeretnek postfix-szel smtp auth-ot csinalni, ugy, hogy a felhasznalokat ldap-bol vegye. Ehhez saslauthd-t hasznalnek, a syslogbol viszont az derul ki, hogy nem akarja hasznalni az ldapot. A main.cf ide vonatkozo resze:
smtpd_sasl_auth_enable = yes
sasl_auth_local_domain =
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,check_relay_domains
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes

A /etc/default/saslauthd:
START=yes
MECHANISMS="ldap"
PARAMS="-O /etc/saslauthd.conf"

A /etc/saslauthd.conf:
ldap_servers: http://localhost:389
ldap_bin_dn: cn=daemons,dc=foo,dc=bar
ldap_bind_pw: foobar
ldap_search_base: ou=People,dc=foo,dc=bar
dap_filter: (&(accountStatus=active)(mail=%u@%d))
ldap_version: 3

Probalkozas utan a syslog:
Apr 9 13:00:42 a-one postfix/smtpd[5948]: warning: SASL authentication failure: Password verification failed
Apr 9 13:00:42 a-one postfix/smtpd[5948]: warning: foo.bar.tld[111.111.111.111]: SASL PLAIN authentication failed
Apr 9 13:00:44 a-one postfix/smtpd[5948]: warning: SASL authentication problem: unable to open Berkeley db /etc/sasldb2: No such file or directory

Latszik, hogy a default sasldb-bol szeretne kikeresni a usert, abban meg nincs. Howto-kban meg a /usr/share/doc-ban ezt talaltam, hogy igy lehet megmondani a sasl-nak, hogy ldapbol authentikaljon. Rosszul csinalok valamit, vagy erre nem saslauthd-t szokas hasznalni?

Hozzászólások

Koszi, ezt olvastam, gondoltam, hogy valami ilyesmit kellene megadni neki:
smtp_sasl_password_maps = /etc/postfix/ldapaliases.cf
Ez a cf elvileg jo, pl. ha bekapcsolom a verify-t vagy postmap -q -val megtalalja az ldap-os usereket. Ennek ellenere a logokban meg mindig az van, hogy a /etc/sasldb2-ben keresi. Emlit meg a howto egy smtpd.conf-ot, amit a /usr/lib/sasl2-be kellene rakni, nalam ebben ez van:
pwcheck_method: auxprop
auxprop_plugin: ldap
Ez elvileg egy tok masik modszer, amihez kell a megfelelo plugin, de elvileg enelkul is kellene mennie. Megmutatnad hol van valasz erre a kerdesre abban a doksiban?

Nekem egy picit úgy tűnik, hogy csak olvasgatod a fent már említett dokumentáció ide vonatkozó részeit, és nem elolvastad.

1) működik-e egyáltalán az authentikáció?
"To authenticate against the UNIX password database, try:
/usr/local/lib/sasl2/smtpd.conf:
pwcheck_method: pwcheck
"

2) ha nem , akkor hogy fordítottad a postfixed?

"Megmutatnad hol van valasz erre a kerdesre abban a doksiban?"
Nem.

Koszi szepen! Megtalaltam mi a gond (pwcheck_method: saslauthd), most viszont valami a chroottal nem jo (alapban debianon a /var/spool/postfix ala van be chrootolva a postfix), a hibauzenet:

Apr  9 18:30:17 foobar postfix/smtpd[4648]: warning: SASL authentication failure: cannot connect to saslauthd server: Connection refused

A /var/run/saslauthd-t nyilvan nem latja a mostfix a chrootbol, ugyhogy mount -o bind-del bevittem a chroot-ba:

/var/run/saslauthd on /var/spool/postfix/var/run/saslauthd type none (rw,bind)

Eddig root:sasl volt a tulajdonosa a konyvtarnak, ezt megvaltoztattam postfix:sasl-re, hogy a chrootban a postfix user is tudja olvani. Ugy tunik, hogy a saslauthd ott figyel, hogy kell neki:
unix 2 [ ACC ] STREAM LISTENING 8102 3184/saslauthd /var/run/saslauthd/mux

A mux ugyanugy megvan a chroot alatt a bindnek koszonhetoen.

Elfelejtettem az elobb: az auth alapban is mukodott, de sasldb-bol, aki usert oda felvettem, az tudott authentikalni, szoval szerintem ez a resze rendben van.

Auxprop nem megy, ahhoz szerintem forditani kellene, jobban szeretnem megcsinalni debian csomagokkal, mert joval egyszerubb lenne karbantartani csak apt-get-tel frissitve, mint figyelni, hogy mikor van olyan bug, hogy ujat kell forditani. Amugy ilyen kis itthoni cucc ez. Amugy az ubuntu servert probalgatom a gepen. A /etc/postfix/sasl/smtpd.conf igy nez ki most:
pwcheck_method: saslauthd
saslauthd_path: /var/run/saslauthd
mech_list: plain

Auxpropnal annyi valtozik, hogy pwcheck_method: auxprop, auxprop_plugin: ldap, olyankor ezt a hibauzenetet kapom:
warning: SASL authentication failure: Password verification failed

Progress made, a /etc/default/saslauthd-t modositottam:
PARAMS="-O /etc/saslauthd.conf -m /var/spool/postfix/var/run/saslauthd"
Igy mar alapbol a postfix chrootjaba teszi a socket file-t a saslauthd. Sikerult testsaslauthd-vel reprodukalni, amit a postfix csinal:
# testsaslauthd -u testuser -p secret -f /var/spool/postfix/var/run/saslauthd
connect() : Connection refused

A postfix is ugyanilyen connection refused hibauzenetet ad.

Mi van a /etc/postfix/sasl/smtpd.conf -odban?
kb ennek kell lennie:
mithos@godness:~$ cat /etc/postfix/sasl/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login
mithos@godness:~$

a saslauthd konfigja meg:
mithos@godness:~$ cat /etc/saslauthd.conf
ldap_servers: ldap://ip.cim.master ldap://ip.cim.slave (ha van)
ldap_search_base: ou=valami,dc=com
mithos@godness:~$

saslauthd-t igy inditsd el:
/usr/sbin/saslauthd -a ldap

indito scriptbe allitsd be, hogy ldap authentikacio legyen (MECHANISMS="ldap")

a main.cf meg:

az ugyanaz mint a tied volt. :)

Hatha segitettem vmit.
Reka

# cat /etc/postfix/sasl/smtpd.conf
pwcheck_method: saslauthd
saslauthd_path: /var/run/saslauthd
mech_list: plain
Ez szerintem stimmel. A saslauthd_path a chroot miatt van igy.
# cat /etc/saslauthd.conf
ldap_servers: http://localhost:389
ldap_bin_dn: cn=admin,dc=foo,dc=bar
ldap_bind_pw: foobar
ldap_search_base: ou=People,dc=foo,dc=bar
dap_filter: (&(accountStatus=active)(mail=%u@%d))
ldap_version: 3
Ez amugy nem admin-kent bindelne, de gondoltam, hogy ez is lehet hiba, amig kizarom, marad igy.
# ps -ef|grep saslauthd
root 3476 1 0 14:22 ? 00:00:00 /usr/sbin/saslauthd -O /etc/saslauthd.conf -m /var/spool/postfix/var/run/saslauthd -a ldap
root 3477 3476 0 14:22 ? 00:00:00 /usr/sbin/saslauthd -O /etc/saslauthd.conf -m /var/spool/postfix/var/run/saslauthd -a ldap
root 3478 3476 0 14:22 ? 00:00:00 /usr/sbin/saslauthd -O /etc/saslauthd.conf -m /var/spool/postfix/var/run/saslauthd -a ldap
root 3479 3476 0 14:22 ? 00:00:00 /usr/sbin/saslauthd -O /etc/saslauthd.conf -m /var/spool/postfix/var/run/saslauthd -a ldap
root 3480 3476 0 14:22 ? 00:00:00 /usr/sbin/saslauthd -O /etc/saslauthd.conf -m /var/spool/postfix/var/run/saslauthd -a ldap

# cat /etc/default/saslauthd
START=yes
MECHANISMS="ldap"
PARAMS="-O /etc/saslauthd.conf -m /var/spool/postfix/var/run/saslauthd"

Elvileg ez is oke. Mit csinalok rosszul? testsaslauthd-vel nalad mutatja a usereket? Connection refused a hibauzenet testsaslauthd-vel is, es a postfix logban is. Ha a bind-et kicommentezem a saslauthd.conf-ban, akkor is connection refused. Mivel a testsaslauthd-vel sem megy, gondolom nem a chroot miatt van. A userek jelszava ldapban MD5-tel van kodolva a userPassword mezoben.

igen, mutatja. Lehet hogy eliras, es nem copy-paste volt, de ezt itt elirtad:

ldap_bin_dn: cn=admin,dc=foo,dc=bar

ha copy-paste volt, akkor javitsd ki, mert igy nem tud bindelni.

A tobbi tenyleg jonak latszik. Bar az igazat megvallva, nalam chrootban nem mukodott, es en sem jottem ra hogy miert nem. Ugyhogy postfix nalam nem chrootolt a sasl miatt. En is szoptam vele jo ket honapot, mire mukodott.

Reka

A testsaslauthd-nek mit adsz meg parameterkent? -f -nel megadod a mux-ot is vagy csak a konyvtarat ahol van? Most kiszedtem a postfixet chrootbol (master.cfbol), de igy is ugyanaz a hibauzenet. Elvileg csak ez a -m-mel socket athelyezes kell neki, hogy menjen chroot-tal. Az nem eliras volt, hanem copy-paste, de mar sokadjara nyultam hozza, volt jo is, most kijavitottam, de igy is ugyanaz a hiba. Itt valami saslauthd gond lesz.

godness:~# testsaslauthd -u username -p password
0: OK "Success."
godness:~#

en csak ezt irom be. a debug modot most nem nagyon akarom megmutatni, mert ahhoz le kellene allitanom az eles, mukodo mailszerveren a saslauthd-t, es debug modban ujrainditani. Na ezert nyakazas lenne :)
De vmi olyasmi remlik, hogy amikor en nezegettem a debug modot, akkor nalam anonymous-kent bindelt, tehat nem kellett binddn, bindpw. es teljesen jol mukodott, debug mod mutatta, hogy most akkor errol es errol a szerverrol kerdezi le ezt es ezt az informaciot.

Reka

Uh, ez azert durva eliras volt benne, koszi, hogy szoltal. Kijavitottam, de sajnos a helyzet igy is ugyanaz. Probaltam meg a saslauthd.conf-ba a custom bind method-ot berakni (a doksija irta, hogy ezzel checkelni az MD5 hash-es userPassword mezot), de sajnos ugyanez az eredmeny. Viszont megneztem mit csinal az ldapsearch, es mit csinal a saslauthd slapd -d-vel, es mast csinalnak, pont az a resz, amiben visszaadja az ldap entry-t nincs benne abban a logban, amikor a saslauthd kerdezi az ldapt. Lehet a slapd.conf van elcseszve? A sima lekerdezest ldapsearch -x -b "ou=People,dc=foo,dc=bar"-ral csinaltam. A userPassword mezot, slappasswd -h {MD5} -tel allitom elo.

A slapd.conf:
allow bind_v2

include /etc/ldap/schema/core.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/inetorgperson.schema
include /etc/ldap/schema/qmail.schema
include /etc/ldap/schema/authldap.schema

schemacheck on

pidfile /var/run/slapd/slapd.pid

argsfile /var/run/slapd.args

loglevel 0

modulepath /usr/lib/ldap
moduleload back_bdb

backend bdb
checkpoint 512 30

database bdb

suffix "dc=foo,dc=bar"
rootdn "cn=admin,dc=foo,dc=bar"
rootpw {SSHA}foofoobarbar

directory "/home/ldap"

index objectClass eq

lastmod on

access to attrs=userPassword
by dn="cn=admin,dc=a-one,dc=hu" write
by anonymous auth
by self write

access to dn.base="" by * read

access to *
by dn="cn=admin,dc=a-one,dc=hu" write
by users read
by self write
by * read

Update: megneztem mi tortenik testsaslauthd kozben, ha a slapd-t debug modban inditom (slapd -d 5) latszik, hogy a saslauthd hozza se nyul, valoszinu saslauthd gond lesz.

Az arhivum kedveert leirom a megoldast:
Akkor sem megy, ha megprobalom elrakni a socketet a helyerol, es akkor sem, hogyha megadom smtpd.conf-ban a saslauthd_path-t. Ha ezek nincsenek, akkor mukodik.