mirror of
https://github.com/Kozea/Radicale.git
synced 2025-07-02 16:58:30 +00:00
Fix compatibility for PAM auth
PR #280 invoked `pam.authenticate().authenticate()` for older versions of python-pam. Also, this version avoids monkeypatching the PAM module.
This commit is contained in:
parent
ab77f62bf4
commit
baa958c81f
1 changed files with 8 additions and 4 deletions
|
@ -33,9 +33,13 @@ from .. import config, log
|
||||||
GROUP_MEMBERSHIP = config.get("auth", "pam_group_membership")
|
GROUP_MEMBERSHIP = config.get("auth", "pam_group_membership")
|
||||||
|
|
||||||
|
|
||||||
# Compatibility patch for old versions of python-pam.
|
# Compatibility for old versions of python-pam.
|
||||||
if not hasattr(pam, "pam"):
|
if hasattr(pam, "pam"):
|
||||||
pam.pam = (lambda *vargs, **kwargs: pam.authenticate(*vargs, **kwards))
|
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):
|
def is_authenticated(user, password):
|
||||||
|
@ -77,7 +81,7 @@ def is_authenticated(user, password):
|
||||||
"The PAM user belongs to the required group (%s)" %
|
"The PAM user belongs to the required group (%s)" %
|
||||||
GROUP_MEMBERSHIP)
|
GROUP_MEMBERSHIP)
|
||||||
# Check the password
|
# Check the password
|
||||||
if pam.pam().authenticate(user, password):
|
if pam_authenticate(user, password):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
log.LOGGER.debug("Wrong PAM password")
|
log.LOGGER.debug("Wrong PAM password")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue