Blame SOURCES/0059-CACHE-Create-timestamp-if-missing.patch

74fd62
From ca8cdbde6285d14181372f1ce8e5f6faf72e1d80 Mon Sep 17 00:00:00 2001
74fd62
From: Tomas Halman <thalman@redhat.com>
74fd62
Date: Mon, 16 Nov 2020 17:28:19 +0100
74fd62
Subject: [PATCH 59/60] CACHE: Create timestamp if missing
74fd62
MIME-Version: 1.0
74fd62
Content-Type: text/plain; charset=UTF-8
74fd62
Content-Transfer-Encoding: 8bit
74fd62
74fd62
In some cases, object is stored in cache but the corresponding
74fd62
record in timestamp cache is missing (for example when timestamp
74fd62
cache file is deleted). The timestamp is never created in such
74fd62
case.
74fd62
74fd62
With this patch we create new timestamp object if update doesn't
74fd62
work for this particular reason (missing object).
74fd62
74fd62
Resolves: https://github.com/SSSD/sssd/issues/5121
74fd62
74fd62
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
74fd62
(cherry picked from commit 37761b42f570e9019f9dd850912a29385e80a14c)
74fd62
---
74fd62
 src/db/sysdb_ops.c | 10 +++++++++-
74fd62
 1 file changed, 9 insertions(+), 1 deletion(-)
74fd62
74fd62
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
74fd62
index d4ad69e39..0e0a95961 100644
74fd62
--- a/src/db/sysdb_ops.c
74fd62
+++ b/src/db/sysdb_ops.c
74fd62
@@ -1371,9 +1371,17 @@ int sysdb_set_entry_attr(struct sysdb_ctx *sysdb,
74fd62
 
74fd62
     if (ret == EOK && is_ts_ldb_dn(entry_dn)) {
74fd62
         tret = sysdb_set_ts_entry_attr(sysdb, entry_dn, attrs, mod_op);
74fd62
+        if (tret == ENOENT && mod_op == SYSDB_MOD_REP) {
74fd62
+            /* Update failed because TS does non exist. Create missing TS */
74fd62
+            tret = sysdb_set_ts_entry_attr(sysdb, entry_dn, attrs,
74fd62
+                                           SYSDB_MOD_ADD);
74fd62
+            DEBUG(SSSDBG_TRACE_FUNC,
74fd62
+                  "The TS value for %s does not exist, trying to create it\n",
74fd62
+                  ldb_dn_get_linearized(entry_dn));
74fd62
+        }
74fd62
         if (tret != EOK) {
74fd62
             DEBUG(SSSDBG_MINOR_FAILURE,
74fd62
-                "Cannot set ts attrs for %s\n", ldb_dn_get_linearized(entry_dn));
74fd62
+                "Cannot set TS attrs for %s\n", ldb_dn_get_linearized(entry_dn));
74fd62
             /* Not fatal */
74fd62
         } else {
74fd62
             state_mask |= SSS_SYSDB_TS_CACHE;
74fd62
-- 
74fd62
2.21.3
74fd62