1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

s3:rpc_server: Use a done goto label for dcesrv_samr_SetUserInfo()

This will be used in the following commits.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Andreas Schneider 2022-07-26 10:57:19 +02:00 committed by Andreas Schneider
parent 2226806ce0
commit a246ae993f

View File

@ -3713,13 +3713,14 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
r->in.info->info18.lm_pwd_active ? r->in.info->info18.lm_pwd.hash : NULL,
r->in.info->info18.nt_pwd_active ? r->in.info->info18.nt_pwd.hash : NULL);
if (!NT_STATUS_IS_OK(status)) {
return status;
goto done;
}
if (r->in.info->info18.password_expired > 0) {
struct ldb_message_element *set_el;
if (samdb_msg_add_uint64(sam_ctx, mem_ctx, msg, "pwdLastSet", 0) != LDB_SUCCESS) {
return NT_STATUS_NO_MEMORY;
status = NT_STATUS_NO_MEMORY;
goto done;
}
set_el = ldb_msg_find_element(msg, "pwdLastSet");
set_el->flags = LDB_FLAG_MOD_REPLACE;
@ -3731,8 +3732,10 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
break;
case 21:
if (r->in.info->info21.fields_present == 0)
return NT_STATUS_INVALID_PARAMETER;
if (r->in.info->info21.fields_present == 0) {
status = NT_STATUS_INVALID_PARAMETER;
goto done;
}
#define IFSET(bit) if (bit & r->in.info->info21.fields_present)
IFSET(SAMR_FIELD_LAST_LOGON)
@ -3777,8 +3780,10 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
SET_UINT (msg, info21.code_page, "codePage");
/* password change fields */
IFSET(SAMR_FIELD_LAST_PWD_CHANGE)
return NT_STATUS_ACCESS_DENIED;
IFSET(SAMR_FIELD_LAST_PWD_CHANGE) {
status = NT_STATUS_ACCESS_DENIED;
goto done;
}
IFSET((SAMR_FIELD_LM_PASSWORD_PRESENT
| SAMR_FIELD_NT_PASSWORD_PRESENT)) {
@ -3787,7 +3792,8 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
if (r->in.info->info21.lm_password_set) {
if ((r->in.info->info21.lm_owf_password.length != 16)
|| (r->in.info->info21.lm_owf_password.size != 16)) {
return NT_STATUS_INVALID_PARAMETER;
status = NT_STATUS_INVALID_PARAMETER;
goto done;
}
lm_pwd_hash = (uint8_t *) r->in.info->info21.lm_owf_password.array;
@ -3795,7 +3801,8 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
if (r->in.info->info21.nt_password_set) {
if ((r->in.info->info21.nt_owf_password.length != 16)
|| (r->in.info->info21.nt_owf_password.size != 16)) {
return NT_STATUS_INVALID_PARAMETER;
status = NT_STATUS_INVALID_PARAMETER;
goto done;
}
nt_pwd_hash = (uint8_t *) r->in.info->info21.nt_owf_password.array;
@ -3808,7 +3815,7 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
lm_pwd_hash,
nt_pwd_hash);
if (!NT_STATUS_IS_OK(status)) {
return status;
goto done;
}
}
@ -3821,7 +3828,8 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
t = "-1";
}
if (ldb_msg_add_string(msg, "pwdLastSet", t) != LDB_SUCCESS) {
return NT_STATUS_NO_MEMORY;
status = NT_STATUS_NO_MEMORY;
goto done;
}
set_el = ldb_msg_find_element(msg, "pwdLastSet");
set_el->flags = LDB_FLAG_MOD_REPLACE;
@ -3830,8 +3838,10 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
break;
case 23:
if (r->in.info->info23.info.fields_present == 0)
return NT_STATUS_INVALID_PARAMETER;
if (r->in.info->info23.info.fields_present == 0) {
status = NT_STATUS_INVALID_PARAMETER;
goto done;
}
#define IFSET(bit) if (bit & r->in.info->info23.info.fields_present)
IFSET(SAMR_FIELD_LAST_LOGON)
@ -3877,8 +3887,10 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
SET_UINT (msg, info23.info.code_page, "codePage");
/* password change fields */
IFSET(SAMR_FIELD_LAST_PWD_CHANGE)
return NT_STATUS_ACCESS_DENIED;
IFSET(SAMR_FIELD_LAST_PWD_CHANGE) {
status = NT_STATUS_ACCESS_DENIED;
goto done;
}
IFSET(SAMR_FIELD_NT_PASSWORD_PRESENT) {
status = samr_set_password(dce_call,
@ -3896,7 +3908,7 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
&r->in.info->info23.password);
}
if (!NT_STATUS_IS_OK(status)) {
return status;
goto done;
}
IFSET(SAMR_FIELD_EXPIRED_FLAG) {
@ -3907,7 +3919,8 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
t = "-1";
}
if (ldb_msg_add_string(msg, "pwdLastSet", t) != LDB_SUCCESS) {
return NT_STATUS_NO_MEMORY;
status = NT_STATUS_NO_MEMORY;
goto done;
}
set_el = ldb_msg_find_element(msg, "pwdLastSet");
set_el->flags = LDB_FLAG_MOD_REPLACE;
@ -3924,13 +3937,14 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
mem_ctx,
&r->in.info->info24.password);
if (!NT_STATUS_IS_OK(status)) {
return status;
goto done;
}
if (r->in.info->info24.password_expired > 0) {
struct ldb_message_element *set_el;
if (samdb_msg_add_uint64(sam_ctx, mem_ctx, msg, "pwdLastSet", 0) != LDB_SUCCESS) {
return NT_STATUS_NO_MEMORY;
status = NT_STATUS_NO_MEMORY;
goto done;
}
set_el = ldb_msg_find_element(msg, "pwdLastSet");
set_el->flags = LDB_FLAG_MOD_REPLACE;
@ -3938,8 +3952,10 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
break;
case 25:
if (r->in.info->info25.info.fields_present == 0)
return NT_STATUS_INVALID_PARAMETER;
if (r->in.info->info25.info.fields_present == 0) {
status = NT_STATUS_INVALID_PARAMETER;
goto done;
}
#define IFSET(bit) if (bit & r->in.info->info25.info.fields_present)
IFSET(SAMR_FIELD_LAST_LOGON)
@ -3984,8 +4000,10 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
SET_UINT (msg, info25.info.code_page, "codePage");
/* password change fields */
IFSET(SAMR_FIELD_LAST_PWD_CHANGE)
return NT_STATUS_ACCESS_DENIED;
IFSET(SAMR_FIELD_LAST_PWD_CHANGE) {
status = NT_STATUS_ACCESS_DENIED;
goto done;
}
IFSET(SAMR_FIELD_NT_PASSWORD_PRESENT) {
status = samr_set_password_ex(dce_call,
@ -4003,7 +4021,7 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
&r->in.info->info25.password);
}
if (!NT_STATUS_IS_OK(status)) {
return status;
goto done;
}
IFSET(SAMR_FIELD_EXPIRED_FLAG) {
@ -4014,7 +4032,8 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
t = "-1";
}
if (ldb_msg_add_string(msg, "pwdLastSet", t) != LDB_SUCCESS) {
return NT_STATUS_NO_MEMORY;
status = NT_STATUS_NO_MEMORY;
goto done;
}
set_el = ldb_msg_find_element(msg, "pwdLastSet");
set_el->flags = LDB_FLAG_MOD_REPLACE;
@ -4031,7 +4050,7 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
mem_ctx,
&r->in.info->info26.password);
if (!NT_STATUS_IS_OK(status)) {
return status;
goto done;
}
if (r->in.info->info26.password_expired > 0) {
@ -4042,7 +4061,8 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
t = "-1";
}
if (ldb_msg_add_string(msg, "pwdLastSet", t) != LDB_SUCCESS) {
return NT_STATUS_NO_MEMORY;
status = NT_STATUS_NO_MEMORY;
goto done;
}
set_el = ldb_msg_find_element(msg, "pwdLastSet");
set_el->flags = LDB_FLAG_MOD_REPLACE;
@ -4051,11 +4071,12 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
default:
/* many info classes are not valid for SetUserInfo */
return NT_STATUS_INVALID_INFO_CLASS;
status = NT_STATUS_INVALID_INFO_CLASS;
goto done;
}
if (!NT_STATUS_IS_OK(status)) {
return status;
goto done;
}
/* modify the samdb record */
@ -4066,11 +4087,14 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
ldb_dn_get_linearized(a_state->account_dn),
ldb_errstring(a_state->sam_ctx)));
return dsdb_ldb_err_to_ntstatus(ret);
status = dsdb_ldb_err_to_ntstatus(ret);
goto done;
}
}
return NT_STATUS_OK;
status = NT_STATUS_OK;
done:
return status;
}