summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/nsswitch/winbindd_cm.c13
-rw-r--r--source3/nsswitch/winbindd_rpc.c13
-rw-r--r--source3/rpc_parse/parse_lsa.c6
3 files changed, 30 insertions, 2 deletions
diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c
index f4abf86c47..ce484795f8 100644
--- a/source3/nsswitch/winbindd_cm.c
+++ b/source3/nsswitch/winbindd_cm.c
@@ -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);
diff --git a/source3/nsswitch/winbindd_rpc.c b/source3/nsswitch/winbindd_rpc.c
index c56b553bdc..53c39b2f57 100644
--- a/source3/nsswitch/winbindd_rpc.c
+++ b/source3/nsswitch/winbindd_rpc.c
@@ -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,
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c
index fd82325be7..91b54b9c83 100644
--- a/source3/rpc_parse/parse_lsa.c
+++ b/source3/rpc_parse/parse_lsa.c
@@ -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 );
+}