From ee660b069f63971047d98bd98313dfa54709ce6c Mon Sep 17 00:00:00 2001
From: Petr Cech <pcech@redhat.com>
Date: Wed, 4 May 2016 11:36:18 -0400
Subject: [PATCH 2/6] RESPONDER: Removing ncache from nss_ctx

This patch switches ncache from nss_ctx to resp_ctx.
---
 src/responder/nss/nsssrv.c          | 15 ++-------
 src/responder/nss/nsssrv.h          |  2 --
 src/responder/nss/nsssrv_cmd.c      | 67 +++++++++++++++++--------------------
 src/responder/nss/nsssrv_netgroup.c |  4 +--
 src/responder/nss/nsssrv_services.c | 12 +++----
 src/tests/cmocka/test_negcache.c    |  6 ----
 src/tests/cmocka/test_nss_srv.c     |  6 ----
 7 files changed, 40 insertions(+), 72 deletions(-)

diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index 363ee7bffac5a3fa61a9d81ae5821ed6ffaa50d7..2cc934c45b27bcb423e88d6bf6886e40e1168ca3 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -247,7 +247,7 @@ static int nss_get_config(struct nss_ctx *nctx,
         nctx->cache_refresh_percent = 0;
     }
 
-    ret = sss_ncache_prepopulate(nctx->ncache, cdb, nctx->rctx);
+    ret = sss_ncache_prepopulate(nctx->rctx->ncache, cdb, nctx->rctx);
     if (ret != EOK) {
         goto done;
     }
@@ -411,7 +411,6 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
     enum idmap_error_code err;
     int hret;
     int fd_limit;
-    uint32_t neg_timeout;
 
     nss_cmds = get_nss_cmds();
 
@@ -436,16 +435,6 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
         goto fail;
     }
 
-    ret = responder_get_neg_timeout_from_confdb(cdb, &neg_timeout);
-    if (ret != EOK) goto fail;
-
-    ret = sss_ncache_init(rctx, neg_timeout, &nctx->ncache);
-    if (ret != EOK) {
-        DEBUG(SSSDBG_FATAL_FAILURE,
-              "fatal error initializing negative cache\n");
-        goto fail;
-    }
-
     nctx->rctx = rctx;
     nctx->rctx->pvt_ctx = nctx;
 
@@ -545,7 +534,7 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
     }
     responder_set_fd_limit(fd_limit);
 
