Hello,
I would like to have this option in SSSD for debugging purposes. It is
not documented, so it should be invisible for users (but I can add it to
man pages as well, if someone thinks it is useful to have it there).
Thanks
Michal
>From 7735db30b161fac4baf01e257db9dca64229b094 Mon Sep 17 00:00:00 2001
From: Michal Zidek <[email protected]>
Date: Wed, 11 Sep 2013 19:58:53 +0200
Subject: [PATCH] nss: Add option to disable memcache
Sometimes it is useful to disable the memory cache (when
developing or debugging code). This patch adds nss option to
enable/disable memcache (default is enabled).
---
src/confdb/confdb.h | 1 +
src/responder/nss/nsssrv.c | 52 +++++++++++++++++++++++++++++++---------------
2 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h
index cb2a624..728ed10 100644
--- a/src/confdb/confdb.h
+++ b/src/confdb/confdb.h
@@ -96,6 +96,7 @@
#define CONFDB_NSS_SHELL_FALLBACK "shell_fallback"
#define CONFDB_NSS_DEFAULT_SHELL "default_shell"
#define CONFDB_MEMCACHE_TIMEOUT "memcache_timeout"
+#define CONFDB_NSS_USE_MEMCACHE "use_memcache"
/* PAM */
#define CONFDB_PAM_CONF_ENTRY "config/pam"
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index 253756d..4a7a613 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -432,6 +432,7 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
struct be_conn *iter;
struct nss_ctx *nctx;
int memcache_timeout;
+ bool use_memcache;
int ret, max_retries;
enum idmap_error_code err;
int hret;
@@ -518,28 +519,45 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
SSS_NSS_MCACHE_DIR"/"CLEAR_MC_FLAG, ret, strerror(ret)));
}
- ret = confdb_get_int(nctx->rctx->cdb,
- CONFDB_NSS_CONF_ENTRY,
- CONFDB_MEMCACHE_TIMEOUT,
- 300, &memcache_timeout);
+ ret = confdb_get_bool(nctx->rctx->cdb,
+ CONFDB_NSS_CONF_ENTRY,
+ CONFDB_NSS_USE_MEMCACHE,
+ true, &use_memcache);
if (ret != EOK) {
- DEBUG(0, ("Failed to set up automatic reconnection\n"));
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ ("Failed to get option use_memcache.\n"));
goto fail;
}
- /* TODO: read cache sizes from configuration */
- ret = sss_mmap_cache_init(nctx, "passwd", SSS_MC_PASSWD,
- SSS_MC_CACHE_ELEMENTS, (time_t)memcache_timeout,
- &nctx->pwd_mc_ctx);
- if (ret) {
- DEBUG(SSSDBG_CRIT_FAILURE, ("passwd mmap cache is DISABLED\n"));
- }
+ if (use_memcache) {
+ ret = confdb_get_int(nctx->rctx->cdb,
+ CONFDB_NSS_CONF_ENTRY,
+ CONFDB_MEMCACHE_TIMEOUT,
+ 300, &memcache_timeout);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ ("Failed to get memcache_timeout.\n"));
+ goto fail;
+ }
- ret = sss_mmap_cache_init(nctx, "group", SSS_MC_GROUP,
- SSS_MC_CACHE_ELEMENTS, (time_t)memcache_timeout,
- &nctx->grp_mc_ctx);
- if (ret) {
- DEBUG(SSSDBG_CRIT_FAILURE, ("group mmap cache is DISABLED\n"));
+ /* TODO: read cache sizes from configuration */
+ ret = sss_mmap_cache_init(nctx, "passwd", SSS_MC_PASSWD,
+ SSS_MC_CACHE_ELEMENTS,
+ (time_t)memcache_timeout,
+ &nctx->pwd_mc_ctx);
+ if (ret) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("passwd mmap cache is DISABLED\n"));
+ }
+
+ ret = sss_mmap_cache_init(nctx, "group", SSS_MC_GROUP,
+ SSS_MC_CACHE_ELEMENTS,
+ (time_t)memcache_timeout,
+ &nctx->grp_mc_ctx);
+ if (ret) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("group mmap cache is DISABLED\n"));
+ }
+ } else {
+ DEBUG(SSSDBG_TRACE_FUNC, ("Memcache will not be used.\n"));
}
/* Set up file descriptor limits */
--
1.7.11.2
_______________________________________________
sssd-devel mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel