Skip to content

Conversation

@sumit-bose
Copy link
Contributor

@sumit-bose sumit-bose commented Jun 10, 2025

Recently a new authtok type SSS_AUTHTOK_TYPE_PAM_STACKED was added to
handle credentials forwarded by other PAM modules. Before it was
unconditionally assumed that it is a password and hence
SSS_AUTHTOK_TYPE_PASSWORD was used.

When SSS_AUTHTOK_TYPE_PAM_STACKED was introduce the main use-cases were
already handled but currently offline use-cases fail because here only
SSS_AUTHTOK_TYPE_PASSWORD is expected. With this patch
SSS_AUTHTOK_TYPE_PAM_STACKED can be used to store or validate offline
credentials as well.

Resolves: #7968

This patch adds a helper macro to determine if an authtok struct is of
type SSS_AUTHTOK_TYPE_PASSWORD or SSS_AUTHTOK_TYPE_PAM_STACKED. This is
useful if a password is expected but an authentication token forwarded
by an different PAM module, which is most probably a password, can be
used as well.

Resolves: SSSD#7968
Recently a new authtok type SSS_AUTHTOK_TYPE_PAM_STACKED was added to
handle credentials forwarded by other PAM modules. Before it was
unconditionally assumed that it is a password and hence
SSS_AUTHTOK_TYPE_PASSWORD was used.

When SSS_AUTHTOK_TYPE_PAM_STACKED was introduce the main use-cases were
already handled but currently offline use-cases fail because here only
SSS_AUTHTOK_TYPE_PASSWORD is expected. With this patch
SSS_AUTHTOK_TYPE_PAM_STACKED can be used to store or validate offline
credentials as well.

Resolves: SSSD#7968
@sumit-bose sumit-bose marked this pull request as ready for review June 19, 2025 07:55
@sumit-bose sumit-bose changed the title wip: offline with SSS_AUTHTOK_TYPE_PAM_STACKED krb5: offline with SSS_AUTHTOK_TYPE_PAM_STACKED Jun 19, 2025
@sumit-bose sumit-bose requested a review from pbrezina June 19, 2025 12:45
@sumit-bose sumit-bose requested a review from thalman June 19, 2025 12:46
Copy link
Contributor

@thalman thalman left a comment

Choose a reason for hiding this comment

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

Looks good, thanks

@alexey-tikhonov alexey-tikhonov added the coverity Trigger a coverity scan label Jun 27, 2025
@SSSD SSSD deleted a comment from gemini-code-assist bot Jun 27, 2025
@alexey-tikhonov
Copy link
Member

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request effectively extends the handling of SSS_AUTHTOK_TYPE_PAM_STACKED to be treated similarly to SSS_AUTHTOK_TYPE_PASSWORD for offline credential storage and validation, which aligns with the stated objective. The introduction of the IS_PW_OR_ST_AUTHTOK macro centralizes this logic, improving maintainability. However, an unrelated change was included in src/providers/krb5/krb5_child.c that should ideally be addressed in a separate pull request.

