unix_chkpwd fails with Percona pam plugin
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
percona-pam-for-mysql |
New
|
Undecided
|
Unassigned |
Bug Description
Using pam_unix with PAM plugin shouldn't require root privileges
since pam_unix can use unix_chkpwd, a setuid helper.
unix_chkpwd is also used by other non-root utilities like xlock.
The helper is used only if geteuid returns non-zero, otherwise it
can read shadow file directly with getspnam etc.
http://
pam_unix in auth setting, some of them run as non-root.
=================
Dec 05 15:51:58 Archie mysqld[11366]: pam_warn(
Dec 05 15:51:58 Archie unix_chkpwd[11417]: salt null
Dec 05 15:51:58 Archie unix_chkpwd[11417]: check pass; user unknown
Dec 05 15:51:58 Archie unix_chkpwd[11417]: password check failed for user (raghavendra)
Dec 05 15:51:58 Archie mysqld[11366]: pam_unix(
================
The "salt null" was a message I added to the PAM library for
diagnostic purposes.
Now, the salt is null because get_pwd_hash used by
helper_
PAM_AUTHINFO_
However, this has nothing to do with salting itself.
This seems to be happening because the uid/euid used for PAM
should match the PAM_USER's uid.
ec 05 18:42:45 Archie mysqld[5203]: pam_warn(
Dec 05 18:42:45 Archie unix_chkpwd[5523]: name testit
Dec 05 18:42:45 Archie unix_chkpwd[5523]: retval 9
Dec 05 18:42:45 Archie unix_chkpwd[5523]: salt null
Dec 05 18:42:45 Archie unix_chkpwd[5523]: check pass; user unknown
Dec 05 18:42:45 Archie unix_chkpwd[5523]: password check failed for user (testit)
Dec 05 18:42:45 Archie mysqld[5203]: pam_unix(
Dec 05 18:42:57 Archie logger[5555]: ACPI group/action undefined: processor / LNXCPU:00
Dec 05 18:43:12 Archie mysqld[5203]: pam_warn(
Dec 05 18:43:12 Archie unix_chkpwd[5568]: name mysql
Dec 05 18:43:12 Archie unix_chkpwd[5568]: retval 0
In the above example, testit and mysql are two users, in case of
testit it fails (name, retval, salt are diagnostics added by me).
However, it succeeds in case of mysql user (which mysqld also
runs as), why? because the uid/euid=89 matches the uid of the
user itself (added as -- create user 'mysql'@'localhost' IDENTIFIED WITH auth_pam; ).
So, the workaround, till it is fixed, is to use mysql system user itself as part of pam plugin authentication.
https:/ /gist.github. com/b137adf6105 afc0ba83c is where the PAM authentication fails.
Since, salt is NULL,
======== log_err( LOG_WARNING, "check pass; user unknown");
helper_
retval = PAM_USER_UNKNOWN;
============
and
======= ======= ======= ======= =
retval = helper_ verify_ password( user, pass, nullok);
memset(pass, '\0', MAXPASS); /* clear memory of the password */
/* return pass or fail */
if (retval != PAM_SUCCESS) { log(AUDIT_ USER_AUTH, user, PAM_AUTH_ERR); log_err( LOG_NOTICE, "password check failed for user (%s)", user); log(AUDIT_ USER_AUTH, user, PAM_SUCCESS);
if (!nullok || !blankpass) {
/* no need to log blank pass test */
#ifdef HAVE_LIBAUDIT
if (getuid() != 0)
_audit_
#endif
helper_
}
return PAM_AUTH_ERR;
} else {
if (getuid() != 0) {
#ifdef HAVE_LIBAUDIT
return _audit_
#else
return PAM_SUCCESS;
#endif
}
return PAM_SUCCESS;
}
======= ======= ======= ======= ======= ====
hence, the message "password check failed for user ..." printed