summaryrefslogtreecommitdiff
path: root/source4/auth
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-08-25 06:44:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:21 -0500
commitede02ee03867d2f6582c446fcab0882072baaa5a (patch)
treeea7e56a1b9f1552cc9752cf8736084555005518c /source4/auth
parent294f6f16947c56d3fac5b24e5c95e8df522e18d6 (diff)
downloadsamba-ede02ee03867d2f6582c446fcab0882072baaa5a.tar.gz
samba-ede02ee03867d2f6582c446fcab0882072baaa5a.tar.bz2
samba-ede02ee03867d2f6582c446fcab0882072baaa5a.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. (This used to be commit da60987a92266734c33b81ee217081abdc4330f3)
Diffstat (limited to 'source4/auth')
-rw-r--r--source4/auth/auth_sam.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/source4/auth/auth_sam.c b/source4/auth/auth_sam.c
index d83d25c42c..5239d6f413 100644
--- a/source4/auth/auth_sam.c
+++ b/source4/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;
}