1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-30 19:42:05 +03:00

s3-rpcclient: more uses of is_valid_policy_hnd in spoolss and samr commands.

Guenther
This commit is contained in:
Günther Deschner
2009-02-25 13:19:12 +01:00
parent 13ac0dc456
commit 2390ea274b
2 changed files with 12 additions and 45 deletions

View File

@ -789,7 +789,6 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
struct samr_SamArray *dom_users = NULL; struct samr_SamArray *dom_users = NULL;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
uint32 acb_mask = ACB_NORMAL; uint32 acb_mask = ACB_NORMAL;
bool got_connect_pol = False, got_domain_pol = False;
if ((argc < 1) || (argc > 3)) { if ((argc < 1) || (argc > 3)) {
printf("Usage: %s [access_mask] [acb_mask]\n", argv[0]); 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)) if (!NT_STATUS_IS_OK(result))
goto done; goto done;
got_connect_pol = True;
/* Get domain policy handle */ /* Get domain policy handle */
result = rpccli_samr_OpenDomain(cli, mem_ctx, 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)) if (!NT_STATUS_IS_OK(result))
goto done; goto done;
got_domain_pol = True;
/* Enumerate domain users */ /* Enumerate domain users */
start_idx = 0; 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)); } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done: done:
if (got_domain_pol) if (is_valid_policy_hnd(&domain_pol))
rpccli_samr_Close(cli, mem_ctx, &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); rpccli_samr_Close(cli, mem_ctx, &connect_pol);
return result; 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 start_idx, size, num_dom_groups, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
struct samr_SamArray *dom_groups = NULL; struct samr_SamArray *dom_groups = NULL;
bool got_connect_pol = False, got_domain_pol = False;
if ((argc < 1) || (argc > 2)) { if ((argc < 1) || (argc > 2)) {
printf("Usage: %s [access_mask]\n", argv[0]); 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)) if (!NT_STATUS_IS_OK(result))
goto done; goto done;
got_connect_pol = True;
/* Get domain policy handle */ /* Get domain policy handle */
result = rpccli_samr_OpenDomain(cli, mem_ctx, 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)) if (!NT_STATUS_IS_OK(result))
goto done; goto done;
got_domain_pol = True;
/* Enumerate domain groups */ /* Enumerate domain groups */
start_idx = 0; 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)); } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done: done:
if (got_domain_pol) if (is_valid_policy_hnd(&domain_pol))
rpccli_samr_Close(cli, mem_ctx, &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); rpccli_samr_Close(cli, mem_ctx, &connect_pol);
return result; 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 start_idx, size, num_als_groups, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
struct samr_SamArray *als_groups = NULL; struct samr_SamArray *als_groups = NULL;
bool got_connect_pol = False, got_domain_pol = False;
if ((argc < 2) || (argc > 3)) { if ((argc < 2) || (argc > 3)) {
printf("Usage: %s builtin|domain [access mask]\n", argv[0]); 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)) if (!NT_STATUS_IS_OK(result))
goto done; goto done;
got_connect_pol = True;
/* Get domain policy handle */ /* Get domain policy handle */
result = get_domain_handle(cli, mem_ctx, argv[1], 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)) if (!NT_STATUS_IS_OK(result))
goto done; goto done;
got_domain_pol = True;
/* Enumerate alias groups */ /* Enumerate alias groups */
start_idx = 0; 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)); } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done: done:
if (got_domain_pol) if (is_valid_policy_hnd(&domain_pol))
rpccli_samr_Close(cli, mem_ctx, &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); rpccli_samr_Close(cli, mem_ctx, &connect_pol);
return result; return result;
@ -1027,7 +1012,6 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli,
NTSTATUS result = NT_STATUS_UNSUCCESSFUL; NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 start_idx, size, num_entries, i; uint32 start_idx, size, num_entries, i;
uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED; uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
bool got_connect_pol = false;
struct samr_SamArray *sam = NULL; struct samr_SamArray *sam = NULL;
if ((argc < 1) || (argc > 2)) { if ((argc < 1) || (argc > 2)) {
@ -1049,8 +1033,6 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli,
goto done; goto done;
} }
got_connect_pol = true;
/* Enumerate alias groups */ /* Enumerate alias groups */
start_idx = 0; 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)); } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done: done:
if (got_connect_pol) { if (is_valid_policy_hnd(&connect_pol)) {
rpccli_samr_Close(cli, mem_ctx, &connect_pol); rpccli_samr_Close(cli, mem_ctx, &connect_pol);
} }

