postfix认证出错 sasl

转自:http://blogold.chinaunix.net/u/12592/showart_1844853.html 错误一:
查看/var/log/mail.log:
Feb 26 23:39:57 vd postfix/smtpd[2323]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory

postfix没有找到saslauthd的工作目录,由于postfix的工作目录默认在/var/spool/postfix/var/run/saslauthd中;而saslauthd默认的工作目录为/var/run/saslauthd中,从而导致postfix无法连接saslauthd服务。
解决方法:
1. 设置saslauthd的工作目录为/var/spool/postfix/var/run/saslauthd
2. 创建符号链接,将/var/run/saslauthd链接到/var/spool/postfix/var/run/saslauthd由于testsaslauthd也是采用saslauthd的默认目录,所以如果saslauthd的工作目录不在/var/run/saslauthd的话,就会无法连接saslauthd服务,需要通过-f选项来指定工作目录;或者是创建一个符号连接。错误二:
查看/var/log/mail.log:
Feb 26 23:47:23 vd postfix/smtpd[2405]: warning: SASL authentication failure: cannot connect to saslauthd server: Permission denied文件/var/spool/postfix/var/run/saslauthd目录或者是/var/run/saslauthd目录的权限问题。
解决方法:
1、修改目录的权限
2、将postfix添加到sasl组中错误三:
查看/var/log/mail.log:
 92739 Feb 26 00:17:17 pact518 postfix/smtpd[30644]: warning: unknown[118.203.19.156]: SASL PLAIN authentication failed: authentication failure考虑就是对LDAP的输入有误:
查看/var/log/auth.log:
Feb 27 10:30:57 pact518 saslauthd[11030]: Entry not found (mail=wangyao).
Feb 27 10:30:57 pact518 saslauthd[11030]: Authentication failed for wangyao: User not found (-6)
Feb 27 10:30:57 pact518 saslauthd[11030]: do_auth: auth failure: [user=wangyao] [service=imap] [realm=] [mech=ldap][reason=Unknow]

发现是mail=wangyao这个entry在ldap中不存在,实际上我们的entry应该是 mail=wangyao@pact518.hit.edu.cn


这也就是说我们的ldap_filter有问题,需要修改ldap_filter。Q.: Why do you run saslauthd with the -r flag?
A.: Because my users authenticate as "user@domain", not "user". If you are in trouble check /var/log/auth.log .> >If you append the domainname as REALM, which you do by setting
> >smtpd_sasl_local_domain this way, you need to run at least saslauthd
> >2.1.19 with the "-r" switch. 可见saslauthd中的-r选项与postfix/main.cf中的smtp_sasl_local_domain字段相互结合,控制着ldap的输入。dn: uid=test,dc=pact518,dc=hit,dc=edu,dc=cn
如果设置了saslauthd的-r选项和smtp_sasl_local_domain的话,postfix会自动的在smtp认证用户名的后面加上@domain,这样ldap的输入就变成了
user@domain,根据%u表示输入,现在%u=user@domain,也就是mail的形式:
ldap_filter: mail=%u
如果没有设置smtp_sasl_local_domain的话,ldap的输入只是user,%u=user,ldap中uid=user,也就是uid的形式:
ldap_filter: uid=%u关于ldap_filter中的%u的含义,可以man ldap_table进行查看。
===================================================登录测试
1. base64编码
perl -MMIME::Base64 -e 'print encode_base64("wangyao")'BTW:这里使用echo "wangyao" | base64不行(echo默认会带上'\n',需要使用-n选项).
debian-wangyao:~$ perl -MMIME::Base64 -e 'print encode_base64("wangyao")'
d2FuZ3lhbw==
debian-wangyao:~$ echo -n wangyao | base64
d2FuZ3lhbw==
debian-wangyao:~$ echo wangyao | base64
d2FuZ3lhbwo=2. telnet smtp登录
wangyao@wangyao-laptop:~$ telnet 202.118.236.130 25
Trying 202.118.236.130...
Connected to 202.118.236.130.
Escape character is '^]'.
220 pact518.hit.edu.cn ESMTP Postfix (Debian/GNU)
ehlo pact518.hit.edu.cn
250-pact518.hit.edu.cn
250-PIPELINING
250-SIZE 30000000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
auth login
334 VXNlcm5hbWU6
xxxxxxxxxxxx
334 UGFzc3dvcmQ6
yyyyyyyyyyyy
235 2.7.0 Authentication successful
quit
221 2.0.0 Bye
Connection closed by foreign host.参考:
http://doc.linuxpk.com/54681.html
http://wlx.westgis.ac.cn/322/
http://www.freeworld.net.cn/Article/Catalog117/34151.html
http://www.postfix.org/ldap_table.5.html

分享到