Hi Michal,
Yes, I'm using version 2 of the PAM plugin.
MariaDB [(none)]> show plugins soname like '%pam%';
+------+---------------+----------------+----------------+---------+
| Name | Status | Type | Library | License |
+------+---------------+----------------+----------------+---------+
| pam | ACTIVE | AUTHENTICATION | auth_pam.so | GPL |
| pam | NOT INSTALLED | AUTHENTICATION | auth_pam_v1.so | GPL |
+------+---------------+----------------+----------------+---------+
Concerning (3), I was able to use /etc/pam.d/mariadb this morning instead of /etc/pam.d/mysql. The only modifications that I've made that I see currently are what you noted in point (4) to only using CREATE USER since SQL_MODE has NO_AUTO_CREATE_USER.
MariaDB [(none)]> SELECT @@SQL_MODE, @@GLOBAL.SQL_MODE;
+-------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------+
| @@SQL_MODE | @@GLOBAL.SQL_MODE |
+-------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------+
I've updated the user creation to only use (4):
CREATE USER 'user'@'%' IDENTIFIED VIA pam USING 'mariadb';
Unix auth appears to work the same as your configuration now using pam_unix in /etc/pam.d/mariadb. However, AD is not working when I change /etc/pam.d/mariadb to:
auth optional pam_exec.so log=/t/pam_output.txt /t/pam_log_script.sh
auth required pam_sss.so
account optional pam_exec.so log=/t/pam_output.txt /t/pam_log_script.sh
account required pam_sss.so
MariaDB [(none)]> DROP USER adadmin;
Query OK, 0 rows affected (0.037 sec)
MariaDB [(none)]> CREATE USER 'adadmin'@'%' IDENTIFIED VIA pam USING 'mariadb';
Query OK, 0 rows affected (0.024 sec)
# tail -f /t/pam_output.txt
*** Tue Aug 3 08:56:05 2021
PAM_TYPE=auth PAM_USER=adadmin PWD=/var/lib/mysql SHLVL=1 PAM_SERVICE=mariadb _=/usr/bin/env
*** Tue Aug 3 08:56:06 2021
PAM_TYPE=account PAM_USER=adadmin PWD=/var/lib/mysql KRB5CCNAME=FILE:/tmp/krb5cc_1767884463_WAaH4K SHLVL=1 PAM_SERVICE=mariadb _=/usr/bin/env
# tail -f /var/log/secure
Aug 3 08:56:06 cs-dbserv auth_pam_tool[76893]: pam_sss(mariadb:auth): authentication success; logname= uid=0 euid=0 tty= ruser= rhost= user=adadmin
Aug 3 08:56:06 cs-dbserv auth_pam_tool[76893]: pam_sss(mariadb:account): Access denied for user adadmin: 6 (Permission denied)
# tail -f /var/log/messages
Aug 3 08:58:42 mariadb sssd[76951]: Outgoing update query:
Aug 3 08:58:42 mariadb sssd[76951]: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23217
Aug 3 08:58:42 mariadb sssd[76951]: ;; flags:; QUESTION: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
Aug 3 08:58:42 mariadb sssd[76951]: ;; QUESTION SECTION:
Aug 3 08:58:42 mariadb sssd[76951]: ;
2530806950.server.domain.college.edu. ANY#011TKEY
Aug 3 08:58:42 mariadb sssd[76951]: ;; ADDITIONAL SECTION:
Aug 3 08:58:42 mariadb sssd[76951]:
2530806950.server.domain.college.edu. 0 ANY TKEY#011gss-tsig. 1627999122 1627999122 3 NOERROR 1326 YIIFKg[shortened] 0
Aug 3 08:58:42 mariadb sssd[76951]: Outgoing update query:
Aug 3 08:58:42 mariadb sssd[76951]: ;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id: 35535
Aug 3 08:58:42 mariadb sssd[76951]: ;; flags:; ZONE: 1, PREREQ: 0, UPDATE: 2, ADDITIONAL: 1
Aug 3 08:58:42 mariadb sssd[76951]: ;; UPDATE SECTION:
Aug 3 08:58:42 mariadb sssd[76951]: mariadb.domain.college.edu.#0110#011ANY#011A
Aug 3 08:58:42 mariadb sssd[76951]: mariadb.domain.college.edu.#01160#011IN#011A#011131.230.133.11
Aug 3 08:58:42 mariadb sssd[76951]: ;; TSIG PSEUDOSECTION:
Aug 3 08:58:42 mariadb sssd[76951]:
2530806950.server.domain.college.edu. 0 ANY TSIG#011gss-tsig. 1627999122 300 28 BAQE[shortened]== 35535 NOERROR 0
Aug 3 08:58:42 mariadb sssd[76951]: Outgoing update query:
Aug 3 08:58:42 mariadb sssd[76951]: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53259
Aug 3 08:58:42 mariadb sssd[76951]: ;; flags:; QUESTION: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
Aug 3 08:58:42 mariadb sssd[76951]: ;; QUESTION SECTION:
Aug 3 08:58:42 mariadb sssd[76951]: ;
417880633.server.domain.college.edu. ANY#011TKEY
Aug 3 08:58:42 mariadb sssd[76951]: ;; ADDITIONAL SECTION:
Aug 3 08:58:42 mariadb sssd[76951]:
417880633.server.domain.college.edu. 0 ANY#011TKEY#011gss-tsig. 1627999122 1627999122 3 NOERROR 1326 YIIFKg[shortened] 0
Aug 3 08:58:42 mariadb sssd[76951]: Outgoing update query:
Aug 3 08:58:42 mariadb sssd[76951]: ;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id: 49877
Aug 3 08:58:42 mariadb sssd[76951]: ;; flags:; ZONE: 1, PREREQ: 0, UPDATE: 1, ADDITIONAL: 1
Aug 3 08:58:42 mariadb sssd[76951]: ;; UPDATE SECTION:
Aug 3 08:58:42 mariadb sssd[76951]: mariadb.domain.college.edu.#0110#011ANY#011AAAA
Aug 3 08:58:42 mariadb sssd[76951]: ;; TSIG PSEUDOSECTION:
Aug 3 08:58:42 mariadb sssd[76951]:
417880633.server.domain.college.edu. 0 ANY#011TSIG#011gss-tsig. 1627999122 300 28 BAQE[shortened]== 49877 NOERROR 0
Also, I noticed when doing the following command pam_acct_mgmt is showing Permission denied:
# sssctl user-checks -s mariadb adadmin
user: adadmin
action: acct
service: mariadb
SSSD nss user lookup result:
- user name:
adadmin@domain.college.edu - user id: 1767884463
- group id: 1767800513
- gecos: Admin CS - adadmin
- home directory: /home/adadmin
- shell: /bin/bash
SSSD InfoPipe user lookup result:
- name: adadmin
- uidNumber: 17xxxxxxxxx
- gidNumber: 17xxxxxxxxx
- gecos: Admin CS - adadmin
- homeDirectory: not set
- loginShell: not set
testing pam_acct_mgmt
pam_acct_mgmt: Permission denied
PAM Environment:
- no env -
This is also showing up in /var/log/secure:
Aug 3 09:03:05 mariadb sssctl[77040]: pam_sss(mariadb:account): Access denied for user adadmin: 6 (Permission denied)