[MDEV-17315] When using group mapping from pam_user_map module, a system user account with the mapped name needs to exist Created: 2018-09-27 Updated: 2020-03-27 Resolved: 2018-10-03 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Authentication and Privilege System, Plugin - pam |
| Affects Version/s: | 10.2.18 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | need_feedback, pam, pam_user_map | ||
| Issue Links: |
|
||||||||
| Description |
|
The authentication process used by MariaDB's PAM authentication plugin goes like this:
https://linux.die.net/man/3/pam_authenticate
https://linux.die.net/man/3/pam_acct_mgmt This process is complicated somewhat when the pam_user_map module is included in the PAM service configuration. The pam_user_map module calls pam_sm_authenticate, which means that it is a auth module type, and it is evaluated when the plugin calls pam_authenticate. https://linux.die.net/man/3/pam_sm_authenticate When group mapping is used along with pam_user_map, this means that the user being verified during the pam_acct_mgmt step is not the original user. If a user account with the same name does not exist, this can cause problems. To give a concrete example, let's say that you have the following PAM service configuration:
And /etc/security/user_map.conf looks like this:
If no system user called "dba" exists, then authentication will fail during the pam_acct_mgmt step, and the syslog will have messages like this:
This can be solved by simply adding a system user with the same name as the group being mapped:
But I wonder whether this limitation can be lifted, and if so, whether we would want to lift it. One possible solution would be to implement pam_sm_acct_mgmt for pam_user_map, so that group mapping could optionally happen as a account module type, rather than an auth module type, and it would be evaluated when the plugin called pam_acct_mgmt. https://linux.die.net/man/3/pam_sm_acct_mgmt I see that the user is actually changed with pam_set_item, and it looks like that can be called from any module type. https://linux.die.net/man/3/pam_set_item However, I don't know enough about PAM to know for sure that this would make the problem go away. |
| Comments |
| Comment by Sergei Golubchik [ 2018-10-01 ] | |
|
Authenticating for MariaDB isn't really a "logging into account" so, unlike login or ssh pam policies, mariadb pam file doesn't need these account lines. Using just
should be enough | |
| Comment by Geoff Montee (Inactive) [ 2018-10-01 ] | |
|
OK, good to know. I tried with no "account" lines, but that caused authentication to fail. I'll keep that pam_permit trick in mind. | |
| Comment by Elena Stepanova [ 2018-10-03 ] | |
|
GeoffMontee, |