|
|
8d3578 |
From fb3f1af38edff257d603da165e0d64d12d92644e Mon Sep 17 00:00:00 2001
|
|
|
8d3578 |
From: Tomas Halman <thalman@redhat.com>
|
|
|
8d3578 |
Date: Sun, 16 Dec 2018 08:46:24 +0100
|
|
|
8d3578 |
Subject: [PATCH] CACHE: SSSD doesn't clear cache entries
|
|
|
8d3578 |
MIME-Version: 1.0
|
|
|
8d3578 |
Content-Type: text/plain; charset=UTF-8
|
|
|
8d3578 |
Content-Transfer-Encoding: 8bit
|
|
|
8d3578 |
|
|
|
8d3578 |
Once object is in cache it is refreshed when it is expired and
|
|
|
8d3578 |
requested by the system. Object ID is not checked before refresh,
|
|
|
8d3578 |
but config parameter ldap_(min|max)_id could be changed by admin.
|
|
|
8d3578 |
We should check object ID and not refresh objects outside min/max
|
|
|
8d3578 |
ID interval.
|
|
|
8d3578 |
|
|
|
8d3578 |
Resolves:
|
|
|
8d3578 |
https://pagure.io/SSSD/sssd/issue/3905
|
|
|
8d3578 |
|
|
|
8d3578 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
8d3578 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
8d3578 |
(cherry picked from commit d2adfcf54c3a37aeda675aec3ba3d174061fac1a)
|
|
|
8d3578 |
---
|
|
|
8d3578 |
.../common/cache_req/cache_req_search.c | 29 +++++++++++++++++++
|
|
|
8d3578 |
1 file changed, 29 insertions(+)
|
|
|
8d3578 |
|
|
|
8d3578 |
diff --git a/src/responder/common/cache_req/cache_req_search.c b/src/responder/common/cache_req/cache_req_search.c
|
|
|
8d3578 |
index 7423feb63..873214503 100644
|
|
|
8d3578 |
--- a/src/responder/common/cache_req/cache_req_search.c
|
|
|
8d3578 |
+++ b/src/responder/common/cache_req/cache_req_search.c
|
|
|
8d3578 |
@@ -25,6 +25,7 @@
|
|
|
8d3578 |
#include "util/util.h"
|
|
|
8d3578 |
#include "responder/common/cache_req/cache_req_private.h"
|
|
|
8d3578 |
#include "responder/common/cache_req/cache_req_plugin.h"
|
|
|
8d3578 |
+#include "db/sysdb.h"
|
|
|
8d3578 |
|
|
|
8d3578 |
static errno_t cache_req_search_ncache(struct cache_req *cr)
|
|
|
8d3578 |
{
|
|
|
8d3578 |
@@ -169,6 +170,30 @@ done:
|
|
|
8d3578 |
return ret;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
+static int
|
|
|
8d3578 |
+cache_req_should_be_in_cache(struct cache_req *cr,
|
|
|
8d3578 |
+ struct ldb_result *result)
|
|
|
8d3578 |
+{
|
|
|
8d3578 |
+ id_t id = 0;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ if (result == NULL || result->count != 1) {
|
|
|
8d3578 |
+ /* can't decide so keep it */
|
|
|
8d3578 |
+ return EOK;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ id = ldb_msg_find_attr_as_uint(result->msgs[0], SYSDB_UIDNUM, 0);
|
|
|
8d3578 |
+ if (id && OUT_OF_ID_RANGE(id, cr->domain->id_min, cr->domain->id_max)) {
|
|
|
8d3578 |
+ return ERR_ID_OUTSIDE_RANGE;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ id = ldb_msg_find_attr_as_uint(result->msgs[0], SYSDB_GIDNUM, 0);
|
|
|
8d3578 |
+ if (id && OUT_OF_ID_RANGE(id, cr->domain->id_min, cr->domain->id_max)) {
|
|
|
8d3578 |
+ return ERR_ID_OUTSIDE_RANGE;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ return EOK;
|
|
|
8d3578 |
+}
|
|
|
8d3578 |
+
|
|
|
8d3578 |
static errno_t cache_req_search_cache(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
struct cache_req *cr,
|
|
|
8d3578 |
struct ldb_result **_result)
|
|
|
8d3578 |
@@ -191,6 +216,10 @@ static errno_t cache_req_search_cache(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
ret = ENOENT;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
+ if (ret == EOK) {
|
|
|
8d3578 |
+ ret = cache_req_should_be_in_cache(cr, result);
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
switch (ret) {
|
|
|
8d3578 |
case EOK:
|
|
|
8d3578 |
if (cr->plugin->only_one_result && result->count > 1) {
|
|
|
8d3578 |
--
|
|
|
8d3578 |
2.20.1
|
|
|
8d3578 |
|