diff options
author | Pavel Reichl <preichl@redhat.com> | 2015-03-16 06:51:37 -0400 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2015-03-23 12:07:03 +0100 |
commit | 08f83281cf4b0f35e8569851fae7364e140371f9 (patch) | |
tree | 803e0aa28ccbc42eb427d1c29ccd1252d5a3aef7 /src/providers | |
parent | 0ec41ab7d3fbb021967de16ea000c69dcedf7cb5 (diff) | |
download | sssd-08f83281cf4b0f35e8569851fae7364e140371f9.tar.gz sssd-08f83281cf4b0f35e8569851fae7364e140371f9.tar.xz sssd-08f83281cf4b0f35e8569851fae7364e140371f9.zip |
ldap: refactor nds_check_expired to use util func
Refactor nds_check_expired() to use utility function sss_utc_to_time_t().
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/providers')
-rw-r--r-- | src/providers/ldap/sdap_access.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/src/providers/ldap/sdap_access.c b/src/providers/ldap/sdap_access.c index 9e9cfc9e3..537ea7193 100644 --- a/src/providers/ldap/sdap_access.c +++ b/src/providers/ldap/sdap_access.c @@ -530,10 +530,9 @@ static errno_t sdap_account_expired_rhds(struct pam_data *pd, bool nds_check_expired(const char *exp_time_str) { - char *end; - struct tm tm; time_t expire_time; time_t now; + errno_t ret; if (exp_time_str == NULL) { DEBUG(SSSDBG_TRACE_ALL, @@ -541,30 +540,14 @@ bool nds_check_expired(const char *exp_time_str) return false; } - memset(&tm, 0, sizeof(tm)); - - end = strptime(exp_time_str, "%Y%m%d%H%M%SZ", &tm); - if (end == NULL) { - DEBUG(SSSDBG_CRIT_FAILURE, - "NDS expire date [%s] invalid.\n", exp_time_str); - return true; - } - if (*end != '\0') { - DEBUG(SSSDBG_CRIT_FAILURE, - "NDS expire date [%s] contains extra characters.\n", - exp_time_str); - return true; - } - - expire_time = mktime(&tm); - if (expire_time == -1) { - DEBUG(SSSDBG_CRIT_FAILURE, - "mktime failed to convert [%s].\n", exp_time_str); + ret = sss_utc_to_time_t(exp_time_str, "%Y%m%d%H%M%SZ", + &expire_time); + if (ret != EOK) { + DEBUG(SSSDBG_MINOR_FAILURE, "sss_utc_to_time_t failed with %d:%s.\n", + ret, sss_strerror(ret)); return true; } - tzset(); - expire_time -= timezone; now = time(NULL); DEBUG(SSSDBG_TRACE_ALL, "Time info: tzname[0] [%s] tzname[1] [%s] timezone [%ld] " |