From: Günther Deschner Date: Tue, 15 Jul 2014 06:28:42 +0000 (+0200) Subject: s3-rpc_client: return info3 in rpccli_netlogon_password_logon(). X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=b722167b2c7435dbd14684261002522808eb7aaf;p=obnox%2Fsamba%2Fsamba-obnox.git s3-rpc_client: return info3 in rpccli_netlogon_password_logon(). Guenther Signed-off-by: Günther Deschner Pair-Programmed-With: Andreas Schneider Reviewed-by: Andreas Schneider --- diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index 746c7b6480f..7063351ef8a 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -193,16 +193,65 @@ NTSTATUS rpccli_setup_netlogon_creds(struct cli_state *cli, return NT_STATUS_OK; } +static NTSTATUS map_validation_to_info3(TALLOC_CTX *mem_ctx, + uint16_t validation_level, + union netr_Validation *validation, + struct netr_SamInfo3 **info3_p) +{ + struct netr_SamInfo3 *info3; + NTSTATUS status; + + if (validation == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } + + switch (validation_level) { + case 3: + if (validation->sam3 == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } + + info3 = talloc_move(mem_ctx, &validation->sam3); + break; + case 6: + if (validation->sam6 == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } + + info3 = talloc_zero(mem_ctx, struct netr_SamInfo3); + if (info3 == NULL) { + return NT_STATUS_NO_MEMORY; + } + status = copy_netr_SamBaseInfo(info3, &validation->sam6->base, &info3->base); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(info3); + return status; + } + + info3->sidcount = validation->sam6->sidcount; + info3->sids = talloc_move(info3, &validation->sam6->sids); + break; + default: + return NT_STATUS_BAD_VALIDATION_CLASS; + } + + *info3_p = info3; + + return NT_STATUS_OK; +} + /* Logon domain user */ NTSTATUS rpccli_netlogon_password_logon(struct netlogon_creds_cli_context *creds, struct dcerpc_binding_handle *binding_handle, + TALLOC_CTX *mem_ctx, uint32_t logon_parameters, const char *domain, const char *username, const char *password, const char *workstation, - enum netr_LogonInfoClass logon_type) + enum netr_LogonInfoClass logon_type, + struct netr_SamInfo3 **info3) { TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; @@ -320,57 +369,19 @@ NTSTATUS rpccli_netlogon_password_logon(struct netlogon_creds_cli_context *creds &validation, &authoritative, &flags); - TALLOC_FREE(frame); if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(frame); return status; } - return NT_STATUS_OK; -} - -static NTSTATUS map_validation_to_info3(TALLOC_CTX *mem_ctx, - uint16_t validation_level, - union netr_Validation *validation, - struct netr_SamInfo3 **info3_p) -{ - struct netr_SamInfo3 *info3; - NTSTATUS status; - - if (validation == NULL) { - return NT_STATUS_INVALID_PARAMETER; - } - - switch (validation_level) { - case 3: - if (validation->sam3 == NULL) { - return NT_STATUS_INVALID_PARAMETER; - } - - info3 = talloc_move(mem_ctx, &validation->sam3); - break; - case 6: - if (validation->sam6 == NULL) { - return NT_STATUS_INVALID_PARAMETER; - } - - info3 = talloc_zero(mem_ctx, struct netr_SamInfo3); - if (info3 == NULL) { - return NT_STATUS_NO_MEMORY; - } - status = copy_netr_SamBaseInfo(info3, &validation->sam6->base, &info3->base); - if (!NT_STATUS_IS_OK(status)) { - TALLOC_FREE(info3); - return status; - } - - info3->sidcount = validation->sam6->sidcount; - info3->sids = talloc_move(info3, &validation->sam6->sids); - break; - default: - return NT_STATUS_BAD_VALIDATION_CLASS; + status = map_validation_to_info3(mem_ctx, + validation_level, validation, + info3); + TALLOC_FREE(frame); + if (!NT_STATUS_IS_OK(status)) { + return status; } - *info3_p = info3; return NT_STATUS_OK; } diff --git a/source3/rpc_client/cli_netlogon.h b/source3/rpc_client/cli_netlogon.h index 61fed4acdd6..fee08016d5d 100644 --- a/source3/rpc_client/cli_netlogon.h +++ b/source3/rpc_client/cli_netlogon.h @@ -45,12 +45,14 @@ NTSTATUS rpccli_setup_netlogon_creds(struct cli_state *cli, const struct samr_Password *previous_nt_hash); NTSTATUS rpccli_netlogon_password_logon(struct netlogon_creds_cli_context *creds, struct dcerpc_binding_handle *binding_handle, + TALLOC_CTX *mem_ctx, uint32_t logon_parameters, const char *domain, const char *username, const char *password, const char *workstation, - enum netr_LogonInfoClass logon_type); + enum netr_LogonInfoClass logon_type, + struct netr_SamInfo3 **info3); NTSTATUS rpccli_netlogon_network_logon(struct netlogon_creds_cli_context *creds, struct dcerpc_binding_handle *binding_handle, TALLOC_CTX *mem_ctx, diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index b637b3e68c6..2d1c35168ce 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -778,6 +778,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli, const char *username, *password; uint32 logon_param = 0; const char *workstation = NULL; + struct netr_SamInfo3 *info3 = NULL; /* Check arguments */ @@ -803,12 +804,14 @@ static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli, result = rpccli_netlogon_password_logon(rpcclient_netlogon_creds, cli->binding_handle, + mem_ctx, logon_param, lp_workgroup(), username, password, workstation, - logon_type); + logon_type, + &info3); if (!NT_STATUS_IS_OK(result)) goto done;