From 844c6291e681d5aa27b70d17bbd4b811b2ff2494 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Wed, 28 Aug 2013 16:30:26 -0400 Subject: [PATCH] Ticket 47371 - Some updates of "passwordgraceusertime" are useless when updating "userpassword" Bug Description: "passwordgraceusertime" is always reset to "0" after a password change. Even if the the current value is "0". Fix Description: Only reset the value to "0" if the current value is not "0". https://fedorahosted.org/389/ticket/47371 Reveiwed by: ? --- ldap/servers/slapd/pw.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c index b9d54a3..8d73753 100644 --- a/ldap/servers/slapd/pw.c +++ b/ldap/servers/slapd/pw.c @@ -585,6 +585,7 @@ int update_pw_info ( Slapi_PBlock *pb , char *old_pw) { Slapi_Operation *operation = NULL; + Slapi_Entry *e = NULL; Slapi_DN *sdn = NULL; Slapi_Mods smods; passwdPolicy *pwpolicy = NULL; @@ -594,9 +595,10 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw) char *timestr; int internal_op = 0; - slapi_pblock_get(pb, SLAPI_OPERATION, &operation); + slapi_pblock_get( pb, SLAPI_OPERATION, &operation); slapi_pblock_get( pb, SLAPI_TARGET_SDN, &sdn ); slapi_pblock_get( pb, SLAPI_REQUESTOR_NDN, &bind_dn); + slapi_pblock_get( pb, SLAPI_ENTRY_PRE_OP, &e); internal_op = slapi_operation_is_flag_set(operation, SLAPI_OP_FLAG_INTERNAL); target_dn = slapi_sdn_get_ndn(sdn); pwpolicy = new_passwdPolicy(pb, target_dn); @@ -633,8 +635,10 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw) set_retry_cnt_mods (pb, &smods, 0 ); } - /* Clear the passwordgraceusertime from the user entry */ - slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordgraceusertime", "0"); + if(!slapi_entry_attr_hasvalue(e,"passwordgraceusertime", "0")){ + /* Clear the passwordgraceusertime from the user entry */ + slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordgraceusertime", "0"); + } /* * If the password is reset by a different user, mark it the first time logon. If this is an internal -- 1.7.1