[PATCH] auth: support both old and new python-pam API
Andrew Shadura
andrew at shadura.me
Wed Feb 24 13:10:41 UTC 2016
# HG changeset patch
# User Andrew Shadura <andrew at shadura.me>
# Date 1456317153 -3600
# Wed Feb 24 13:32:33 2016 +0100
# Node ID 9e0c363ed9eaf72fe0faf0da4a80065dc2faf8da
# Parent 05a85a6cecba5c8caeb7996590365d5d9bc523c9
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,13 @@ Original author and date, and relevant c
import logging
import time
-import pam
+
+try:
+ from pam import authenticate as pam_authenticate
+except ImportError:
+ from pam import pam
+ pam_authenticate = pam().authenticate
+
import pwd
import grp
import re
@@ -92,7 +98,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:
More information about the kallithea-general
mailing list