我试图configurationPostfix,以便用户可以通过SMTP发送电子邮件,其中包含用户名和密码。 而我正试图将证书存储在MySQL数据库中。 我已经走上了saslauthd和pam的路,我陷入了困境。
启用pamdebuggingfunction我可以看到,当我尝试使用Thunderbird发送电子邮件时,执行的查询检索密码为:
pam_mysql - SELECT password FROM mailbox WHERE username = 'mehran'
在这种情况下,用户名持有[email protected]的价值。 但是当我尝试:
# testsaslauthd -u [email protected] -p 123 -s smtp 0: OK "Success."
并且日志读取:
pam_mysql - SELECT password FROM mailbox WHERE username = '[email protected]'
显示它是Postfix,在把它交给saslauthd (或者至less我相信是这样)之前,把用户名中的@domain省略掉了。 我已经search了Postfix的configuration,但我没有看到什么影响这个!?
我发现这个问题,所以在这里可以帮助任何人:
有一个saslauthd的configuration文件,我的位于/etc/sysconfig/saslauthd :
# Directory in which to place saslauthd's listening socket, pid file, and so # on. This directory must already exist. SOCKETDIR=/var/run/saslauthd # Mechanism to use when checking passwords. Run "saslauthd -v" to get a list # of which mechanism your installation was compiled with the ablity to use. MECH=pam # Options sent to the saslauthd. If the MECH is other than "pam" uncomment the next line. # DAEMONOPTS=--user saslauth # OPTIONS="-c -r -m /var/spool/postfix/var/run/saslauthd" OPTIONS="-c -m /var/run/saslauthd" # Additional flags to pass to saslauthd on the command line. See saslauthd(8) # for the list of accepted flags. FLAGS=
OPTIONSvariables应该包含传递给saslauthd的选项。 这是缺less的,这正是我正在寻找什么。 根据其文件 :
-r将领域与login(两者之间带有“@”符号)组合在一起。 例如login:“foo”realm:“bar”将会以login的forms传递:“foo @ bar”。 请注意,领域仍然会通过,这可能会导致意外的行为。
但是我的问题没有被这个改变解决! 事实certificate,由于/etc/init.d/saslauthd脚本中的一些错误,即使上面提到的configuration文件被加载,但它不被应用! $OPTIONS从未使用过!
以下是/etc/init.d/saslauthd脚本的原始开始部分:
start() { [ -x $path ] || exit 5 echo -n $"Starting $prog: " daemon $DAEMONOPTS $path -m $SOCKETDIR -a $MECH $FLAGS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $lockfile return $RETVAL }
这就是我修改它的方法:
start() { [ -x $path ] || exit 5 echo -n $"Starting $prog: " daemon $DAEMONOPTS $path $OPTIONS -a $MECH $FLAGS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $lockfile return $RETVAL }
全做完了! 现在查询包含完整的电子邮件地址以检查密码。
您的查询包含查询的错误/不完整参数。
这个查询会将域添加到login的本地部分:
SELECT password FROM mailbox WHERE username = '%u@%r'
改正你的SASLconfiguration中的查询,例如/etc/postfix/sasl/smtpd.conf