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