From c4393245babd4177cc4dddc94367e5493449f4bf Mon Sep 17 00:00:00 2001
From: Petr Cech <pcech@redhat.com>
Date: Wed, 4 May 2016 13:36:53 -0400
Subject: [PATCH 3/6] RESPONDER: Removing ncache from ifp_ctx

This patch switches ncache from ifp_ctx to resp_ctx.
---
 src/responder/ifp/ifp_groups.c  |  9 +++++----
 src/responder/ifp/ifp_private.h |  1 -
 src/responder/ifp/ifp_users.c   |  9 +++++----
 src/responder/ifp/ifpsrv.c      | 11 -----------
 src/responder/ifp/ifpsrv_cmd.c  |  4 ++--
 5 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/src/responder/ifp/ifp_groups.c b/src/responder/ifp/ifp_groups.c
index 411cebc12079e01b05d341ca98f159f30d9395a1..1c1f1a7705ed6384c23ebe4a7aebf2b6e5ee1edb 100644
--- a/src/responder/ifp/ifp_groups.c
+++ b/src/responder/ifp/ifp_groups.c
@@ -118,7 +118,7 @@ int ifp_groups_find_by_name(struct sbus_request *sbus_req,
     }
 
     req = cache_req_group_by_name_send(sbus_req, ctx->rctx->ev, ctx->rctx,
-                                       ctx->ncache, 0, NULL, name);
+                                       ctx->rctx->ncache, 0, NULL, name);
     if (req == NULL) {
         return ENOMEM;
     }
@@ -188,7 +188,7 @@ int ifp_groups_find_by_id(struct sbus_request *sbus_req,
     }
 
     req = cache_req_group_by_id_send(sbus_req, ctx->rctx->ev, ctx->rctx,
-                                     ctx->ncache, 0, NULL, id);
+                                     ctx->rctx->ncache, 0, NULL, id);
     if (req == NULL) {
         return ENOMEM;
     }
@@ -526,7 +526,7 @@ static struct tevent_req *resolv_ghosts_send(TALLOC_CTX *mem_ctx,
     }
 
     subreq = cache_req_group_by_name_send(state, ev, ctx->rctx,
-                                          ctx->ncache, 0, domain->name, name);
+                                          ctx->rctx->ncache, 0, domain->name, name);
     if (subreq == NULL) {
         ret = ENOMEM;
         goto immediately;
@@ -604,7 +604,8 @@ errno_t resolv_ghosts_step(struct tevent_req *req)
     }
 
     subreq = cache_req_user_by_name_send(state, state->ev, state->ctx->rctx,
-                                   state->ctx->ncache, 0, state->domain->name,
+                                   state->ctx->rctx->ncache, 0,
+                                   state->domain->name,
                                    state->ghosts[state->index]);
     if (subreq == NULL) {
         return ENOMEM;
diff --git a/src/responder/ifp/ifp_private.h b/src/responder/ifp/ifp_private.h
index 9eacdbb9e43a17db4800eb0eb12cdc3e4f130741..24e60df48f6525348cecee7f31bc69751b287108 100644
--- a/src/responder/ifp/ifp_private.h
+++ b/src/responder/ifp/ifp_private.h
@@ -39,7 +39,6 @@ struct sysbus_ctx {
 struct ifp_ctx {
     struct resp_ctx *rctx;
     struct sss_names_ctx *snctx;
-    struct sss_nc_ctx *ncache;
 
     struct sysbus_ctx *sysbus;
     const char **user_whitelist;
diff --git a/src/responder/ifp/ifp_users.c b/src/responder/ifp/ifp_users.c
index f362ea289be2a2188b588ebaf69c1d98d432c29f..e16ee65009666e8866027bb8e42cdc777ebeed31 100644
--- a/src/responder/ifp/ifp_users.c
+++ b/src/responder/ifp/ifp_users.c
@@ -99,7 +99,7 @@ int ifp_users_find_by_name(struct sbus_request *sbus_req,
     }
 
     req = cache_req_user_by_name_send(sbus_req, ctx->rctx->ev, ctx->rctx,
-                                      ctx->ncache, 0, NULL, name);
+                                      ctx->rctx->ncache, 0, NULL, name);
     if (req == NULL) {
         return ENOMEM;
     }
@@ -169,7 +169,7 @@ int ifp_users_find_by_id(struct sbus_request *sbus_req,
     }
 
     req = cache_req_user_by_id_send(sbus_req, ctx->rctx->ev, ctx->rctx,
-                                    ctx->ncache, 0, NULL, id);
+                                    ctx->rctx->ncache, 0, NULL, id);
     if (req == NULL) {
         return ENOMEM;
     }
@@ -255,7 +255,7 @@ int ifp_users_find_by_cert(struct sbus_request *sbus_req, void *data,
     }
 
     req = cache_req_user_by_cert_send(sbus_req, ctx->rctx->ev, ctx->rctx,
-                                      ctx->ncache, 0, NULL, derb64);
+                                      ctx->rctx->ncache, 0, NULL, derb64);
     if (req == NULL) {
         return ENOMEM;
     }
