login: Clean up PAM resource handling#1599
Open
stoeckmann wants to merge 3 commits intoshadow-maint:masterfrom
Open
login: Clean up PAM resource handling#1599stoeckmann wants to merge 3 commits intoshadow-maint:masterfrom
stoeckmann wants to merge 3 commits intoshadow-maint:masterfrom
Conversation
According to Linux-PAM's pam_setcred manual page and shadow's su implementation, credentials shall be set before session is opened. Adjust login to follow this rule, which is also applied by util-linux login/su and at least gdm (didn't check more implementations). Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
If authentication fails, call pam_end without pam_close_session, since at this point, pam_open_session was never called. Only two callers of PAM_END benefit from the macro, which is not worth it. Inlined PAM_END instead. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Call pam_setcreds if pam_open_session fails. This deletes credentials which are allocated with a previous pam_setcreds call. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pam_setcred(3)manual page. It also violates su's cred/session order. Other examples of cred/session tools: util-linux login and su, and gdmpam_close_sessionifpam_open_sessionwas never calledpam_open_sessionfailsSee pam_setcred(3):
https://github.com/linux-pam/linux-pam/blob/cf2fc5ff7b4a8555fda2a5ebe5f6ab0e45c22996/doc/man/pam_setcred.3.xml#L33-L43