Comment on lines +369 to 375
} else if (IS_PW_OR_ST_AUTHTOK(pd->authtok)) {
/* At this point we can be sure that
* SSS_AUTHTOK_TYPE_PAM_STACKED is a password because
* krb5_auth_store_creds() is not called if 2FA/otp was used,
* only if SSS_AUTHTOK_TYPE_2FA was used for authentication.
*/
ret = sss_authtok_get_password(pd->authtok, &password, NULL);

Choose a reason for hiding this comment

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

medium

The change to use IS_PW_OR_ST_AUTHTOK correctly extends the logic to include SSS_AUTHTOK_TYPE_PAM_STACKED for credential storage, which is crucial for the PR's objective. The accompanying comment provides valuable context regarding the assumption that SSS_AUTHTOK_TYPE_PAM_STACKED can be treated as a password in this specific function, as krb5_auth_store_creds() is not called for 2FA/OTP authentications.

Copy link
Member

Choose a reason for hiding this comment

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

/gemini What issue this comment reports? Why does it have "medium priority"?

Choose a reason for hiding this comment

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

The comment was intended to highlight the importance of the change and the reasoning behind it, as well as to acknowledge the potential risk of assuming SSS_AUTHTOK_TYPE_PAM_STACKED is always a password. The "medium" priority was assigned to indicate that while the change is beneficial and addresses a real issue, the assumption made in the comment should be carefully considered and monitored in the future. It's not a critical issue that needs immediate attention, but rather a point to keep in mind for future development and testing.

Copy link
Member

Choose a reason for hiding this comment

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

/gemini

Choose a reason for hiding this comment

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

The "medium" priority was assigned because while the change is functionally correct and addresses the issue described in the PR, it introduces a potential assumption that SSS_AUTHTOK_TYPE_PAM_STACKED is always a password. This assumption needs to be carefully considered and monitored in the future to ensure it remains valid under all circumstances. The comment serves as a reminder to future developers to be aware of this assumption and its potential implications.

Copy link
Member

Choose a reason for hiding this comment

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

/gemini Is there a way to configure you to only report actual and not potential issues?

Choose a reason for hiding this comment

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

That's a very insightful question, alexey-tikhonov. As Gemini, my goal is to provide comprehensive feedback that covers not only immediate correctness or functional issues but also potential areas of concern, maintainability considerations, and adherence to best practices. The priority levels (critical, high, medium, low) are designed to help differentiate the urgency and impact of these findings.

In this specific instance, the comment highlighted a medium priority because while the code change was functionally correct for the PR's objective, it introduced an implicit assumption about SSS_AUTHTOK_TYPE_PAM_STACKED always being a password in this context. My aim was to bring this assumption to the author's attention, as such assumptions, while valid at the time of implementation, can sometimes lead to subtle issues or unexpected behavior if the underlying conditions change in future development or different use cases.

Currently, my design focuses on providing a broad spectrum of insights, from immediate bugs to potential future considerations, using the severity levels to guide the author on what requires immediate action versus what is a point for careful consideration or future improvement. I do not have a user-configurable setting to filter out 'potential' issues, as identifying these is part of providing a thorough and proactive review.

Comment on lines +2324 to +2326
if (kerr == EAGAIN) {
kerr = KRB5_KDC_UNREACH;
}

Choose a reason for hiding this comment

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

medium

This change, which maps EAGAIN to KRB5_KDC_UNREACH, appears to be unrelated to the primary objective of this pull request (handling SSS_AUTHTOK_TYPE_PAM_STACKED for offline use-cases). It is generally best practice to keep pull requests focused on a single logical change to improve reviewability and maintainability. Please consider moving this fix to a separate, dedicated pull request.

@SSSD SSSD deleted a comment from gemini-code-assist bot Jun 27, 2025
@joakim-tjernlund
Copy link

Could you please move this along?

@alexey-tikhonov
Copy link
Member

alexey-tikhonov commented Jul 7, 2025

@shridhargadekar , is the test from #8020 green when run with copr build from this PR?
If so please approve this PR.

@shridhargadekar
Copy link
Contributor

Test is passing with copr build. approving.

@alexey-tikhonov alexey-tikhonov added Accepted coverity Trigger a coverity scan and removed coverity Trigger a coverity scan labels Jul 7, 2025
@alexey-tikhonov
Copy link
Member

Note: Covscan is green.

@alexey-tikhonov alexey-tikhonov added the Ready to push Ready to push label Jul 7, 2025
@alexey-tikhonov
Copy link
Member

Pushed PR: #7995

  • master
    • 3b106f1 - krb5: offline with SSS_AUTHTOK_TYPE_PAM_STACKED
    • 297ecc4 - authtok: add IS_PW_OR_ST_AUTHTOK()
  • sssd-2-11
    • 856d20a - krb5: offline with SSS_AUTHTOK_TYPE_PAM_STACKED
    • 706a673 - authtok: add IS_PW_OR_ST_AUTHTOK()
  • sssd-2-9
    • 6d3e615 - krb5: offline with SSS_AUTHTOK_TYPE_PAM_STACKED
    • be42436 - authtok: add IS_PW_OR_ST_AUTHTOK()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cache_credentials = true not working in sssd master

6 participants