summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-11-14 13:42:54 +0100
committerKarolin Seeger <kseeger@samba.org>2008-11-18 10:06:56 +0100
commit6cd23d54796ca4922df188b6abb8c74d80316510 (patch)
tree990756d5103db7166e0cb7d8cc6453e4c170a5d9
parent4de462293a61800ef5091ab7b9f3bb8acd6a78bb (diff)
downloadsamba-6cd23d54796ca4922df188b6abb8c74d80316510.tar.gz
Make memcache_add_talloc NULL out the source pointer
This is an orthogonality measure to make clear this pointer now belongs to the cache. (cherry picked from commit e6080c6e87d6fe3995b121a772bf3f6343fa666f) (cherry picked from commit 076bc9a21e540b25180a8d63e1e0c3eb071c16f7)
-rw-r--r--source/auth/token_util.c6
-rw-r--r--source/lib/memcache.c14
-rw-r--r--source/lib/util_pw.c2
-rw-r--r--source/passdb/pdb_interface.c14
-rw-r--r--source/torture/torture.c4
5 files changed, 26 insertions, 14 deletions
diff --git a/source/auth/token_util.c b/source/auth/token_util.c
index bb8f222abf6..7aa53910153 100644
--- a/source/auth/token_util.c
+++ b/source/auth/token_util.c
@@ -77,7 +77,7 @@ bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid )
NT_USER_TOKEN *get_root_nt_token( void )
{
- struct nt_user_token *token = NULL;
+ struct nt_user_token *token, *for_cache;
DOM_SID u_sid, g_sid;
struct passwd *pw;
void *cache_data;
@@ -107,9 +107,11 @@ NT_USER_TOKEN *get_root_nt_token( void )
token->privileges = se_disk_operators;
+ for_cache = token;
+
memcache_add_talloc(
NULL, SINGLETON_CACHE_TALLOC,
- data_blob_string_const("root_nt_token"), token);
+ data_blob_string_const("root_nt_token"), &for_cache);
return token;
}
diff --git a/source/lib/memcache.c b/source/lib/memcache.c
index fec0134b840..4cd9a94244c 100644
--- a/source/lib/memcache.c
+++ b/source/lib/memcache.c
@@ -340,9 +340,19 @@ void memcache_add(struct memcache *cache, enum memcache_number n,
}
void memcache_add_talloc(struct memcache *cache, enum memcache_number n,
- DATA_BLOB key, void *ptr)
+ DATA_BLOB key, void *pptr)
{
- void *p = talloc_move(cache, &ptr);
+ void **ptr = (void **)pptr;
+ void *p;
+
+ if (cache == NULL) {
+ cache = global_cache;
+ }
+ if (cache == NULL) {
+ return;
+ }
+
+ p = talloc_move(cache, ptr);
memcache_add(cache, n, key, data_blob_const(&p, sizeof(p)));
}
diff --git a/source/lib/util_pw.c b/source/lib/util_pw.c
index f0f3f008955..bf09c428abb 100644
--- a/source/lib/util_pw.c
+++ b/source/lib/util_pw.c
@@ -63,7 +63,7 @@ struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
}
memcache_add_talloc(NULL, GETPWNAM_CACHE, data_blob_string_const(name),
- for_cache);
+ &for_cache);
return tcopy_passwd(mem_ctx, pw);
}
diff --git a/source/passdb/pdb_interface.c b/source/passdb/pdb_interface.c
index 6fe105854f1..5a79f09db06 100644
--- a/source/passdb/pdb_interface.c
+++ b/source/passdb/pdb_interface.c
@@ -207,28 +207,28 @@ static struct pdb_methods *pdb_get_methods(void)
bool pdb_getsampwnam(struct samu *sam_acct, const char *username)
{
struct pdb_methods *pdb = pdb_get_methods();
- struct samu *cache_copy;
+ struct samu *for_cache;
const struct dom_sid *user_sid;
if (!NT_STATUS_IS_OK(pdb->getsampwnam(pdb, sam_acct, username))) {
return False;
}
- cache_copy = samu_new(NULL);
- if (cache_copy == NULL) {
+ for_cache = samu_new(NULL);
+ if (for_cache == NULL) {
return False;
}
- if (!pdb_copy_sam_account(cache_copy, sam_acct)) {
- TALLOC_FREE(cache_copy);
+ if (!pdb_copy_sam_account(for_cache, sam_acct)) {
+ TALLOC_FREE(for_cache);
return False;
}
- user_sid = pdb_get_user_sid(cache_copy);
+ user_sid = pdb_get_user_sid(for_cache);
memcache_add_talloc(NULL, PDB_GETPWSID_CACHE,
data_blob_const(user_sid, sizeof(*user_sid)),
- cache_copy);
+ &for_cache);
return True;
}
diff --git a/source/torture/torture.c b/source/torture/torture.c
index 6beb57c98cf..a4b46790118 100644
--- a/source/torture/torture.c
+++ b/source/torture/torture.c
@@ -5254,11 +5254,11 @@ static bool run_local_memcache(int dummy)
str2 = talloc_strdup(mem_ctx, "string2");
memcache_add_talloc(cache, SINGLETON_CACHE_TALLOC,
- data_blob_string_const("torture"), str1);
+ data_blob_string_const("torture"), &str1);
size1 = talloc_total_size(cache);
memcache_add_talloc(cache, SINGLETON_CACHE_TALLOC,
- data_blob_string_const("torture"), str2);
+ data_blob_string_const("torture"), &str2);
size2 = talloc_total_size(cache);
printf("size1=%d, size2=%d\n", (int)size1, (int)size2);