1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

Convert get_root_nt_token to memcache

(This used to be commit fada689893)
This commit is contained in:
Volker Lendecke 2007-12-28 17:24:39 +01:00
parent d826fcf6df
commit 245537f9bd
3 changed files with 17 additions and 3 deletions

View File

@ -77,12 +77,19 @@ bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid )
NT_USER_TOKEN *get_root_nt_token( void ) 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; DOM_SID u_sid, g_sid;
struct passwd *pw; struct passwd *pw;
void *cache_data;
if ( token ) cache_data = memcache_lookup_talloc(
return token; 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" )) ) { if ( !(pw = sys_getpwnam( "root" )) ) {
DEBUG(0,("get_root_nt_token: getpwnam(\"root\") failed!\n")); 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, token = create_local_nt_token(NULL, &u_sid, False,
1, &global_sid_Builtin_Administrators); 1, &global_sid_Builtin_Administrators);
memcache_add_talloc(
NULL, SINGLETON_CACHE_TALLOC,
data_blob_string_const("root_nt_token"), token);
return token; return token;
} }

View File

@ -34,6 +34,7 @@ enum memcache_number {
GETPWNAM_CACHE, /* talloc */ GETPWNAM_CACHE, /* talloc */
MANGLE_HASH2_CACHE, MANGLE_HASH2_CACHE,
PDB_GETPWSID_CACHE, /* talloc */ PDB_GETPWSID_CACHE, /* talloc */
SINGLETON_CACHE_TALLOC, /* talloc */
SINGLETON_CACHE SINGLETON_CACHE
}; };

View File

@ -47,6 +47,7 @@ static bool memcache_is_talloc(enum memcache_number n)
switch (n) { switch (n) {
case GETPWNAM_CACHE: case GETPWNAM_CACHE:
case PDB_GETPWSID_CACHE: case PDB_GETPWSID_CACHE:
case SINGLETON_CACHE_TALLOC:
result = true; result = true;
break; break;
default: default: