summaryrefslogtreecommitdiff
path: root/source3/auth
diff options
context:
space:
mode:
Diffstat (limited to 'source3/auth')
-rw-r--r--source3/auth/auth_sam.c2
-rw-r--r--source3/auth/auth_util.c18
2 files changed, 12 insertions, 8 deletions
diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c
index 847315ef88..31178a761c 100644
--- a/source3/auth/auth_sam.c
+++ b/source3/auth/auth_sam.c
@@ -266,7 +266,7 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
/* Can't use the talloc version here, because the returned struct gets
kept on the server_info */
- if ( !(sampass = samu_new( NULL )) ) {
+ if ( !(sampass = samu_new( mem_ctx )) ) {
return NT_STATUS_NO_MEMORY;
}
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;