From 1d0a914578ce72bad86cbe9e0beeda0c3b2d1dee Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 8 Aug 2016 17:30:29 +0200
Subject: [PATCH 81/82] NSS: Use correct name for invalidating memory cache
After refactoring of sysdb, we get and internal fully qualified
name from backend in org.freedesktop.sssd.dataprovider_rev.initgrCheck
Previously we got short name and we created fq name in
nss_update_initgr_memcache. Memory cache still need to use short names
if it was specified.
This patch uses right name in different places.
Reviewed-by: Petr Cech <pcech@redhat.com>
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
---
src/responder/nss/nsssrv_cmd.c | 31 +++++++++++++++++--------------
src/responder/nss/nsssrv_private.h | 2 +-
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index f3b6ac4afb5d1571f283933b48e0256b91c56391..573959ea76fc1277fe84f40b88dcd34093da468d 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -3961,13 +3961,13 @@ done:
}
void nss_update_initgr_memcache(struct nss_ctx *nctx,
- const char *name, const char *domain,
+ const char *fq_name, const char *domain,
int gnum, uint32_t *groups)
{
TALLOC_CTX *tmp_ctx = NULL;
struct sss_domain_info *dom;
struct ldb_result *res;
- struct sized_string delete_name;
+ struct sized_string *delete_name;
bool changed = false;
uint32_t id;
uint32_t gids[gnum];
@@ -3987,8 +3987,19 @@ void nss_update_initgr_memcache(struct nss_ctx *nctx,
}
tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ return;
+ }
- ret = sysdb_initgroups(tmp_ctx, dom, name, &res);
+ ret = sized_output_name(tmp_ctx, nctx->rctx, fq_name, dom, &delete_name);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE,
+ "sized_output_name failed for '%s': %d [%s]\n",
+ fq_name, ret, sss_strerror(ret));
+ goto done;
+ }
+
+ ret = sysdb_initgroups(tmp_ctx, dom, fq_name, &res);
if (ret != EOK && ret != ENOENT) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Failed to make request to our cache! [%d][%s]\n",
@@ -4002,8 +4013,7 @@ void nss_update_initgr_memcache(struct nss_ctx *nctx,
if (ret == ENOENT || res->count == 0) {
/* The user is gone. Invalidate the mc record */
- to_sized_string(&delete_name, name);
- ret = sss_mmap_cache_pw_invalidate(nctx->pwd_mc_ctx, &delete_name);
+ ret = sss_mmap_cache_pw_invalidate(nctx->pwd_mc_ctx, delete_name);
if (ret != EOK && ret != ENOENT) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Internal failure in memory cache code: %d [%s]\n",
@@ -4047,13 +4057,6 @@ void nss_update_initgr_memcache(struct nss_ctx *nctx,
}
if (changed) {
- char *fq_name = sss_tc_fqname(tmp_ctx, dom->names, dom, name);
- if (!fq_name) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- "Could not create fq name\n");
- goto done;
- }
-
for (i = 0; i < gnum; i++) {
id = groups[i];
@@ -4065,9 +4068,9 @@ void nss_update_initgr_memcache(struct nss_ctx *nctx,
}
}
- to_sized_string(&delete_name, fq_name);
+ to_sized_string(delete_name, fq_name);
ret = sss_mmap_cache_initgr_invalidate(nctx->initgr_mc_ctx,
- &delete_name);
+ delete_name);
if (ret != EOK && ret != ENOENT) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Internal failure in memory cache code: %d [%s]\n",
diff --git a/src/responder/nss/nsssrv_private.h b/src/responder/nss/nsssrv_private.h
index 79c7b7265f66f57e0ea89fe192a1da4f8992f1a3..391eaaf40f84a7436bee63fd699241e4957fdbeb 100644
--- a/src/responder/nss/nsssrv_private.h
+++ b/src/responder/nss/nsssrv_private.h
@@ -146,7 +146,7 @@ errno_t check_cache(struct nss_dom_ctx *dctx,
void nss_update_pw_memcache(struct nss_ctx *nctx);
void nss_update_gr_memcache(struct nss_ctx *nctx);
void nss_update_initgr_memcache(struct nss_ctx *nctx,
- const char *name, const char *domain,
+ const char *fq_name, const char *domain,
int gnum, uint32_t *groups);
int nss_connection_setup(struct cli_ctx *cctx);
--
2.4.11