Blame SOURCES/0015-sysdb_sudo-Enable-LDAP-time-format-compatibility.patch

0d097b
From 9ba6f33ee78e1c15847f11b8f75f8a8413034875 Mon Sep 17 00:00:00 2001
0d097b
From: =?UTF-8?q?Pawe=C5=82=20Po=C5=82awski?= <ppolawsk@redhat.com>
0d097b
Date: Tue, 3 Dec 2019 04:13:53 +0100
0d097b
Subject: [PATCH] sysdb_sudo: Enable LDAP time format compatibility
0d097b
MIME-Version: 1.0
0d097b
Content-Type: text/plain; charset=UTF-8
0d097b
Content-Transfer-Encoding: 8bit
0d097b
0d097b
LDAP specification allows to ommit seconds and minutes
0d097b
in time border definition. In that case they defaults to zeros.
0d097b
Current sssd.sudo implementation requires precision up to
0d097b
seconds in time definition. This commit allows to lower
0d097b
the precision up to hours.
0d097b
0d097b
Resolves:
0d097b
https://pagure.io/SSSD/sssd/issue/4118
0d097b
0d097b
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
0d097b
---
0d097b
 src/db/sysdb_sudo.c | 16 ++++++++++++++++
0d097b
 1 file changed, 16 insertions(+)
0d097b
0d097b
diff --git a/src/db/sysdb_sudo.c b/src/db/sysdb_sudo.c
0d097b
index 59d6824c0..18088b017 100644
0d097b
--- a/src/db/sysdb_sudo.c
0d097b
+++ b/src/db/sysdb_sudo.c
0d097b
@@ -55,6 +55,22 @@ static errno_t sysdb_sudo_convert_time(const char *str, time_t *unix_time)
0d097b
                              "%Y%m%d%H%M%S.0%z",
0d097b
                              "%Y%m%d%H%M%S,0Z",
0d097b
                              "%Y%m%d%H%M%S,0%z",
0d097b
+                             /* LDAP specification says that minutes and seconds
0d097b
+                                might be omitted and in that case these are meant
0d097b
+                                to be treated as zeros [1].
0d097b
+                             */
0d097b
+                             "%Y%m%d%H%MZ",    /* Discard seconds */
0d097b
+                             "%Y%m%d%H%M%z",
0d097b
+                             "%Y%m%d%H%M.0Z",
0d097b
+                             "%Y%m%d%H%M.0%z",
0d097b
+                             "%Y%m%d%H%M,0Z",
0d097b
+                             "%Y%m%d%H%M,0%z",
0d097b
+                             "%Y%m%d%HZ",    /* Discard minutes and seconds*/
0d097b
+                             "%Y%m%d%H%z",
0d097b
+                             "%Y%m%d%H.0Z",
0d097b
+                             "%Y%m%d%H.0%z",
0d097b
+                             "%Y%m%d%H,0Z",
0d097b
+                             "%Y%m%d%H,0%z",
0d097b
                              NULL};
0d097b
 
0d097b
     for (format = formats; *format != NULL; format++) {
0d097b
-- 
0d097b
2.20.1
0d097b