From 58a67cd38b8be9bef45ce70588763d851840dd65 Mon Sep 17 00:00:00 2001 From: Paweł Poławski Date: Dec 04 2019 11:02:48 +0000 Subject: sysdb_sudo: Enable LDAP time format compatibility LDAP specification allows to ommit seconds and minutes in time border definition. In that case they defaults to zeros. Current sssd.sudo implementation requires precision up to seconds in time definition. This commit allows to lower the precision up to hours. Resolves: https://pagure.io/SSSD/sssd/issue/4118 Reviewed-by: Pavel Březina --- diff --git a/src/db/sysdb_sudo.c b/src/db/sysdb_sudo.c index 59d6824..18088b0 100644 --- a/src/db/sysdb_sudo.c +++ b/src/db/sysdb_sudo.c @@ -55,6 +55,22 @@ static errno_t sysdb_sudo_convert_time(const char *str, time_t *unix_time) "%Y%m%d%H%M%S.0%z", "%Y%m%d%H%M%S,0Z", "%Y%m%d%H%M%S,0%z", + /* LDAP specification says that minutes and seconds + might be omitted and in that case these are meant + to be treated as zeros [1]. + */ + "%Y%m%d%H%MZ", /* Discard seconds */ + "%Y%m%d%H%M%z", + "%Y%m%d%H%M.0Z", + "%Y%m%d%H%M.0%z", + "%Y%m%d%H%M,0Z", + "%Y%m%d%H%M,0%z", + "%Y%m%d%HZ", /* Discard minutes and seconds*/ + "%Y%m%d%H%z", + "%Y%m%d%H.0Z", + "%Y%m%d%H.0%z", + "%Y%m%d%H,0Z", + "%Y%m%d%H,0%z", NULL}; for (format = formats; *format != NULL; format++) {