Blame SOURCES/0006-NEGCACHE-skip-permanent-entries-in-users-groups-rese.patch

8aada9
From 88e92967a7b4e3e4501b17f21812467effa331c7 Mon Sep 17 00:00:00 2001
8aada9
From: Alexey Tikhonov <atikhono@redhat.com>
8aada9
Date: Tue, 16 Jun 2020 13:51:28 +0200
8aada9
Subject: [PATCH] NEGCACHE: skip permanent entries in [users/groups] reset
8aada9
MIME-Version: 1.0
8aada9
Content-Type: text/plain; charset=UTF-8
8aada9
Content-Transfer-Encoding: 8bit
8aada9
8aada9
Files provider calling `sss_ncache_reset_[users/groups]()`
8aada9
during cache rebuilding was breaking neg-cache prepopulation.
8aada9
8aada9
Resolves: https://github.com/SSSD/sssd/issues/1024
8aada9
8aada9
Reviewed-by: Tomáš Halman <thalman@redhat.com>
8aada9
---
8aada9
 src/responder/common/negcache.c | 9 +++++++++
8aada9
 src/responder/common/negcache.h | 1 +
8aada9
 2 files changed, 10 insertions(+)
8aada9
8aada9
diff --git a/src/responder/common/negcache.c b/src/responder/common/negcache.c
8aada9
index d9545aef6..ce1c0ab8c 100644
8aada9
--- a/src/responder/common/negcache.c
8aada9
+++ b/src/responder/common/negcache.c
8aada9
@@ -900,12 +900,21 @@ static int delete_prefix(struct tdb_context *tdb,
8aada9
                          TDB_DATA key, TDB_DATA data, void *state)
8aada9
 {
8aada9
     const char *prefix = (const char *) state;
8aada9
+    unsigned long long int timestamp;
8aada9
+    char *ep = NULL;
8aada9
 
8aada9
     if (strncmp((char *)key.dptr, prefix, strlen(prefix) - 1) != 0) {
8aada9
         /* not interested in this key */
8aada9
         return 0;
8aada9
     }
8aada9
 
8aada9
+    errno = 0;
8aada9
+    timestamp = strtoull((const char *)data.dptr, &ep, 10);
8aada9
+    if ((errno == 0) && (*ep == '\0') && (timestamp == 0)) {
8aada9
+        /* skip permanent entries */
8aada9
+        return 0;
8aada9
+    }
8aada9
+
8aada9
     return tdb_delete(tdb, key);
8aada9
 }
8aada9
 
8aada9
diff --git a/src/responder/common/negcache.h b/src/responder/common/negcache.h
8aada9
index a80412215..4dcfb5e8f 100644
8aada9
--- a/src/responder/common/negcache.h
8aada9
+++ b/src/responder/common/negcache.h
8aada9
@@ -146,6 +146,7 @@ int sss_ncache_set_locate_uid(struct sss_nc_ctx *ctx,
8aada9
                               uid_t uid);
8aada9
 
8aada9
 int sss_ncache_reset_permanent(struct sss_nc_ctx *ctx);
8aada9
+/* sss_ncache_reset_[users/groups] skips permanent entries */
8aada9
 int sss_ncache_reset_users(struct sss_nc_ctx *ctx);
8aada9
 int sss_ncache_reset_groups(struct sss_nc_ctx *ctx);
8aada9
 
8aada9
-- 
8aada9
2.21.3
8aada9