1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-06 13:18:07 +03:00

s4:kpasswd: Restructure code for clarity

View with 'git show -b'.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Joseph Sutton 2022-05-18 17:11:49 +12:00 committed by Jule Anger
parent 6c4fd575d7
commit 69e742e620

View File

@ -160,7 +160,16 @@ static krb5_error_code kpasswd_set_password(struct kdc_server *kdc,
return 0;
}
if (chpw.targname != NULL && chpw.targrealm != NULL) {
if (chpw.targname == NULL || chpw.targrealm == NULL) {
free_ChangePasswdDataMS(&chpw);
return kpasswd_change_password(kdc,
mem_ctx,
gensec_security,
session_info,
&password,
kpasswd_reply,
error_string);
}
code = krb5_build_principal_ext(context,
&target_principal,
strlen(*chpw.targrealm),
@ -175,25 +184,14 @@ static krb5_error_code kpasswd_set_password(struct kdc_server *kdc,
}
code = copy_PrincipalName(chpw.targname,
&target_principal->name);
if (code != 0) {
free_ChangePasswdDataMS(&chpw);
if (code != 0) {
krb5_free_principal(context, target_principal);
return kpasswd_make_error_reply(mem_ctx,
KRB5_KPASSWD_MALFORMED,
"Failed to parse principal",
kpasswd_reply);
}
} else {
free_ChangePasswdDataMS(&chpw);
return kpasswd_change_password(kdc,
mem_ctx,
gensec_security,
session_info,
&password,
kpasswd_reply,
error_string);
}
free_ChangePasswdDataMS(&chpw);
if (target_principal->name.name_string.len >= 2) {
is_service_principal = true;