|
|
ca1eb8 |
From bfafa12ae83bcdec53bb306f68eff9e6acfbb4a6 Mon Sep 17 00:00:00 2001
|
|
|
ca1eb8 |
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
|
|
|
ca1eb8 |
Date: Fri, 20 Jul 2018 12:15:18 +0200
|
|
|
ca1eb8 |
Subject: [PATCH] sdap: respect passwordGracelimit
|
|
|
ca1eb8 |
MIME-Version: 1.0
|
|
|
ca1eb8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
ca1eb8 |
Content-Transfer-Encoding: 8bit
|
|
|
ca1eb8 |
|
|
|
ca1eb8 |
Since recent changes in 389-ds two response controls are end when
|
|
|
ca1eb8 |
passwordGracelimit is set and about to expire:
|
|
|
ca1eb8 |
- [1.3.6.1.4.1.42.2.27.8.5.1] for the GraceLimit itself
|
|
|
ca1eb8 |
- [2.16.840.1.113730.3.4.4] for the PasswordExpired
|
|
|
ca1eb8 |
|
|
|
ca1eb8 |
Whenever the former is returned and the GraceLimit is still valid, we
|
|
|
ca1eb8 |
shouldn't report the latter to the users.
|
|
|
ca1eb8 |
|
|
|
ca1eb8 |
Resolves:
|
|
|
ca1eb8 |
https://pagure.io/SSSD/sssd/issue/3597
|
|
|
ca1eb8 |
|
|
|
ca1eb8 |
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
|
|
|
ca1eb8 |
|
|
|
ca1eb8 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
ca1eb8 |
(cherry picked from commit 954bf82b60b7cfd93b865a6618f155d042b15729)
|
|
|
ca1eb8 |
|
|
|
ca1eb8 |
DOWNSTREAM:
|
|
|
ca1eb8 |
Resolves: rhbz#1522928 - sssd doesn't allow user with expired password
|
|
|
ca1eb8 |
to login when PasswordgraceLimit set
|
|
|
ca1eb8 |
---
|
|
|
ca1eb8 |
src/providers/ldap/sdap_async_connection.c | 21 ++++++++++++++++++++-
|
|
|
ca1eb8 |
1 file changed, 20 insertions(+), 1 deletion(-)
|
|
|
ca1eb8 |
|
|
|
ca1eb8 |
diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c
|
|
|
ca1eb8 |
index a8d4262b52c4b2d2810450d68794f00558ea5c2d..8aacd6705a1f82be8c14f97996786ac9b47396d5 100644
|
|
|
ca1eb8 |
--- a/src/providers/ldap/sdap_async_connection.c
|
|
|
ca1eb8 |
+++ b/src/providers/ldap/sdap_async_connection.c
|
|
|
ca1eb8 |
@@ -734,6 +734,7 @@ static void simple_bind_done(struct sdap_op *op,
|
|
|
ca1eb8 |
ber_int_t pp_expire;
|
|
|
ca1eb8 |
LDAPPasswordPolicyError pp_error;
|
|
|
ca1eb8 |
int result = LDAP_OTHER;
|
|
|
ca1eb8 |
+ bool on_grace_login_limit = false;
|
|
|
ca1eb8 |
|
|
|
ca1eb8 |
if (error) {
|
|
|
ca1eb8 |
tevent_req_error(req, error);
|
|
|
ca1eb8 |
@@ -772,6 +773,7 @@ static void simple_bind_done(struct sdap_op *op,
|
|
|
ca1eb8 |
DEBUG(SSSDBG_TRACE_INTERNAL,
|
|
|
ca1eb8 |
"Server returned control [%s].\n",
|
|
|
ca1eb8 |
response_controls[c]->ldctl_oid);
|
|
|
ca1eb8 |
+
|
|
|
ca1eb8 |
if (strcmp(response_controls[c]->ldctl_oid,
|
|
|
ca1eb8 |
LDAP_CONTROL_PASSWORDPOLICYRESPONSE) == 0) {
|
|
|
ca1eb8 |
lret = ldap_parse_passwordpolicy_control(state->sh->ldap,
|
|
|
ca1eb8 |
@@ -799,13 +801,26 @@ static void simple_bind_done(struct sdap_op *op,
|
|
|
ca1eb8 |
state->ppolicy->grace = pp_grace;
|
|
|
ca1eb8 |
state->ppolicy->expire = pp_expire;
|
|
|
ca1eb8 |
if (result == LDAP_SUCCESS) {
|
|
|
ca1eb8 |
-
|
|
|
ca1eb8 |
+ /* We have to set the on_grace_login_limit as when going
|
|
|
ca1eb8 |
+ * through the response controls 389-ds may return both
|
|
|
ca1eb8 |
+ * an warning and an error (and the order is not ensured)
|
|
|
ca1eb8 |
+ * for the GraceLimit:
|
|
|
ca1eb8 |
+ * - [1.3.6.1.4.1.42.2.27.8.5.1] for the GraceLimit itself
|
|
|
ca1eb8 |
+ * - [2.16.840.1.113730.3.4.4] for the PasswordExpired
|
|
|
ca1eb8 |
+ *
|
|
|
ca1eb8 |
+ * So, in order to avoid bulldozing the GraceLimit, let's
|
|
|
ca1eb8 |
+ * set it to true when pp_grace >= 0 and, in the end of
|
|
|
ca1eb8 |
+ * this function, just return EOK when LDAP returns the
|
|
|
ca1eb8 |
+ * PasswordExpired error but the GraceLimit is still valid.
|
|
|
ca1eb8 |
+ */
|
|
|
ca1eb8 |
+ on_grace_login_limit = false;
|
|
|
ca1eb8 |
if (pp_error == PP_changeAfterReset) {
|
|
|
ca1eb8 |
DEBUG(SSSDBG_TRACE_LIBS,
|
|
|
ca1eb8 |
"Password was reset. "
|
|
|
ca1eb8 |
"User must set a new password.\n");
|
|
|
ca1eb8 |
ret = ERR_PASSWORD_EXPIRED;
|
|
|
ca1eb8 |
} else if (pp_grace >= 0) {
|
|
|
ca1eb8 |
+ on_grace_login_limit = true;
|
|
|
ca1eb8 |
DEBUG(SSSDBG_TRACE_LIBS,
|
|
|
ca1eb8 |
"Password expired. "
|
|
|
ca1eb8 |
"[%d] grace logins remaining.\n",
|
|
|
ca1eb8 |
@@ -875,6 +890,10 @@ static void simple_bind_done(struct sdap_op *op,
|
|
|
ca1eb8 |
ret = ERR_AUTH_FAILED;
|
|
|
ca1eb8 |
}
|
|
|
ca1eb8 |
|
|
|
ca1eb8 |
+ if (ret == ERR_PASSWORD_EXPIRED && on_grace_login_limit) {
|
|
|
ca1eb8 |
+ ret = EOK;
|
|
|
ca1eb8 |
+ }
|
|
|
ca1eb8 |
+
|
|
|
ca1eb8 |
done:
|
|
|
ca1eb8 |
ldap_controls_free(response_controls);
|
|
|
ca1eb8 |
ldap_memfree(errmsg);
|
|
|
ca1eb8 |
--
|
|
|
ca1eb8 |
2.14.4
|
|
|
ca1eb8 |
|