Changeset - 7ef7536bf8e7
[Not reviewed]
stable
0 1 0
Andrej Shadura (andrewsh) - 9 years ago 2016-02-24 12:32:33
andrew@shadura.me
Grafted from: 9e0c363ed9ea
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.
1 file changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general) First comment
kallithea/lib/auth_modules/auth_pam.py
Show inline comments
 
@@ -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:
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now