From e61587a5d620310c09f226f43c9bb3008481bbe3 Mon Sep 17 00:00:00 2001 From: Michal Zidek Date: Thu, 13 Dec 2012 17:38:55 +0100 Subject: sssd_nss: Remove entries from memory cache if not found in sysdb Functions nss_cmd_getXXnam remove entries from memory cache if not found in sysdb cache of a local domain. --- src/responder/nss/nsssrv_cmd.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/responder/nss/nsssrv_cmd.c') diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c index 14bb3afe..c30e21ee 100644 --- a/src/responder/nss/nsssrv_cmd.c +++ b/src/responder/nss/nsssrv_cmd.c @@ -660,6 +660,7 @@ static int nss_cmd_getpwnam_search(struct nss_dom_ctx *dctx) struct sss_domain_info *dom = dctx->domain; struct cli_ctx *cctx = cmdctx->cctx; char *name = NULL; + struct sized_string delete_usrname; struct sysdb_ctx *sysdb; struct nss_ctx *nctx; int ret; @@ -744,6 +745,17 @@ static int nss_cmd_getpwnam_search(struct nss_dom_ctx *dctx) DEBUG(2, ("No results for getpwnam call\n")); + /* User not found in ldb -> delete user from memory cache. */ + to_sized_string(&delete_usrname, name); + ret = sss_mmap_cache_pw_invalidate(nctx->pwd_mc_ctx, + &delete_usrname); + if (ret != EOK && ret != ENOENT) { + DEBUG(SSSDBG_CRIT_FAILURE, + ("Internal failure in memory cache code: %d [%s]\n", + ret, strerror(ret))); + } + + return ENOENT; } @@ -2250,6 +2262,7 @@ static int nss_cmd_getgrnam_search(struct nss_dom_ctx *dctx) struct sss_domain_info *dom = dctx->domain; struct cli_ctx *cctx = cmdctx->cctx; char *name = NULL; + struct sized_string delete_grpname; struct sysdb_ctx *sysdb; struct nss_ctx *nctx; int ret; @@ -2334,6 +2347,16 @@ static int nss_cmd_getgrnam_search(struct nss_dom_ctx *dctx) DEBUG(2, ("No results for getgrnam call\n")); + /* Group not found in ldb -> delete group from memory cache. */ + to_sized_string(&delete_grpname, name); + ret = sss_mmap_cache_gr_invalidate(nctx->grp_mc_ctx, + &delete_grpname); + if (ret != EOK && ret != ENOENT) { + DEBUG(SSSDBG_CRIT_FAILURE, + ("Internal failure in memory cache code: %d [%s]\n", + ret, strerror(ret))); + } + return ENOENT; } -- cgit