summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2007-12-28 17:24:39 +0100
committerVolker Lendecke <vl@samba.org>2007-12-28 17:24:39 +0100
commit245537f9bd1bddc496da0155012c34a2c7a18668 (patch)
treeb9ab1f4b1acde03e57b8f4b1da00a0f614e755fb /source3
parentd826fcf6dfb0e2203a114cbd427badc0abeea559 (diff)
downloadsamba-245537f9bd1bddc496da0155012c34a2c7a18668.tar.gz
samba-245537f9bd1bddc496da0155012c34a2c7a18668.tar.bz2
samba-245537f9bd1bddc496da0155012c34a2c7a18668.zip
Convert get_root_nt_token to memcache
(This used to be commit fada689893314bed2fc78588b3fd9b144f4c808a)
Diffstat (limited to 'source3')
-rw-r--r--source3/auth/token_util.c18
-rw-r--r--source3/include/memcache.h1
-rw-r--r--source3/lib/memcache.c1
3 files changed, 17 insertions, 3 deletions
diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c
index 27c98c9581..a1b4edfb7a 100644
--- a/source3/auth/token_util.c
+++ b/source3/auth/token_util.c
@@ -77,12 +77,19 @@ bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid )
NT_USER_TOKEN *get_root_nt_token( void )
{
- static NT_USER_TOKEN *token = NULL;
+ struct nt_user_token *token = NULL;
DOM_SID u_sid, g_sid;
struct passwd *pw;
+ void *cache_data;
- if ( token )
- return token;
+ cache_data = memcache_lookup_talloc(
+ NULL, SINGLETON_CACHE_TALLOC,
+ data_blob_string_const("root_nt_token"));
+
+ if (cache_data != NULL) {
+ return talloc_get_type_abort(
+ cache_data, struct nt_user_token);
+ }
if ( !(pw = sys_getpwnam( "root" )) ) {
DEBUG(0,("get_root_nt_token: getpwnam(\"root\") failed!\n"));
@@ -97,6 +104,11 @@ NT_USER_TOKEN *get_root_nt_token( void )
token = create_local_nt_token(NULL, &u_sid, False,
1, &global_sid_Builtin_Administrators);
+
+ memcache_add_talloc(
+ NULL, SINGLETON_CACHE_TALLOC,
+ data_blob_string_const("root_nt_token"), token);
+
return token;
}
diff --git a/source3/include/memcache.h b/source3/include/memcache.h
index c615efa695..5a0ce63cb7 100644
--- a/source3/include/memcache.h
+++ b/source3/include/memcache.h
@@ -34,6 +34,7 @@ enum memcache_number {
GETPWNAM_CACHE, /* talloc */
MANGLE_HASH2_CACHE,
PDB_GETPWSID_CACHE, /* talloc */
+ SINGLETON_CACHE_TALLOC, /* talloc */
SINGLETON_CACHE
};
diff --git a/source3/lib/memcache.c b/source3/lib/memcache.c
index c06e7ceacc..6dee61af50 100644
--- a/source3/lib/memcache.c
+++ b/source3/lib/memcache.c
@@ -47,6 +47,7 @@ static bool memcache_is_talloc(enum memcache_number n)
switch (n) {
case GETPWNAM_CACHE:
case PDB_GETPWSID_CACHE:
+ case SINGLETON_CACHE_TALLOC:
result = true;
break;
default: