Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/providers/krb5/krb5_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,15 @@ static krb5_error_code answer_pkinit(krb5_context ctx,
const char *module_name = NULL;
krb5_responder_pkinit_challenge *chl = NULL;
size_t c;
enum sss_authtok_type type;

type = sss_authtok_get_type(kr->pd->authtok);
if (type != SSS_AUTHTOK_TYPE_SC_PIN && type != SSS_AUTHTOK_TYPE_SC_KEYPAD) {
DEBUG(SSSDBG_MINOR_FAILURE, "Unexpected authentication token type [%s]\n",
sss_authtok_type_to_str(type));
kerr = ERR_CHECK_NEXT_AUTH_TYPE;
goto done;
}
Comment on lines +720 to +726
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While this check is correctly moved to the beginning of the function, it introduces redundancy with a later check. The if condition at line 750 will now always evaluate to true, making the else block at line 789 unreachable. As a follow-up, you should consider removing the redundant if-else structure (lines 750-795) and placing the code from the if block directly under if (kr->pd->cmd == SSS_PAM_AUTHENTICATE).


kerr = krb5_responder_pkinit_get_challenge(ctx, rctx, &chl);
if (kerr != EOK || chl == NULL) {
Expand Down Expand Up @@ -1271,11 +1280,12 @@ static krb5_error_code sss_krb5_responder(krb5_context ctx,
KRB5_RESPONDER_QUESTION_PASSWORD) == 0) {
kerr = answer_password(ctx, kr, rctx);
} else if (strcmp(question_list[c],
KRB5_RESPONDER_QUESTION_PKINIT) == 0
&& (sss_authtok_get_type(kr->pd->authtok)
== SSS_AUTHTOK_TYPE_SC_PIN
|| sss_authtok_get_type(kr->pd->authtok)
== SSS_AUTHTOK_TYPE_SC_KEYPAD)) {
KRB5_RESPONDER_QUESTION_PKINIT) == 0) {
/* Skip answer_pkinit for expired password changes, e.g. user with auth types
* passkey AND password set */
if (kr->pd->cmd == SSS_PAM_CHAUTHTOK_PRELIM || kr->pd->cmd == SSS_PAM_CHAUTHTOK) {
continue;
}
kerr = answer_pkinit(ctx, kr, rctx);
} else if (strcmp(question_list[c], SSSD_IDP_OAUTH2_QUESTION) == 0) {
kerr = answer_idp_oauth2(ctx, kr, rctx);
Expand Down
Loading