-    ret = schedule_get_domains_task(rctx, rctx->ev, rctx, nctx->ncache);
+    ret = schedule_get_domains_task(rctx, rctx->ev, rctx, nctx->rctx->ncache);
     if (ret != EOK) {
         DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
         goto fail;
diff --git a/src/responder/nss/nsssrv.h b/src/responder/nss/nsssrv.h
index 28e62b78acf85299c5d813182fca68ca964549d3..2977479aa52082480f92eab94f7833e2e696a9ac 100644
--- a/src/responder/nss/nsssrv.h
+++ b/src/responder/nss/nsssrv.h
@@ -44,8 +44,6 @@ struct sss_mc_ctx;
 struct nss_ctx {
     struct resp_ctx *rctx;
 
-    struct sss_nc_ctx *ncache;
-
     int cache_refresh_percent;
 
     int enum_cache_timeout;
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 30daf4bc5791283f20c2d39725e487ac827347ce..0c7bf8adad8695082e7dfb376836c2398f6b46b4 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -108,14 +108,7 @@ struct setent_ctx {
 
 static int nss_reset_negcache(struct resp_ctx *rctx)
 {
-    struct nss_ctx *nss_ctx;
-
-    nss_ctx = talloc_get_type(rctx->pvt_ctx, struct nss_ctx);
-    if (nss_ctx == NULL) {
-        return EIO;
-    }
-
-    return sss_ncache_reset_repopulate_permanent(rctx, nss_ctx->ncache);
+    return sss_ncache_reset_repopulate_permanent(rctx, rctx->ncache);
 }
 
 /****************************************************************************
@@ -408,7 +401,7 @@ static int fill_pwent(struct sss_packet *packet,
         }
 
         if (filter_users) {
-            ncret = sss_ncache_check_user(nctx->ncache, dom, orig_name);
+            ncret = sss_ncache_check_user(nctx->rctx->ncache, dom, orig_name);
             if (ncret == EEXIST) {
                 DEBUG(SSSDBG_TRACE_FUNC,
                       "User [%s@%s] filtered out! (negative cache)\n",
@@ -1007,7 +1000,7 @@ static int nss_cmd_getpwnam_search(struct nss_dom_ctx *dctx)
 
         /* verify this user has not yet been negatively cached,
         * or has been permanently filtered */
-        ret = sss_ncache_check_user(nctx->ncache, dom, name);
+        ret = sss_ncache_check_user(nctx->rctx->ncache, dom, name);
 
         /* if neg cached, return we didn't find it */
         if (ret == EEXIST) {
@@ -1087,7 +1080,7 @@ static int nss_cmd_getpwnam_search(struct nss_dom_ctx *dctx)
 
         if (dctx->res->count == 0 && !dctx->check_provider) {
             /* set negative cache only if not result of cache check */
-            ret = sss_ncache_set_user(nctx->ncache, false, dom, name);
+            ret = sss_ncache_set_user(nctx->rctx->ncache, false, dom, name);
             if (ret != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE, "Cannot set negcache for %s@%s\n",
                       name, dom->name);
@@ -1266,7 +1259,7 @@ static void nss_cmd_getby_dp_callback(uint16_t err_maj, uint32_t err_min,
          * here. */
         switch (dctx->cmdctx->cmd) {
         case SSS_NSS_GETPWUID:
-            ret = sss_ncache_set_uid(nctx->ncache, false, dctx->domain,
+            ret = sss_ncache_set_uid(nctx->rctx->ncache, false, dctx->domain,
                                      cmdctx->id);
             if (ret != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE,
@@ -1276,7 +1269,7 @@ static void nss_cmd_getby_dp_callback(uint16_t err_maj, uint32_t err_min,
             gnd_flags = SSS_GND_DESCEND;
             break;
         case SSS_NSS_GETGRGID:
-            ret = sss_ncache_set_gid(nctx->ncache, false, dctx->domain,
+            ret = sss_ncache_set_gid(nctx->rctx->ncache, false, dctx->domain,
                                      cmdctx->id);
             if (ret != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE,
@@ -1286,14 +1279,14 @@ static void nss_cmd_getby_dp_callback(uint16_t err_maj, uint32_t err_min,
             gnd_flags = SSS_GND_DESCEND;
             break;
         case SSS_NSS_GETSIDBYID:
-            ret = sss_ncache_set_uid(nctx->ncache, false, dctx->domain,
+            ret = sss_ncache_set_uid(nctx->rctx->ncache, false, dctx->domain,
                                      cmdctx->id);
             if (ret != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE,
                       "Cannot set negative cache for UID %"PRIu32"\n",
                        cmdctx->id);
             }
-            ret = sss_ncache_set_gid(nctx->ncache, false, dctx->domain,
+            ret = sss_ncache_set_gid(nctx->rctx->ncache, false, dctx->domain,
                                      cmdctx->id);
             if (ret != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE,
@@ -1876,7 +1869,7 @@ static int nss_cmd_getpwuid_search(struct nss_dom_ctx *dctx)
 done:
     if (ret == ENOENT) {
         /* The entry was not found, need to set result in negative cache */
-        err = sss_ncache_set_uid(nctx->ncache, false, NULL, cmdctx->id);
+        err = sss_ncache_set_uid(nctx->rctx->ncache, false, NULL, cmdctx->id);
         if (err != EOK) {
             DEBUG(SSSDBG_MINOR_FAILURE,
                 "Cannot set negative cache for UID %"PRIu32"\n", cmdctx->id);
@@ -1947,7 +1940,7 @@ static int nss_cmd_getbyid(enum sss_cli_command cmd, struct cli_ctx *cctx)
 
     switch(dctx->cmdctx->cmd) {
     case SSS_NSS_GETPWUID:
-        ret = sss_ncache_check_uid(nctx->ncache, NULL, cmdctx->id);
+        ret = sss_ncache_check_uid(nctx->rctx->ncache, NULL, cmdctx->id);
         if (ret == EEXIST) {
             DEBUG(SSSDBG_TRACE_FUNC,
                   "Uid [%"PRIu32"] does not exist! (negative cache)\n",
@@ -1957,7 +1950,7 @@ static int nss_cmd_getbyid(enum sss_cli_command cmd, struct cli_ctx *cctx)
         }
         break;
     case SSS_NSS_GETGRGID:
-        ret = sss_ncache_check_gid(nctx->ncache, NULL, cmdctx->id);
+        ret = sss_ncache_check_gid(nctx->rctx->ncache, NULL, cmdctx->id);
         if (ret == EEXIST) {
             DEBUG(SSSDBG_TRACE_FUNC,
                   "Gid [%"PRIu32"] does not exist! (negative cache)\n",
@@ -1967,9 +1960,9 @@ static int nss_cmd_getbyid(enum sss_cli_command cmd, struct cli_ctx *cctx)
         }
         break;
     case SSS_NSS_GETSIDBYID:
-        ret = sss_ncache_check_uid(nctx->ncache, NULL, cmdctx->id);
+        ret = sss_ncache_check_uid(nctx->rctx->ncache, NULL, cmdctx->id);
         if (ret != EEXIST) {
-            ret = sss_ncache_check_gid(nctx->ncache, NULL, cmdctx->id);
+            ret = sss_ncache_check_gid(nctx->rctx->ncache, NULL, cmdctx->id);
         }
         if (ret == EEXIST) {
             DEBUG(SSSDBG_TRACE_FUNC,
@@ -2823,7 +2816,7 @@ static int fill_members(struct sss_packet *packet,
         }
 
         if (nctx->filter_users_in_groups) {
-            ret = sss_ncache_check_user(nctx->ncache, dom, tmpstr);
+            ret = sss_ncache_check_user(nctx->rctx->ncache, dom, tmpstr);
             if (ret == EEXIST) {
                 DEBUG(SSSDBG_TRACE_FUNC,
                       "Group [%s] member [%s@%s] filtered out!"
@@ -2979,7 +2972,7 @@ static int fill_grent(struct sss_packet *packet,
         }
 
         if (filter_groups) {
-            ret = sss_ncache_check_group(nctx->ncache, dom, orig_name);
+            ret = sss_ncache_check_group(nctx->rctx->ncache, dom, orig_name);
             if (ret == EEXIST) {
                 DEBUG(SSSDBG_TRACE_FUNC,
                       "Group [%s@%s] filtered out! (negative cache)\n",
@@ -3216,7 +3209,7 @@ static int nss_cmd_getgrnam_search(struct nss_dom_ctx *dctx)
 
         /* verify this group has not yet been negatively cached,
         * or has been permanently filtered */
-        ret = sss_ncache_check_group(nctx->ncache, dom, name);
+        ret = sss_ncache_check_group(nctx->rctx->ncache, dom, name);
 
         /* if neg cached, return we didn't find it */
         if (ret == EEXIST) {
@@ -3262,7 +3255,7 @@ static int nss_cmd_getgrnam_search(struct nss_dom_ctx *dctx)
 
         if (dctx->res->count == 0 && !dctx->check_provider) {
             /* set negative cache only if not result of cache check */
-            ret = sss_ncache_set_group(nctx->ncache, false, dom, name);
+            ret = sss_ncache_set_group(nctx->rctx->ncache, false, dom, name);
             if (ret != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE, "Cannot set negcache for %s@%s\n",
                       name, dom->name);
@@ -3453,7 +3446,7 @@ static int nss_cmd_getgrgid_search(struct nss_dom_ctx *dctx)
 done:
     if (ret == ENOENT) {
         /* The entry was not found, need to set result in negative cache */
-        err = sss_ncache_set_gid(nctx->ncache, false, NULL, cmdctx->id);
+        err = sss_ncache_set_gid(nctx->rctx->ncache, false, NULL, cmdctx->id);
         if (err != EOK) {
             DEBUG(SSSDBG_MINOR_FAILURE,
                 "Cannot set negative cache for GID %"PRIu32"\n", cmdctx->id);
@@ -4333,7 +4326,7 @@ static int nss_cmd_initgroups_search(struct nss_dom_ctx *dctx)
 
         /* verify this user has not yet been negatively cached,
         * or has been permanently filtered */
-        ret = sss_ncache_check_user(nctx->ncache, dom, name);
+        ret = sss_ncache_check_user(nctx->rctx->ncache, dom, name);
 
         /* if neg cached, return we didn't find it */
         if (ret == EEXIST) {
@@ -4408,7 +4401,7 @@ static int nss_cmd_initgroups_search(struct nss_dom_ctx *dctx)
 
         if (dctx->res->count == 0 && !dctx->check_provider) {
             /* set negative cache only if not result of cache check */
-            ret = sss_ncache_set_user(nctx->ncache, false, dom, name);
+            ret = sss_ncache_set_user(nctx->rctx->ncache, false, dom, name);
             if (ret != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE, "Cannot set negcache for %s@%s\n",
                       name, dom->name);
@@ -4542,9 +4535,9 @@ static errno_t nss_cmd_getsidby_search(struct nss_dom_ctx *dctx)
             DEBUG(SSSDBG_TRACE_FUNC, "Requesting info for [%"PRIu32"@%s]\n",
                                       cmdctx->id, dom->name);
 
-            ret = sss_ncache_check_uid(nctx->ncache, dom, cmdctx->id);
+            ret = sss_ncache_check_uid(nctx->rctx->ncache, dom, cmdctx->id);
             if (ret == EEXIST) {
-                ret = sss_ncache_check_gid(nctx->ncache, dom, cmdctx->id);
+                ret = sss_ncache_check_gid(nctx->rctx->ncache, dom, cmdctx->id);
                 if (ret == EEXIST) {
                     DEBUG(SSSDBG_TRACE_FUNC,
                           "ID [%"PRIu32"] does not exist in [%s]! (negative cache)\n",
@@ -4595,10 +4588,10 @@ static errno_t nss_cmd_getsidby_search(struct nss_dom_ctx *dctx)
 
             /* verify this name has not yet been negatively cached, as user
              * and groupm, or has been permanently filtered */
-            ret = sss_ncache_check_user(nctx->ncache, dom, name);
+            ret = sss_ncache_check_user(nctx->rctx->ncache, dom, name);
 
             if (ret == EEXIST) {
-                ret = sss_ncache_check_group(nctx->ncache, dom, name);
+                ret = sss_ncache_check_group(nctx->rctx->ncache, dom, name);
                 if (ret == EEXIST) {
                     /* if neg cached, return we didn't find it */
                     DEBUG(SSSDBG_TRACE_FUNC,
@@ -4721,13 +4714,13 @@ static errno_t nss_cmd_getsidby_search(struct nss_dom_ctx *dctx)
         if (dctx->res->count == 0 && !dctx->check_provider) {
             if (cmdctx->cmd == SSS_NSS_GETSIDBYNAME
                     || cmdctx->cmd == SSS_NSS_GETORIGBYNAME) {
-                ret = sss_ncache_set_user(nctx->ncache, false, dom, name);
+                ret = sss_ncache_set_user(nctx->rctx->ncache, false, dom, name);
                 if (ret != EOK) {
                     DEBUG(SSSDBG_MINOR_FAILURE,
                           "Cannot set negcache for %s@%s\n", name, dom->name);
                 }
 
-                ret = sss_ncache_set_group(nctx->ncache, false, dom, name);
+                ret = sss_ncache_set_group(nctx->rctx->ncache, false, dom, name);
                 if (ret != EOK) {
                     DEBUG(SSSDBG_MINOR_FAILURE,
                           "Cannot set negcache for %s@%s\n", name, dom->name);
@@ -4796,13 +4789,13 @@ done:
         if (cmdctx->cmd == SSS_NSS_GETSIDBYID) {
             DEBUG(SSSDBG_MINOR_FAILURE,
                 "No matching domain found for [%"PRIu32"], fail!\n", cmdctx->id);
-            err = sss_ncache_set_uid(nctx->ncache, false, NULL, cmdctx->id);
+            err = sss_ncache_set_uid(nctx->rctx->ncache, false, NULL, cmdctx->id);
             if (err != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE,
                     "Cannot set negative cache for UID %"PRIu32"\n", cmdctx->id);
             }
 
-            err = sss_ncache_set_gid(nctx->ncache, false, NULL, cmdctx->id);
+            err = sss_ncache_set_gid(nctx->rctx->ncache, false, NULL, cmdctx->id);
             if (err != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE,
                     "Cannot set negative cache for GID %"PRIu32"\n", cmdctx->id);
@@ -4838,7 +4831,7 @@ static errno_t nss_cmd_getbysid_search(struct nss_dom_ctx *dctx)
 
     /* verify this user has not yet been negatively cached,
         * or has been permanently filtered */
-    ret = sss_ncache_check_sid(nctx->ncache, cmdctx->secid);
+    ret = sss_ncache_check_sid(nctx->rctx->ncache, cmdctx->secid);
     if (ret == EEXIST) {
         DEBUG(SSSDBG_TRACE_FUNC,
               "SID [%s] does not exist! (negative cache)\n", cmdctx->secid);
@@ -4852,7 +4845,7 @@ static errno_t nss_cmd_getbysid_search(struct nss_dom_ctx *dctx)
             DEBUG(SSSDBG_OP_FAILURE, "No results for getbysid call.\n");
 
             /* set negative cache only if not result of cache check */
-            ret = sss_ncache_set_sid(nctx->ncache, false, cmdctx->secid);
+            ret = sss_ncache_set_sid(nctx->rctx->ncache, false, cmdctx->secid);
             if (ret != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE,
                       "Cannot set negative cache for %s\n", cmdctx->secid);
diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c
index cde3a207430c6e42cc71036242e04fce48ac94f5..a3c74a3fd2050a63dff3d69224bcf0cc59b2a9bf 100644
--- a/src/responder/nss/nsssrv_netgroup.c
+++ b/src/responder/nss/nsssrv_netgroup.c
@@ -467,7 +467,7 @@ static errno_t create_negcache_netgr(struct setent_step_ctx *step_ctx)
     netgr->ready = true;
     netgr->found = false;
 
-    lifetime = sss_ncache_get_timeout(step_ctx->nctx->ncache);
+    lifetime = sss_ncache_get_timeout(step_ctx->nctx->rctx->ncache);
     set_netgr_lifetime(lifetime, step_ctx, netgr);
 
     ret = EOK;
@@ -587,7 +587,7 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
                   "Failed to convert results into entries\n");
             netgr->ready = true;
             netgr->found = false;
-            lifetime = sss_ncache_get_timeout(step_ctx->nctx->ncache);
+            lifetime = sss_ncache_get_timeout(step_ctx->nctx->rctx->ncache);
             set_netgr_lifetime(lifetime, step_ctx, netgr);
             ret = EIO;
             goto done;
diff --git a/src/responder/nss/nsssrv_services.c b/src/responder/nss/nsssrv_services.c
index 213d2926b3abb87d0b95ebcc6836e87b0df15754..05f9d52fad299bc4621d0890c95a10d9b8cd842d 100644
--- a/src/responder/nss/nsssrv_services.c
+++ b/src/responder/nss/nsssrv_services.c
@@ -174,7 +174,7 @@ getserv_send(TALLOC_CTX *mem_ctx,
          /* If we're looking up by name */
          if (service_name) {
              /* Check the negative cache */
-             ret = sss_ncache_check_service(nctx->ncache, dom,
+             ret = sss_ncache_check_service(nctx->rctx->ncache, dom,
                                             SVC_NAME_CASED, SVC_PROTO_CASED);
              /* If negatively cached, return we didn't find it */
              if (ret == EEXIST) {
@@ -213,7 +213,7 @@ getserv_send(TALLOC_CTX *mem_ctx,
                                        &state->res);
          } else { /* Looking up by port */
              /* Check the negative cache */
-             ret = sss_ncache_check_service_port(nctx->ncache, dom, port,
+             ret = sss_ncache_check_service_port(nctx->rctx->ncache, dom, port,
                                                  SVC_PROTO_CASED);
              /* If negatively cached, return we didn't find it */
              if (ret == EEXIST) {
@@ -262,7 +262,7 @@ getserv_send(TALLOC_CTX *mem_ctx,
              } else {
                  /* No provider to check. Set the negative cache here */
                  if (state->name) {
-                     ret = sss_ncache_set_service_name(nctx->ncache, false,
+                     ret = sss_ncache_set_service_name(nctx->rctx->ncache, false,
                                                        dom,
                                                        SVC_NAME_CASED,
                                                        SVC_PROTO_CASED);
@@ -275,7 +275,7 @@ getserv_send(TALLOC_CTX *mem_ctx,
                                 SVC_NAME_CASED, SVC_PROTO_CASED);
                      }
                  } else {
-                     ret = sss_ncache_set_service_port(nctx->ncache, false,
+                     ret = sss_ncache_set_service_port(nctx->rctx->ncache, false,
                                                        dom,
                                                        state->port,
                                                        SVC_PROTO_CASED);
@@ -510,7 +510,7 @@ static void lookup_service_done(struct tevent_req *subreq)
          * Set the negative cache
          */
         if (state->name) {
-            ret = sss_ncache_set_service_name(nctx->ncache, false,
+            ret = sss_ncache_set_service_name(nctx->rctx->ncache, false,
                                               dom,
                                               SVC_NAME_CASED,
                                               SVC_PROTO_CASED);
@@ -523,7 +523,7 @@ static void lookup_service_done(struct tevent_req *subreq)
                        SVC_NAME_CASED, SVC_PROTO_CASED);
             }
         } else {
-            ret = sss_ncache_set_service_port(nctx->ncache, false,
+            ret = sss_ncache_set_service_port(nctx->rctx->ncache, false,
                                               dom,
                                               state->port,
                                               SVC_PROTO_CASED);
diff --git a/src/tests/cmocka/test_negcache.c b/src/tests/cmocka/test_negcache.c
index 99d61fbc646e86de8fdb775dce3e062ce5b66b8a..e309ce6456ddaa425568d263964e7a01a653eaf5 100644
--- a/src/tests/cmocka/test_negcache.c
+++ b/src/tests/cmocka/test_negcache.c
@@ -71,7 +71,6 @@ static struct nss_ctx *
 mock_nctx(TALLOC_CTX *mem_ctx)
 {
     struct nss_ctx *nctx;
-    errno_t ret;
     enum idmap_error_code err;
 
     nctx = talloc_zero(mem_ctx, struct nss_ctx);
@@ -79,11 +78,6 @@ mock_nctx(TALLOC_CTX *mem_ctx)
         return NULL;
     }
 
-    ret = sss_ncache_init(nctx, SHORTSPAN, &nctx->ncache);
-    if (ret != EOK) {
-        talloc_free(nctx);
-        return NULL;
-    }
     nctx->pwfield = discard_const("*");
 
     err = sss_idmap_init(sss_idmap_talloc, nctx, sss_idmap_talloc_free,
diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c
index 9471e51bd8203a2112e300b3590e5b313df9494a..3064a96ea30633b5d65a874b16f7a17d9b87101e 100644
--- a/src/tests/cmocka/test_nss_srv.c
+++ b/src/tests/cmocka/test_nss_srv.c
@@ -62,7 +62,6 @@ struct nss_ctx *
 mock_nctx(TALLOC_CTX *mem_ctx)
 {
     struct nss_ctx *nctx;
-    errno_t ret;
     enum idmap_error_code err;
 
     nctx = talloc_zero(mem_ctx, struct nss_ctx);
@@ -70,11 +69,6 @@ mock_nctx(TALLOC_CTX *mem_ctx)
         return NULL;
     }
 
-    ret = sss_ncache_init(nctx, 10, &nctx->ncache);
-    if (ret != EOK) {
-        talloc_free(nctx);
-        return NULL;
-    }
     nctx->pwfield = discard_const("*");
 
     err = sss_idmap_init(sss_idmap_talloc, nctx, sss_idmap_talloc_free,
-- 
2.5.5