@@ -651,7 +651,8 @@ int ifp_users_user_update_groups_list(struct sbus_request *sbus_req,
     }
 
     req = cache_req_initgr_by_name_send(sbus_req, ctx->rctx->ev, ctx->rctx,
-                                        ctx->ncache, 0, domain->name, username);
+                                        ctx->rctx->ncache, 0, domain->name,
+                                        username);
     if (req == NULL) {
         return ENOMEM;
     }
diff --git a/src/responder/ifp/ifpsrv.c b/src/responder/ifp/ifpsrv.c
index 55a182143b82c7eedfa4f4619adc6ab1de73bf4d..879e00c8ed78751bb37d5d5a019ff1c7bc03966d 100644
--- a/src/responder/ifp/ifpsrv.c
+++ b/src/responder/ifp/ifpsrv.c
@@ -227,7 +227,6 @@ int ifp_process_init(TALLOC_CTX *mem_ctx,
     struct be_conn *iter;
     int ret;
     int max_retries;
-    uint32_t neg_timeout;
     char *uid_str;
     char *attr_list_str;
     char *wildcard_limit_str;
@@ -283,16 +282,6 @@ int ifp_process_init(TALLOC_CTX *mem_ctx,
         goto fail;
     }
 
-    /* Set up the negative cache */
-    ret = responder_get_neg_timeout_from_confdb(cdb, &neg_timeout);
-    if (ret != EOK) goto fail;
-
-    ret = sss_ncache_init(rctx, neg_timeout, &ifp_ctx->ncache);
-    if (ret != EOK) {
-        DEBUG(SSSDBG_CRIT_FAILURE, "fatal error initializing negcache\n");
-        goto fail;
-    }
-
     ret = confdb_get_string(ifp_ctx->rctx->cdb, ifp_ctx->rctx,
                             CONFDB_IFP_CONF_ENTRY, CONFDB_IFP_USER_ATTR_LIST,
                             NULL, &attr_list_str);
diff --git a/src/responder/ifp/ifpsrv_cmd.c b/src/responder/ifp/ifpsrv_cmd.c
index c50f51763fdf5cfcf941c8be76333ddafe9023b5..27a9d6a1ef0bc9622e8df6a5888e861f5ed4dbe4 100644
--- a/src/responder/ifp/ifpsrv_cmd.c
+++ b/src/responder/ifp/ifpsrv_cmd.c
@@ -91,7 +91,7 @@ int ifp_user_get_attr(struct sbus_request *dbus_req, void *data)
           attr_req->name, ireq->dbus_req->client);
 
     req = ifp_user_get_attr_send(ireq, ifp_ctx->rctx,
-                                 ifp_ctx->ncache, SSS_DP_USER,
+                                 ifp_ctx->rctx->ncache, SSS_DP_USER,
                                  attr_req->name, attr_req->attrs);
     if (req == NULL) {
         return sbus_request_finish(dbus_req, NULL);
@@ -320,7 +320,7 @@ int ifp_user_get_groups(struct sbus_request *dbus_req,
           group_req->name, group_req->ireq->dbus_req->client);
 
     req = ifp_user_get_attr_send(ireq, ifp_ctx->rctx,
-                                 ifp_ctx->ncache, SSS_DP_INITGROUPS,
+                                 ifp_ctx->rctx->ncache, SSS_DP_INITGROUPS,
                                  group_req->name, group_req->attrs);
     if (req == NULL) {
         return sbus_request_finish(dbus_req, NULL);
-- 
2.5.5

