Postfix SASL Authentication using PAM_Python
- by Christian Joudrey
Cross-post from: http://stackoverflow.com/questions/4337995/postfix-sasl-authentication-using-pam-python
Hey guys,
I just set up a Postfix server in Ubuntu and I want to add SASL authentication using PAM_Python.
I've compiled pam_python.so and made sure that it is in /lib/security.
I've also added created the /etc/pam.d/smtp file and added:
auth required pam_python.so test.py
The test.py file has been placed in /lib/security and contains:
#
# Duplicates pam_permit.c
#
DEFAULT_USER = "nobody"
def pam_sm_authenticate(pamh, flags, argv):
try:
user = pamh.get_user(None)
except pamh.exception, e:
return e.pam_result
if user == None:
pam.user = DEFAULT_USER
return pamh.PAM_SUCCESS
def pam_sm_setcred(pamh, flags, argv):
return pamh.PAM_SUCCESS
def pam_sm_acct_mgmt(pamh, flags, argv):
return pamh.PAM_SUCCESS
def pam_sm_open_session(pamh, flags, argv):
return pamh.PAM_SUCCESS
def pam_sm_close_session(pamh, flags, argv):
return pamh.PAM_SUCCESS
def pam_sm_chauthtok(pamh, flags, argv):
return pamh.PAM_SUCCESS
When I test the authentication using auth plain amltbXkAamltbXkAcmVhbC1zZWNyZXQ= I get the following response:
535 5.7.8 Error: authentication failed: no mechanism available
In the postfix logs I have this:
Dec 2 00:37:19 duo postfix/smtpd[16487]: warning: SASL authentication problem: unknown password verifier
Dec 2 00:37:19 duo postfix/smtpd[16487]: warning: SASL authentication failure: Password verification failed
Dec 2 00:37:19 duo postfix/smtpd[16487]: warning: localhost.localdomain[127.0.0.1]: SASL plain authentication failed: no mechanism available
Any ideas?
tl;dr Anyone have step by step instructions on how to set up PAM_Python with Postfix?
Christian