From 51ace9549829daa87a47218ed174de59752de177 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Tue, 19 Jul 2016 14:42:26 +0200
Subject: [PATCH 4/4] NSS: Remove unused functions

When removing the old data provider I noticed that those functions
are not used at all.
---
 src/responder/nss/nsssrv.c         |  11 ----
 src/responder/nss/nsssrv_cmd.c     | 112 -------------------------------------
 src/responder/nss/nsssrv_private.h |   2 -
 3 files changed, 125 deletions(-)

diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index 05b51ecdf2e17e20af2ee3ee48377cbe1bf19a24..06d58f21b00b73c6c7a4b7583e10b4b61a627d75 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -328,17 +328,6 @@ done:
     return ret;
 }
 
-int nss_update_memcache(struct sbus_request *dbus_req, void *data)
-{
-    struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
-    struct nss_ctx *nctx = talloc_get_type(rctx->pvt_ctx, struct nss_ctx);
-
-    nss_update_pw_memcache(nctx);
-    nss_update_gr_memcache(nctx);
-
-    return EOK;
-}
-
 int nss_memorycache_update_initgroups(struct sbus_request *sbus_req,
                                       void *data,
                                       const char *user,
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 1ae17969688fa29734ca14fd2b152decef1fdbca..196bdb7a30936e2f1c7b60ed27687c3453bba592 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -118,66 +118,6 @@ static int nss_reset_negcache(struct resp_ctx *rctx)
  * PASSWD db related functions
  ***************************************************************************/
 
-void nss_update_pw_memcache(struct nss_ctx *nctx)
-{
-    struct sss_domain_info *dom;
-    struct ldb_result *res;
-    uint64_t exp;
-    struct sized_string key;
-    const char *id;
-    time_t now;
-    int ret;
-    int i;
-
-    now = time(NULL);
-
-    for (dom = nctx->rctx->domains; dom; dom = get_next_domain(dom, 0)) {
-        ret = sysdb_enumpwent_with_views(nctx, dom, &res);
-        if (ret != EOK) {
-            DEBUG(SSSDBG_CRIT_FAILURE,
-                  "Failed to enumerate users for domain [%s]\n", dom->name);
-            continue;
-        }
-
-        for (i = 0; i < res->count; i++) {
-            exp = ldb_msg_find_attr_as_uint64(res->msgs[i],
-                                              SYSDB_CACHE_EXPIRE, 0);
-            if (exp >= now) {
-                continue;
-            }
-
-            /* names require more manipulation (build up fqname conditionally),
-             * but uidNumber is unique and always resolvable too, so we use
-             * that to update the cache, as it points to the same entry */
-            id = sss_view_ldb_msg_find_attr_as_string(dom, res->msgs[i],
-                                                      SYSDB_UIDNUM, NULL);
-            if (!id) {
-                DEBUG(SSSDBG_CRIT_FAILURE,
-                      "Failed to find uidNumber in %s.\n",
-                       ldb_dn_get_linearized(res->msgs[i]->dn));
-                continue;
-            }
-            to_sized_string(&key, id);
-
-            ret = sss_mmap_cache_pw_invalidate(nctx->pwd_mc_ctx, &key);
-            if (ret != EOK && ret != ENOENT) {
-                DEBUG(SSSDBG_CRIT_FAILURE,
-                      "Internal failure in memory cache code: %d [%s]\n",
-                       ret, strerror(ret));
-            }
-
-            ret = sss_mmap_cache_pw_invalidate(nctx->initgr_mc_ctx, &key);
-            if (ret != EOK && ret != ENOENT) {
-                DEBUG(SSSDBG_CRIT_FAILURE,
-                      "Internal failure in memory cache code: %d [%s]\n",
-                      ret, strerror(ret));
-            }
-        }
-
-        talloc_zfree(res);
-    }
-}
-
 static gid_t get_gid_override(struct ldb_message *msg,
                               struct sss_domain_info *dom)
 {
@@ -2735,58 +2675,6 @@ done:
  * GROUP db related functions
  ***************************************************************************/
 
-void nss_update_gr_memcache(struct nss_ctx *nctx)
-{
-    struct sss_domain_info *dom;
-    struct ldb_result *res;
-    uint64_t exp;
-    struct sized_string key;
-    const char *id;
-    time_t now;
-    int ret;
-    int i;
-
-    now = time(NULL);
-
-    for (dom = nctx->rctx->domains; dom; dom = get_next_domain(dom, 0)) {
-        ret = sysdb_enumgrent_with_views(nctx, dom, &res);
-        if (ret != EOK) {
-            DEBUG(SSSDBG_CRIT_FAILURE,
-                  "Failed to enumerate users for domain [%s]\n", dom->name);
-            continue;
-        }
-
-        for (i = 0; i < res->count; i++) {
-            exp = ldb_msg_find_attr_as_uint64(res->msgs[i],
-                                              SYSDB_CACHE_EXPIRE, 0);
-            if (exp >= now) {
-                continue;
-            }
-
-            /* names require more manipulation (build up fqname conditionally),
-             * but uidNumber is unique and always resolvable too, so we use
-             * that to update the cache, as it points to the same entry */
-            id = sss_view_ldb_msg_find_attr_as_string(dom, res->msgs[i],
-                                                      SYSDB_GIDNUM, NULL);
-            if (!id) {
-                DEBUG(SSSDBG_CRIT_FAILURE,
-                      "Failed to find gidNumber in %s.\n",
-                       ldb_dn_get_linearized(res->msgs[i]->dn));
-                continue;
-            }
-            to_sized_string(&key, id);
-
-            ret = sss_mmap_cache_gr_invalidate(nctx->grp_mc_ctx, &key);
-            if (ret != EOK && ret != ENOENT) {
-                DEBUG(SSSDBG_CRIT_FAILURE,
-                      "Internal failure in memory cache code: %d [%s]\n",
-                       ret, strerror(ret));
-            }
-        }
-        talloc_zfree(res);
-    }
-}
-
 #define GID_ROFFSET 0
 #define MNUM_ROFFSET sizeof(uint32_t)
 #define STRS_ROFFSET 2*sizeof(uint32_t)
diff --git a/src/responder/nss/nsssrv_private.h b/src/responder/nss/nsssrv_private.h
index 79c7b7265f66f57e0ea89fe192a1da4f8992f1a3..c6f57235ca9f14fb80ead7c88bf830906c8b94ef 100644
--- a/src/responder/nss/nsssrv_private.h
+++ b/src/responder/nss/nsssrv_private.h
@@ -143,8 +143,6 @@ errno_t check_cache(struct nss_dom_ctx *dctx,
                     sss_dp_callback_t callback,
                     void *pvt);
 
-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,
                                 int gnum, uint32_t *groups);
-- 
2.1.0

