平台:centos 5 X64
postfix:postfix-2.5.6
May 9 20:42:49 mail postfix/smtpd[2536]: warning: unknown[ip]: SASL LOGIN authentication failed: authentication failure
现象:
本地extmail能正常登陆并发送邮件出去。通过telnet登陆出现错误:
1.SASL LOGIN authentication failed: authentication failure
通过foxmail,php的smtp类登陆同样报此错。
分析:
查看验证配置文件:
cat /usr/lib/sasl2/smtpd.conf
pwcheck_method: authdaemond
log_level: 3
mech_list: PLAIN LOGIN
authdaemond_path:/var/spool/authdaemon/socket且 /var/spool/authdaemon/socket 文件存在,权限为
srwxrwxrwx 1 daemon daemon 0 Apr 30 15:44 /var/spool/authdaemon/socket也正常啊,难道本地的exmail不走验证机制?
1./usr/local/sbin/authtest -s login pass
这里的验证通过了。怪怪。。
仔细想了下这次邮局的配置,与以前大不同的是使用了不少RPM,减少编译过程。所以把怀疑对象定在了cyrus-sasl。
1.rpm -qa|grep cyrus-sasl
发现没有cyrus-sasl,于是
1.yum install cyrus-sasl
重新启动postfix,再次测试登陆。依然失败。
saslauthd -v
authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap支持的验证机制方法里怎么没有authdaemond。。看来RPM的默认是没有。。
解决:
下载二进制cyrus-sasl包编译。ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.22.tar.gz
yum remove cyrus-sasl
yum remove cyrus-sasl-plain
yum remove cyrus-sasl-devel
yum remove cyrus-sasl-md5
tar zvfx cyrus-sasl-2.1.22.tar.gz
cd cyrus-sasl-2.1.22
export LDFLAGS="-lpthread"
./configure --with-mysql --enable-anon --enable-plain --enable-login --disable-krb4 --disable-otp --disable-cram --disable-digest --disable-gssapi --with-pam --with-authdaemond
make
make install
rm -rf /usr/lib/sasl
rm -rf /usr/lib/sasl2
ln -s /usr/local/lib/sasl2 /usr/lib/
#为了让postfix能找到sasl,请运行如下命令:
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
cat > /usr/lib/sasl2/smtpd.conf <<EOT
pwcheck_method: authdaemond
log_level: 3
mech_list: PLAIN LOGIN
authdaemond_path:/var/spool/authdaemon/socket
EOT再次登陆发信,成功!