diff options
-rw-r--r-- | source3/rpcclient/cmd_samr.c | 32 | ||||
-rw-r--r-- | source3/rpcclient/cmd_spoolss.c | 25 |
2 files changed, 12 insertions, 45 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 31977e9554..936c2081f3 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -789,7 +789,6 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli, struct samr_SamArray *dom_users = NULL; uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; uint32 acb_mask = ACB_NORMAL; - bool got_connect_pol = False, got_domain_pol = False; if ((argc < 1) || (argc > 3)) { printf("Usage: %s [access_mask] [acb_mask]\n", argv[0]); @@ -811,8 +810,6 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - got_connect_pol = True; - /* Get domain policy handle */ result = rpccli_samr_OpenDomain(cli, mem_ctx, @@ -824,8 +821,6 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - got_domain_pol = True; - /* Enumerate domain users */ start_idx = 0; @@ -852,10 +847,10 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli, } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)); done: - if (got_domain_pol) + if (is_valid_policy_hnd(&domain_pol)) rpccli_samr_Close(cli, mem_ctx, &domain_pol); - if (got_connect_pol) + if (is_valid_policy_hnd(&connect_pol)) rpccli_samr_Close(cli, mem_ctx, &connect_pol); return result; @@ -872,7 +867,6 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli, uint32 start_idx, size, num_dom_groups, i; uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; struct samr_SamArray *dom_groups = NULL; - bool got_connect_pol = False, got_domain_pol = False; if ((argc < 1) || (argc > 2)) { printf("Usage: %s [access_mask]\n", argv[0]); @@ -891,8 +885,6 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - got_connect_pol = True; - /* Get domain policy handle */ result = rpccli_samr_OpenDomain(cli, mem_ctx, @@ -904,8 +896,6 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - got_domain_pol = True; - /* Enumerate domain groups */ start_idx = 0; @@ -930,10 +920,10 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli, } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)); done: - if (got_domain_pol) + if (is_valid_policy_hnd(&domain_pol)) rpccli_samr_Close(cli, mem_ctx, &domain_pol); - if (got_connect_pol) + if (is_valid_policy_hnd(&connect_pol)) rpccli_samr_Close(cli, mem_ctx, &connect_pol); return result; @@ -950,7 +940,6 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli, uint32 start_idx, size, num_als_groups, i; uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; struct samr_SamArray *als_groups = NULL; - bool got_connect_pol = False, got_domain_pol = False; if ((argc < 2) || (argc > 3)) { printf("Usage: %s builtin|domain [access mask]\n", argv[0]); @@ -969,8 +958,6 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - got_connect_pol = True; - /* Get domain policy handle */ result = get_domain_handle(cli, mem_ctx, argv[1], @@ -982,8 +969,6 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - got_domain_pol = True; - /* Enumerate alias groups */ start_idx = 0; @@ -1008,10 +993,10 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli, } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)); done: - if (got_domain_pol) + if (is_valid_policy_hnd(&domain_pol)) rpccli_samr_Close(cli, mem_ctx, &domain_pol); - if (got_connect_pol) + if (is_valid_policy_hnd(&connect_pol)) rpccli_samr_Close(cli, mem_ctx, &connect_pol); return result; @@ -1027,7 +1012,6 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; uint32 start_idx, size, num_entries, i; uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - bool got_connect_pol = false; struct samr_SamArray *sam = NULL; if ((argc < 1) || (argc > 2)) { @@ -1049,8 +1033,6 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli, goto done; } - got_connect_pol = true; - /* Enumerate alias groups */ start_idx = 0; @@ -1075,7 +1057,7 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli, } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)); done: - if (got_connect_pol) { + if (is_valid_policy_hnd(&connect_pol)) { rpccli_samr_Close(cli, mem_ctx, &connect_pol); } diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index fe2554e02d..eaee516ad5 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1812,7 +1812,6 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c WERROR werror; NTSTATUS status; const char *printername; - bool got_handle = False; union spoolss_AddFormInfo info; struct spoolss_AddFormInfo1 info1; @@ -1834,8 +1833,6 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c if (!W_ERROR_IS_OK(werror)) goto done; - got_handle = True; - /* Dummy up some values for the form data */ info1.flags = FORM_USER; @@ -1859,7 +1856,7 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c &werror); done: - if (got_handle) + if (is_valid_policy_hnd(&handle)) rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); return werror; @@ -1875,7 +1872,6 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c WERROR werror; NTSTATUS status; const char *printername; - bool got_handle = False; union spoolss_AddFormInfo info; struct spoolss_AddFormInfo1 info1; @@ -1897,8 +1893,6 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c if (!W_ERROR_IS_OK(werror)) goto done; - got_handle = True; - /* Dummy up some values for the form data */ info1.flags = FORM_PRINTER; @@ -1922,7 +1916,7 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c &werror); done: - if (got_handle) + if (is_valid_policy_hnd(&handle)) rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); return werror; @@ -1991,7 +1985,6 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c WERROR werror; NTSTATUS status; const char *printername; - bool got_handle = False; DATA_BLOB buffer; uint32_t offered = 0; union spoolss_FormInfo info; @@ -2015,8 +2008,6 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c if (!W_ERROR_IS_OK(werror)) goto done; - got_handle = True; - /* Get the form */ status = rpccli_spoolss_GetForm(cli, mem_ctx, @@ -2048,7 +2039,7 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c display_form_info1(&info.info1); done: - if (got_handle) + if (is_valid_policy_hnd(&handle)) rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); return werror; @@ -2065,7 +2056,6 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli, WERROR werror; NTSTATUS status; const char *printername; - bool got_handle = False; /* Parse the command arguments */ @@ -2085,8 +2075,6 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli, if (!W_ERROR_IS_OK(werror)) goto done; - got_handle = True; - /* Delete the form */ status = rpccli_spoolss_DeleteForm(cli, mem_ctx, @@ -2098,7 +2086,7 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli, } done: - if (got_handle) + if (is_valid_policy_hnd(&handle)) rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); return werror; @@ -2114,7 +2102,6 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli, POLICY_HND handle; WERROR werror; const char *printername; - bool got_handle = False; uint32 num_forms, level = 1, i; FORM_1 *forms; @@ -2136,8 +2123,6 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli, if (!W_ERROR_IS_OK(werror)) goto done; - got_handle = True; - /* Enumerate forms */ werror = rpccli_spoolss_enumforms(cli, mem_ctx, &handle, level, &num_forms, &forms); @@ -2154,7 +2139,7 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli, } done: - if (got_handle) + if (is_valid_policy_hnd(&handle)) rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); return werror; |