mirror of
https://github.com/samba-team/samba.git
synced 2024-12-28 07:21:54 +03:00
Fixed the handle leak in the connection management code (this code is crap
and should be rewritten, just not now... :-). Jeremy.
This commit is contained in:
parent
5c4ce2129f
commit
5de792e7e9
@ -459,6 +459,13 @@ CLI_POLICY_HND *cm_get_lsa_handle(char *domain)
|
||||
if (!NT_STATUS_IS_OK(result = get_connection_from_cache(domain, PIPE_LSARPC, &conn))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This *shitty* code needs scrapping ! JRA */
|
||||
if (policy_handle_is_valid(&conn->pol)) {
|
||||
hnd.pol = conn->pol;
|
||||
hnd.cli = conn->cli;
|
||||
return &hnd;
|
||||
}
|
||||
|
||||
result = cli_lsa_open_policy(conn->cli, conn->cli->mem_ctx, False,
|
||||
des_access, &conn->pol);
|
||||
@ -503,6 +510,12 @@ CLI_POLICY_HND *cm_get_sam_handle(char *domain)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This *shitty* code needs scrapping ! JRA */
|
||||
if (policy_handle_is_valid(&conn->pol)) {
|
||||
hnd.pol = conn->pol;
|
||||
hnd.cli = conn->cli;
|
||||
return &hnd;
|
||||
}
|
||||
result = cli_samr_connect(conn->cli, conn->cli->mem_ctx,
|
||||
des_access, &conn->pol);
|
||||
|
||||
|
@ -67,7 +67,10 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
|
||||
ctr.sam.info1 = &info1;
|
||||
|
||||
ctx2 = talloc_init_named("winbindd dispinfo");
|
||||
if (!ctx2) return NT_STATUS_NO_MEMORY;
|
||||
if (!ctx2) {
|
||||
result = NT_STATUS_NO_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Query display info level 1 */
|
||||
result = cli_samr_query_dispinfo(hnd->cli, ctx2,
|
||||
@ -83,7 +86,9 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
|
||||
(*info) = talloc_realloc(mem_ctx, *info,
|
||||
(*num_entries)*sizeof(WINBIND_USERINFO));
|
||||
if (!(*info)) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
result = NT_STATUS_NO_MEMORY;
|
||||
talloc_destroy(ctx2);
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (j=0;j<count;i++, j++) {
|
||||
@ -157,6 +162,7 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
|
||||
sizeof(**info) * ((*num_entries) + count));
|
||||
if (! *info) {
|
||||
talloc_destroy(mem_ctx2);
|
||||
cli_samr_close(hnd->cli, mem_ctx, &dom_pol);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
@ -286,11 +292,14 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
|
||||
if (!NT_STATUS_IS_OK(result))
|
||||
goto done;
|
||||
|
||||
got_user_pol = True;
|
||||
|
||||
/* Get user info */
|
||||
result = cli_samr_query_userinfo(hnd->cli, mem_ctx, &user_pol,
|
||||
0x15, &ctr);
|
||||
|
||||
cli_samr_close(hnd->cli, mem_ctx, &user_pol);
|
||||
got_user_pol = False;
|
||||
|
||||
user_info->group_rid = ctr->info.id21->group_rid;
|
||||
user_info->acct_name = unistr2_tdup(mem_ctx,
|
||||
|
@ -2094,4 +2094,10 @@ BOOL lsa_io_r_removeprivs(char *desc, LSA_R_REMOVEPRIVS *r_c, prs_struct *ps, in
|
||||
return True;
|
||||
}
|
||||
|
||||
BOOL policy_handle_is_valid(const POLICY_HND *hnd)
|
||||
{
|
||||
POLICY_HND zero_pol;
|
||||
|
||||
ZERO_STRUCT(zero_pol);
|
||||
return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user