View File

@ -1812,7 +1812,6 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
WERROR werror; WERROR werror;
NTSTATUS status; NTSTATUS status;
const char *printername; const char *printername;
bool got_handle = False;
union spoolss_AddFormInfo info; union spoolss_AddFormInfo info;
struct spoolss_AddFormInfo1 info1; 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)) if (!W_ERROR_IS_OK(werror))
goto done; goto done;
got_handle = True;
/* Dummy up some values for the form data */ /* Dummy up some values for the form data */
info1.flags = FORM_USER; info1.flags = FORM_USER;
@ -1859,7 +1856,7 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
&werror); &werror);
done: done:
if (got_handle) if (is_valid_policy_hnd(&handle))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
return werror; return werror;
@ -1875,7 +1872,6 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
WERROR werror; WERROR werror;
NTSTATUS status; NTSTATUS status;
const char *printername; const char *printername;
bool got_handle = False;
union spoolss_AddFormInfo info; union spoolss_AddFormInfo info;
struct spoolss_AddFormInfo1 info1; 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)) if (!W_ERROR_IS_OK(werror))
goto done; goto done;
got_handle = True;
/* Dummy up some values for the form data */ /* Dummy up some values for the form data */
info1.flags = FORM_PRINTER; info1.flags = FORM_PRINTER;
@ -1922,7 +1916,7 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
&werror); &werror);
done: done:
if (got_handle) if (is_valid_policy_hnd(&handle))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
return werror; return werror;
@ -1991,7 +1985,6 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
WERROR werror; WERROR werror;
NTSTATUS status; NTSTATUS status;
const char *printername; const char *printername;
bool got_handle = False;
DATA_BLOB buffer; DATA_BLOB buffer;
uint32_t offered = 0; uint32_t offered = 0;
union spoolss_FormInfo info; 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)) if (!W_ERROR_IS_OK(werror))
goto done; goto done;
got_handle = True;
/* Get the form */ /* Get the form */
status = rpccli_spoolss_GetForm(cli, mem_ctx, 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); display_form_info1(&info.info1);
done: done:
if (got_handle) if (is_valid_policy_hnd(&handle))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
return werror; return werror;
@ -2065,7 +2056,6 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
WERROR werror; WERROR werror;
NTSTATUS status; NTSTATUS status;
const char *printername; const char *printername;
bool got_handle = False;
/* Parse the command arguments */ /* Parse the command arguments */
@ -2085,8 +2075,6 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(werror)) if (!W_ERROR_IS_OK(werror))
goto done; goto done;
got_handle = True;
/* Delete the form */ /* Delete the form */
status = rpccli_spoolss_DeleteForm(cli, mem_ctx, status = rpccli_spoolss_DeleteForm(cli, mem_ctx,
@ -2098,7 +2086,7 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
} }
done: done:
if (got_handle) if (is_valid_policy_hnd(&handle))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
return werror; return werror;
@ -2114,7 +2102,6 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
POLICY_HND handle; POLICY_HND handle;
WERROR werror; WERROR werror;
const char *printername; const char *printername;
bool got_handle = False;
uint32 num_forms, level = 1, i; uint32 num_forms, level = 1, i;
FORM_1 *forms; FORM_1 *forms;
@ -2136,8 +2123,6 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(werror)) if (!W_ERROR_IS_OK(werror))
goto done; goto done;
got_handle = True;
/* Enumerate forms */ /* Enumerate forms */
werror = rpccli_spoolss_enumforms(cli, mem_ctx, &handle, level, &num_forms, &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: done:
if (got_handle) if (is_valid_policy_hnd(&handle))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
return werror; return werror;