summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-04-02 03:46:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:19:03 -0500
commitfb3835846ef89a632230ff808259dad1cddc05c0 (patch)
tree4e06c7b8a1b1d106a7c4e6e40a5d16b817c148cb /source3/lib
parent074c1eb0ea84ec5d9ebb95f5604d8b0acee7d4ec (diff)
downloadsamba-fb3835846ef89a632230ff808259dad1cddc05c0.tar.gz
samba-fb3835846ef89a632230ff808259dad1cddc05c0.tar.bz2
samba-fb3835846ef89a632230ff808259dad1cddc05c0.zip
r22020: Make it more clear that both the vuser struct and it's contents are
talloc_free()'ed at the end of a session. Rework the passwd cache code to use talloc_unlink and talloc_reference, to more carefully manage the cache. Andrew Bartlett (This used to be commit e3e0ec25e67308de314aa61852905ee42aa2c8fe)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_pw.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/source3/lib/util_pw.c b/source3/lib/util_pw.c
index dc184233a6..8b3c78a3f9 100644
--- a/source3/lib/util_pw.c
+++ b/source3/lib/util_pw.c
@@ -98,15 +98,15 @@ struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
i = rand() % PWNAMCACHE_SIZE;
if (pwnam_cache[i] != NULL) {
- TALLOC_FREE(pwnam_cache[i]);
+ /* Remove this old cache entry, from the cache. We
+ * use talloc_unlink here because we want to be very
+ * clear which referece we are removing */
+ talloc_unlink(pwnam_cache, pwnam_cache[i]);
}
pwnam_cache[i] = tcopy_passwd(pwnam_cache, temp);
- if (pwnam_cache[i]!= NULL && mem_ctx != NULL) {
- return (struct passwd *)talloc_reference(mem_ctx, pwnam_cache[i]);
- }
-
- return tcopy_passwd(NULL, pwnam_cache[i]);
+ /* while keeping this in the cache, reference a copy for the caller */
+ return (struct passwd *)talloc_reference(mem_ctx, pwnam_cache[i]);
}
struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)