[MDEV-19878] pam v2: pam password authentication doesn't work at all Created: 2019-06-27 Updated: 2020-08-25 Resolved: 2019-07-02 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Authentication and Privilege System, Plugin - pam |
| Affects Version/s: | 10.4.6 |
| Fix Version/s: | 10.4.7 |
| Type: | Bug | Priority: | Major |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
In MariaDB 10.4, version 2 of the pam plugin is provided. Unfortunately, password authentication seems to be completely broken. To reproduce, simply do the following: Create a Unix user account and set a password for the user:
Create the PAM service configuration:
Then in MariaDB, install the plugin:
And then create the user account:
And then you might need to execute some commands to work around
And then, try to authenticate as the Unix account (while using the workaround for
I thought that this might be caused by The syslog shows the following:
And the strace output for the process running the auth_pam_tool utility shows the following:
And the strace output for the process running the client connection shows the following:
In the strace output for the client connection, it looks to me like the client is sending an empty password for some reason. This made me want to try testing how it worked if I provided the password on the command line. Even that fails:
And the strace output for that does show that the client connection received the proper password:
It just doesn't seem to be passing the proper password to the auth_pam_tool process. |
| Comments |
| Comment by Taylor Davis [ 2019-06-27 ] | |||||||||||||||||||||||||||||||||||||||
|
We ran into the same issue at Wiland while testing 10.4.6. We are using kerberos to authenticate off an AD server so my messaging in /var/log/secure is different, but I was able to replicate the problem when using the workaround for | |||||||||||||||||||||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2019-06-28 ] | |||||||||||||||||||||||||||||||||||||||
|
After some code inspection, I wonder if the problem is due to this block:
https://github.com/MariaDB/server/blob/mariadb-10.4.6/plugin/auth_pam/auth_pam.c#L160 This code seems to be checking for the data sent by auth_pam_tool here:
https://github.com/MariaDB/server/blob/mariadb-10.4.6/plugin/auth_pam/auth_pam_base.c#L111 This code seems to be saying that if PAM needs a password with a prompt, then the "message style" is 2. If you need a password without a prompt, then the "message style" is 4. In the Linux-PAM API, PAM_PROMPT_ECHO_OFF is 1 and PAM_PROMPT_ECHO_ON is 2, so MariaDB seems to be using non-standard values here: Anyway, the plugin itself is only asking for a password if (buf[0] >> 1) != 2). Since this is right-shifted one bit, this seems equivalent to buf[0] != 4). This means that the plugin will only ask the user for a password if PAM is saying that it needs a password without a prompt. We can see from the strace output that the client connection is receiving a message style "4" from auth_pam_tool with a prompt of "Password: ":
And since the plugin only asks for a password if the message style != 4, this would seem to explain why the plugin isn't asking the client for the password. It seems like the relevant block in the plugin code should actually be something like this:
| |||||||||||||||||||||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2019-07-09 ] | |||||||||||||||||||||||||||||||||||||||
|
I tested out the fix for this using tarbuildnum #27339 from hasky for RHEL 7: http://buildbot.askmonty.org/buildbot/builders/kvm-rpm-centos74-amd64/builds/8839 http://hasky.askmonty.org/archive/10.4/build-27339/kvm-rpm-centos74-amd64/rpms/ Password authentication with pam v2 still fails for me, even though the same password works just fine with pam v1 after For example, here's the user account:
Now let's say that I install pam v2:
And then I try to log in as my "alice" user account, but it fails:
So then I uninstall pam v2 and install pam v1:
And now the "alice" user account can login just fine:
For the pam v2 failure, the syslog only shows a generic "password check failed" error:
But you can see from the above output that I used the exact same password when using both pam v1 and pam v2, and the password check only failed with pam v2. This indicates that the password is not the problem. I do see that the systemd service file has the relevant capabilities that are required for pam v2:
| |||||||||||||||||||||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2019-07-09 ] | |||||||||||||||||||||||||||||||||||||||
|
The cause of the previous failures was |