Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
Do you have saslauthd configured to use pam and running ? –  topdog Dec 3 '10 at 5:26
    
I have PAM running using /usr/sbin/saslauthd -a pam –  Christian Joudrey Dec 3 '10 at 20:50
    
Can you post your /etc/postfix/sasl/smtpd.conf file? The valid values for password verification are: saslauthd sasldb sql ldapdb. –  schemacs Mar 12 '11 at 5:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.