diff options
| author | Simo Sorce <simo@redhat.com> | 2016-07-19 07:43:50 -0400 |
|---|---|---|
| committer | Simo Sorce <simo@redhat.com> | 2016-07-20 06:08:05 -0400 |
| commit | fec7ed2d2d7d8352d1a6a9cf5607476c9fd5d65f (patch) | |
| tree | 565750d5473ee095c4a64da4116f1a0540b1b907 /daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c | |
| parent | 72b2c8a54de09d6e5c1cc82c951d5bfd06938e88 (diff) | |
| download | freeipa-mindatefix.tar.gz freeipa-mindatefix.tar.xz freeipa-mindatefix.zip | |
Simplify date manipulation in pwd pluginmindatefix
Use a helper function to perform operations on dates in LDAP attributes.
Related to #2795
Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c')
| -rw-r--r-- | daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c index 9d923d6fb..c62eae334 100644 --- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c +++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c @@ -1028,8 +1028,6 @@ static int ipapwd_post_modadd(Slapi_PBlock *pb) struct ipapwd_operation *pwdop = NULL; Slapi_Mods *smods; Slapi_Value **pwvals; - struct tm utctime; - char timestr[GENERALIZED_TIME_LENGTH+1]; int ret; char *errMsg = "Internal operations error\n"; struct ipapwd_krbcfg *krbcfg = NULL; @@ -1115,29 +1113,19 @@ static int ipapwd_post_modadd(Slapi_PBlock *pb) (slapi_entry_attr_has_syntax_value(pwdop->pwdata.target, SLAPI_ATTR_OBJECTCLASS, ipahost)) == 0) { /* set Password Expiration date */ - if (!gmtime_r(&(pwdop->pwdata.expireTime), &utctime)) { - LOG_FATAL("failed to parse expiration date (buggy gmtime_r ?)\n"); + ret = ipapwd_setdate(pwdop->pwdata.target, smods, + "krbPasswordExpiration", + pwdop->pwdata.expireTime, + (pwdop->pwdata.expireTime == 0)); + if (ret != LDAP_SUCCESS) goto done; - } - strftime(timestr, GENERALIZED_TIME_LENGTH+1, - "%Y%m%d%H%M%SZ", &utctime); - slapi_mods_add_string(smods, LDAP_MOD_REPLACE, - "krbPasswordExpiration", timestr); - if (pwdop->pwdata.expireTime == 0) { - slapi_mods_add_string(smods, LDAP_MOD_DELETE, - "krbPasswordExpiration", timestr); - } /* change Last Password Change field with the current date */ - if (!gmtime_r(&(pwdop->pwdata.timeNow), &utctime)) { - LOG_FATAL("failed to parse current date (buggy gmtime_r ?)\n"); - slapi_value_free(&ipahost); + ret = ipapwd_setdate(pwdop->pwdata.target, smods, + "krbLastPwdChange", + pwdop->pwdata.timeNow, false); + if (ret != LDAP_SUCCESS) goto done; - } - strftime(timestr, GENERALIZED_TIME_LENGTH+1, - "%Y%m%d%H%M%SZ", &utctime); - slapi_mods_add_string(smods, LDAP_MOD_REPLACE, - "krbLastPwdChange", timestr); } slapi_value_free(&ipahost); } @@ -1391,6 +1379,7 @@ static int ipapwd_pre_bind(Slapi_PBlock *pb) SLAPI_USERPWD_ATTR, "ipaUserAuthType", "krbprincipalkey", "uid", "krbprincipalname", "objectclass", "passwordexpirationtime", "passwordhistory", "krbprincipalexpiration", "krbcanonicalname", + "krbPasswordExpiration", "krblastpwchange", NULL }; struct berval *credentials = NULL; |
