summaryrefslogtreecommitdiff
path: root/source3/auth/auth_util.c
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/auth/auth_util.c
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/auth/auth_util.c')
-rw-r--r--source3/auth/auth_util.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 82567473b5..5c3bf7acce 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -561,19 +561,23 @@ NTSTATUS make_server_info_sam(auth_serversupplied_info **server_info,
DOM_SID unix_group_sid;
- if ( !(pwd = getpwnam_alloc(NULL, pdb_get_username(sampass))) ) {
- DEBUG(1, ("User %s in passdb, but getpwnam() fails!\n",
- pdb_get_username(sampass)));
- return NT_STATUS_NO_SUCH_USER;
- }
-
if ( !(result = make_server_info(NULL)) ) {
TALLOC_FREE(pwd);
return NT_STATUS_NO_MEMORY;
}
+ if ( !(pwd = getpwnam_alloc(result, pdb_get_username(sampass))) ) {
+ DEBUG(1, ("User %s in passdb, but getpwnam() fails!\n",
+ pdb_get_username(sampass)));
+ return NT_STATUS_NO_SUCH_USER;
+ }
+
result->sam_account = sampass;
- result->unix_name = talloc_strdup(result, pwd->pw_name);
+ /* Ensure thaat the sampass will be freed with the result */
+ talloc_steal(result, sampass);
+ result->unix_name = pwd->pw_name;
+ /* Ensure that we keep pwd->pw_name, because we will free pwd below */
+ talloc_steal(result, pwd->pw_name);
result->gid = pwd->pw_gid;
result->uid = pwd->pw_uid;