>From 36e31732dd759c8c6b302c75d050a11fe1ea594a Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Mon, 21 Sep 2015 10:26:20 -0400
Subject: [PATCH] confdb: warn if memcache_timeout > than entry_cache

Only group and user records are cached in memory cache so only timeouts
for those are checked.

Resolves:
https://fedorahosted.org/sssd/ticket/2176
---
 src/confdb/confdb.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/confdb/confdb.c b/src/confdb/confdb.c
index 3a8a1c01b92e62302ac4f787ccd085be9d8f05c3..e93632d34a8aa6de14224c6b296a84ee6007c38e 100644
--- a/src/confdb/confdb.c
+++ b/src/confdb/confdb.c
@@ -827,6 +827,7 @@ static int confdb_get_domain_internal(struct confdb_ctx *cdb,
     uint32_t entry_cache_timeout;
     char *default_domain;
     bool fqnames_default = false;
+    int memcache_timeout;
 
     tmp_ctx = talloc_new(mem_ctx);
     if (!tmp_ctx) return ENOMEM;
@@ -851,6 +852,16 @@ static int confdb_get_domain_internal(struct confdb_ctx *cdb,
         goto done;
     }
 
+    ret = confdb_get_int(cdb,
+                         CONFDB_NSS_CONF_ENTRY,
+                         CONFDB_MEMCACHE_TIMEOUT,
+                         300, &memcache_timeout);
+    if (ret != EOK) {
+        DEBUG(SSSDBG_FATAL_FAILURE,
+              "Unable to get memory cache entry timeout.\n");
+        goto done;
+    }
+
     domain = talloc_zero(mem_ctx, struct sss_domain_info);
     if (!domain) {
         ret = ENOMEM;
@@ -1078,6 +1089,12 @@ static int confdb_get_domain_internal(struct confdb_ctx *cdb,
         goto done;
     }
 
+    if (domain->user_timeout < memcache_timeout) {
+        DEBUG(SSSDBG_CONF_SETTINGS,
+              "%s is lesser then %s, sysdb will not be updated for users.\n",
+              CONFDB_DOMAIN_USER_CACHE_TIMEOUT, CONFDB_MEMCACHE_TIMEOUT);
+    }
+
     /* Override the group cache timeout, if specified */
     ret = get_entry_as_uint32(res->msgs[0], &domain->group_timeout,
                               CONFDB_DOMAIN_GROUP_CACHE_TIMEOUT,
@@ -1089,6 +1106,12 @@ static int confdb_get_domain_internal(struct confdb_ctx *cdb,
         goto done;
     }
 
+    if (domain->group_timeout < memcache_timeout) {
+        DEBUG(SSSDBG_CONF_SETTINGS,
+              "%s is lesser then %s, sysdb will not be updated for groups.\n",
+              CONFDB_DOMAIN_GROUP_CACHE_TIMEOUT, CONFDB_MEMCACHE_TIMEOUT);
+    }
+
     /* Override the netgroup cache timeout, if specified */
     ret = get_entry_as_uint32(res->msgs[0], &domain->netgroup_timeout,
                               CONFDB_DOMAIN_NETGROUP_CACHE_TIMEOUT,
-- 
2.4.3

