summaryrefslogtreecommitdiffstats
path: root/source/auth/auth_sam.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-08-25 06:44:23 +0000
committerAndrew Tridgell <tridge@samba.org>2004-08-25 06:44:23 +0000
commit11a7dbcd0b57123612179581809aab7e66cef925 (patch)
treecdcfd1d87dfaa3df2c07f698c5e3d64a7b37a37d /source/auth/auth_sam.c
parent55e5ed05bbb5477f484ee06a76d96a492fc687b9 (diff)
downloadsamba-11a7dbcd0b57123612179581809aab7e66cef925.tar.gz
samba-11a7dbcd0b57123612179581809aab7e66cef925.tar.xz
samba-11a7dbcd0b57123612179581809aab7e66cef925.zip
r2051: switched the samdb over to using the new destructor and reference
count features of talloc, instead of re-implementing both those features inside of samdb (which is what we did before). This makes samdb considerably simpler, and also fixes some bugs, as I found some error paths that didn't call samdb_close(). Those are now handled by the fact that a talloc_free() will auto-close and destroy the samdb context, using a destructor.
Diffstat (limited to 'source/auth/auth_sam.c')
-rw-r--r--source/auth/auth_sam.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/source/auth/auth_sam.c b/source/auth/auth_sam.c
index d83d25c42c3..5239d6f4130 100644
--- a/source/auth/auth_sam.c
+++ b/source/auth/auth_sam.c
@@ -218,7 +218,7 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
return NT_STATUS_UNSUCCESSFUL;
}
- sam_ctx = samdb_connect();
+ sam_ctx = samdb_connect(mem_ctx);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@@ -230,19 +230,16 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
if (ret == 0) {
DEBUG(3,("check_sam_security: Couldn't find user [%s] in passdb file.\n",
username));
- samdb_close(sam_ctx);
return NT_STATUS_NO_SUCH_USER;
}
if (ret > 1) {
DEBUG(0,("Found %d records matching user [%s]\n", ret, username));
- samdb_close(sam_ctx);
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
domain_sid = samdb_result_sid_prefix(mem_ctx, msgs[0], "objectSid");
if (!domain_sid) {
- samdb_close(sam_ctx);
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -254,14 +251,12 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
if (ret_domain == 0) {
DEBUG(3,("check_sam_security: Couldn't find domain [%s] in passdb file.\n",
domain_sid));
- samdb_close(sam_ctx);
return NT_STATUS_NO_SUCH_USER;
}
if (ret_domain > 1) {
DEBUG(0,("Found %d records matching domain [%s]\n",
ret_domain, domain_sid));
- samdb_close(sam_ctx);
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -273,7 +268,6 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
if (acct_flags & ACB_AUTOLOCK) {
DEBUG(3,("check_sam_security: Account for user %s was locked out.\n",
username));
- samdb_close(sam_ctx);
return NT_STATUS_ACCOUNT_LOCKED_OUT;
}
@@ -288,7 +282,6 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
user_info, &user_sess_key, &lm_sess_key);
if (!NT_STATUS_IS_OK(nt_status)) {
- samdb_close(sam_ctx);
return nt_status;
}
@@ -308,13 +301,11 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
user_info);
if (!NT_STATUS_IS_OK(nt_status)) {
- samdb_close(sam_ctx);
return nt_status;
}
if (!NT_STATUS_IS_OK(nt_status = make_server_info(server_info, username))) {
DEBUG(0,("check_sam_security: make_server_info_sam() failed with '%s'\n", nt_errstr(nt_status)));
- samdb_close(sam_ctx);
return nt_status;
}
@@ -342,7 +333,6 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
!(groupSIDs = talloc_realloc_p(groupSIDs,
struct dom_sid *, group_ret))) {
talloc_destroy((*server_info)->mem_ctx);
- samdb_close(sam_ctx);
return NT_STATUS_NO_MEMORY;
}
@@ -422,8 +412,6 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
return NT_STATUS_NO_MEMORY;
}
- samdb_close(sam_ctx);
-
return nt_status;
}