New feature: Set PAM service name in sshd_config file #122
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.


This allows different pam auth configurations based on
used AuthenticationMethod and Match directives.
See https://pastebin.com/SuCG6dft for the problem this solves.
There are 2 new config directives:
From Manpage:
Both new config options are allowed within Match directives, which allows very sophisticated setup, where different hosts can undergo completely different authentication paradigms.
If neither of the new options is set (or set to none) the behavior is as it used to, setting the pam service either to the program name or to the fixed override given with
./configure --with-pam-service=name
Implementation:
Instead of hardcoding the service name to SSHD_PAM_SERVICE, the pam handle is now initiated with a dynamic service name. Since this can change unexpectedly when used in Match directives, pam is now reinitialized every time pam_init() is called, even if the user is identical.
sshpam_auth_passwd() which implements PAM based PasswordAuthentication now uses its own separate PAM handle used for authentication only (the regular one is used for account and session management)
I'm looking forward to your feedback.