Mercurial > kallithea
changeset 5748:7ef7536bf8e7 stable
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.
author | Andrew Shadura <andrew@shadura.me> |
---|---|
date | Wed, 24 Feb 2016 13:32:33 +0100 |
parents | 941548131765 |
children | 250f8150c4bb |
files | kallithea/lib/auth_modules/auth_pam.py |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/auth_modules/auth_pam.py Wed Mar 02 20:32:32 2016 +0100 +++ b/kallithea/lib/auth_modules/auth_pam.py Wed Feb 24 13:32:33 2016 +0100 @@ -25,7 +25,14 @@ 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 @@ # 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: