# HG changeset patch # User Andrew Shadura # Date 2016-02-24 13:32:33 # Node ID 7ef7536bf8e7e6a31f9497621aea0cc866968bec # Parent 9415481317652856e55fa54af51abdb907494671 auth: support both old and new python-pam API python-pam 1.8.* provides a new API replacing the previously available authenticate() function. The latest unreleased version brings it back, but until it's available, use a custom shim instead. diff --git a/kallithea/lib/auth_modules/auth_pam.py b/kallithea/lib/auth_modules/auth_pam.py --- a/kallithea/lib/auth_modules/auth_pam.py +++ b/kallithea/lib/auth_modules/auth_pam.py @@ -25,7 +25,14 @@ Original author and date, and relevant c import logging import time -import pam + +try: + from pam import authenticate as pam_authenticate +except ImportError: + # work around pam.authenticate missing in python-pam 1.8.* + from pam import pam + pam_authenticate = pam().authenticate + import pwd import grp import re @@ -92,7 +99,7 @@ class KallitheaAuthPlugin(auth_modules.K # Need lock here, as PAM authentication is not thread safe _pam_lock.acquire() try: - auth_result = pam.authenticate(username, password, + auth_result = pam_authenticate(username, password, settings["service"]) # cache result only if we properly authenticated if auth_result: