The authentication process used by MariaDB's PAM authentication plugin goes like this:
- First, it calls pam_authenticate. This step causes the server to authenticate the user account by evaluating all auth module types in the provided PAM service configuration.
https://github.com/MariaDB/server/blob/54caaf684801c332a7130d478023aa7706a69aa1/plugin/auth_pam/auth_pam.c#L154
https://linux.die.net/man/3/pam_authenticate
- Second, it calls pam_acct_mgmt. This step causes the server to verify the user account by evaluating all *account* module types in the provided PAM service configuration.
https://github.com/MariaDB/server/blob/54caaf684801c332a7130d478023aa7706a69aa1/plugin/auth_pam/auth_pam.c#L157
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://github.com/MariaDB/server/blob/2ad51a0bd8380fba3d03a4cebd43860329b7fbaa/plugin/auth_pam/mapper/pam_user_map.c#L135
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:
#%PAM-1.0
|
auth required pam_sss.so
|
account sufficient pam_unix.so
|
account sufficient pam_sss.so
|
auth required pam_user_map.so debug
|
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:
Sep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): Opening file '/etc/security/user_map.conf'.
|
Sep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): Incoming username 'alice'.
|
Sep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): User belongs to 4 groups [dba,mongod,mongodba,mysql].
|
Sep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): Check if user is in group 'mysql': YES
|
Sep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): User mapped as 'dba'
|
Sep 27 17:17:05 dbserver1 mysqld: pam_unix(mysql:account): could not identify user (from getpwnam(dba))
|
Sep 27 17:17:05 dbserver1 mysqld: pam_sss(mysql:account): Access denied for user dba: 10 (User not known to the underlying authentication module)
|
Sep 27 17:17:05 dbserver1 mysqld: 2018-09-27 17:17:05 72 [Warning] Access denied for user 'alice'@'localhost' (using password: NO)
|
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://github.com/MariaDB/server/blob/2ad51a0bd8380fba3d03a4cebd43860329b7fbaa/plugin/auth_pam/mapper/pam_user_map.c#L220
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.
- is duplicated by
-
MDEV-14124
pam_user_map plugin doesn't work on RH7
-
-
Closed
{"report":{"fcp":1870.5,"ttfb":620.8000001907349,"pageVisibility":"visible","entityId":69997,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"336feb6e-7d58-4c1c-b531-c800272300e2","navigationType":0,"readyForUser":1962.9000000953674,"redirectCount":0,"resourceLoadedEnd":1554,"resourceLoadedStart":632.8000001907349,"resourceTiming":[{"duration":73.80000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":632.8000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":632.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":706.6000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":102.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":633.1000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":633.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":735.2000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":592.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":633.2000002861023,"connectEnd":633.2000002861023,"connectStart":633.2000002861023,"domainLookupEnd":633.2000002861023,"domainLookupStart":633.2000002861023,"fetchStart":633.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":800.9000000953674,"responseEnd":1225.3000001907349,"responseStart":859,"secureConnectionStart":633.2000002861023},{"duration":920.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":633.5,"connectEnd":633.5,"connectStart":633.5,"domainLookupEnd":633.5,"domainLookupStart":633.5,"fetchStart":633.5,"redirectEnd":0,"redirectStart":0,"requestStart":800.8000001907349,"responseEnd":1554,"responseStart":854.5,"secureConnectionStart":633.5},{"duration":233.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":633.7000002861023,"connectEnd":633.7000002861023,"connectStart":633.7000002861023,"domainLookupEnd":633.7000002861023,"domainLookupStart":633.7000002861023,"fetchStart":633.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":801.1000003814697,"responseEnd":867.3000001907349,"responseStart":859.8000001907349,"secureConnectionStart":633.7000002861023},{"duration":233.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":634.2000002861023,"connectEnd":634.2000002861023,"connectStart":634.2000002861023,"domainLookupEnd":634.2000002861023,"domainLookupStart":634.2000002861023,"fetchStart":634.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":802.1000003814697,"responseEnd":867.8000001907349,"responseStart":861.1000003814697,"secureConnectionStart":634.2000002861023},{"duration":233.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":634.4000000953674,"connectEnd":634.4000000953674,"connectStart":634.4000000953674,"domainLookupEnd":634.4000000953674,"domainLookupStart":634.4000000953674,"fetchStart":634.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":801.2000002861023,"responseEnd":867.5,"responseStart":860.4000000953674,"secureConnectionStart":634.4000000953674},{"duration":101.7999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":634.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":634.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":736.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":238,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":634.7000002861023,"connectEnd":634.7000002861023,"connectStart":634.7000002861023,"domainLookupEnd":634.7000002861023,"domainLookupStart":634.7000002861023,"fetchStart":634.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":803.8000001907349,"responseEnd":872.7000002861023,"responseStart":862,"secureConnectionStart":634.7000002861023},{"duration":135.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":634.9000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":634.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":770.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":238.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":635.2000002861023,"connectEnd":635.2000002861023,"connectStart":635.2000002861023,"domainLookupEnd":635.2000002861023,"domainLookupStart":635.2000002861023,"fetchStart":635.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":803.9000000953674,"responseEnd":874.1000003814697,"responseStart":870,"secureConnectionStart":635.2000002861023},{"duration":811.6999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":647.1000003814697,"connectEnd":647.1000003814697,"connectStart":647.1000003814697,"domainLookupEnd":647.1000003814697,"domainLookupStart":647.1000003814697,"fetchStart":647.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":905.4000000953674,"responseEnd":1458.8000001907349,"responseStart":1424,"secureConnectionStart":647.1000003814697},{"duration":811.7999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":647.2000002861023,"connectEnd":647.2000002861023,"connectStart":647.2000002861023,"domainLookupEnd":647.2000002861023,"domainLookupStart":647.2000002861023,"fetchStart":647.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":905.7000002861023,"responseEnd":1459,"responseStart":1439.8000001907349,"secureConnectionStart":647.2000002861023},{"duration":396,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1365.1000003814697,"connectEnd":1365.1000003814697,"connectStart":1365.1000003814697,"domainLookupEnd":1365.1000003814697,"domainLookupStart":1365.1000003814697,"fetchStart":1365.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":1722.4000000953674,"responseEnd":1761.1000003814697,"responseStart":1759.4000000953674,"secureConnectionStart":1365.1000003814697}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":426,"responseStart":620,"responseEnd":640,"domLoading":630,"domInteractive":2037,"domContentLoadedEventStart":2037,"domContentLoadedEventEnd":2092,"domComplete":3143,"loadEventStart":3143,"loadEventEnd":3143,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2014.8000001907349},{"name":"bigPipe.sidebar-id.end","time":2015.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":2015.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":2017.2000002861023},{"name":"activityTabFullyLoaded","time":2106.9000000953674}],"measures":[],"correlationId":"13d0218d5109e2","effectiveType":"4g","downlink":9.2,"rtt":0,"serverDuration":96,"dbReadsTimeInMs":11,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
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
account required pam_permit.so
should be enough