summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2007-12-20 16:05:57 +0100
committerVolker Lendecke <vl@samba.org>2007-12-21 09:58:20 +0100
commitc19363eb77fcc3e1bf3341e6373d38f1e91fc08f (patch)
treec8280daa73b9391d6df188abf56fbf7e3a0809f5
parent4b06c68482247d859ec30b8b1920706e43358989 (diff)
downloadsamba-c19363eb77fcc3e1bf3341e6373d38f1e91fc08f.tar.gz
samba-c19363eb77fcc3e1bf3341e6373d38f1e91fc08f.tar.xz
samba-c19363eb77fcc3e1bf3341e6373d38f1e91fc08f.zip
Add a singleton cache
First user is yp_default_domain
-rw-r--r--source/include/memcache.h3
-rw-r--r--source/lib/access.c20
2 files changed, 20 insertions, 3 deletions
diff --git a/source/include/memcache.h b/source/include/memcache.h
index 36cde98bd33..c4a2974b629 100644
--- a/source/include/memcache.h
+++ b/source/include/memcache.h
@@ -32,7 +32,8 @@ enum memcache_number {
SID_GID_CACHE,
GETWD_CACHE,
GETPWNAM_CACHE, /* talloc */
- MANGLE_HASH2_CACHE
+ MANGLE_HASH2_CACHE,
+ SINGLETON_CACHE
};
struct memcache *memcache_init(TALLOC_CTX *mem_ctx, size_t max_size);
diff --git a/source/lib/access.c b/source/lib/access.c
index 1e4df836079..6a463446d1a 100644
--- a/source/lib/access.c
+++ b/source/lib/access.c
@@ -97,13 +97,29 @@ static bool string_match(const char *tok,const char *s)
}
} else if (tok[0] == '@') { /* netgroup: look it up */
#ifdef HAVE_NETGROUP
- static char *mydomain = NULL;
+ DATA_BLOB tmp;
+ char *mydomain = NULL;
char *hostname = NULL;
bool netgroup_ok = false;
- if (!mydomain)
+ if (memcache_lookup(
+ NULL, SINGLETON_CACHE,
+ data_blob_string_const("yp_default_domain"),
+ &tmp)) {
+
+ SMB_ASSERT(tmp.length > 0);
+ mydomain = (tmp.data[0] == '\0')
+ ? NULL : (char *)tmp.data;
+ }
+ else {
yp_get_default_domain(&mydomain);
+ memcache_add(
+ NULL, SINGLETON_CACHE,
+ data_blob_string_const("yp_default_domain"),
+ data_blob_string_const(mydomain?mydomain:""));
+ }
+
if (!mydomain) {
DEBUG(0,("Unable to get default yp domain. "
"Try without it.\n"));