Skip to content

Commit

Permalink
Merge pull request #281 from untitaker/pam
Browse files Browse the repository at this point in the history
Fix compatibility for PAM auth
  • Loading branch information
liZe committed Apr 25, 2015
2 parents ab77f62 + baa958c commit 85826fc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions radicale/auth/PAM.py
Expand Up @@ -33,9 +33,13 @@
GROUP_MEMBERSHIP = config.get("auth", "pam_group_membership")


# Compatibility patch for old versions of python-pam.
if not hasattr(pam, "pam"):
pam.pam = (lambda *vargs, **kwargs: pam.authenticate(*vargs, **kwards))
# Compatibility for old versions of python-pam.
if hasattr(pam, "pam"):
def pam_authenticate(*args, **kwargs):
return pam.pam().authenticate(*args, **kwargs)
else:
def pam_authenticate(*args, **kwargs):
return pam.authenticate(*args, **kwargs)


def is_authenticated(user, password):
Expand Down Expand Up @@ -77,7 +81,7 @@ def is_authenticated(user, password):
"The PAM user belongs to the required group (%s)" %
GROUP_MEMBERSHIP)
# Check the password
if pam.pam().authenticate(user, password):
if pam_authenticate(user, password):
return True
else:
log.LOGGER.debug("Wrong PAM password")
Expand Down

0 comments on commit 85826fc

Please sign in to comment.