Skip to content

Commit 9226cfe

Browse files
committed
Bug #12818542: PAM: ADDING PASSWORD FOR AN ACCOUNT DISABLES
PAM AUTHENTICATION SETTINGS SET PASSWORD code on a account with plugin authentication was errorneously resetting the in-memory plugin pointer for the user back to native password plugin despite the fact that it was sending a warning that the command has no immediate effect. Fixed by not updating the user's plugin if it's already set to a non default value. Note that the bug affected only the in-memory cache of the user definitions. Any restart of the server will fix the problem. Also the salt and the password has are still stored into the user tables (just as it's documented now). Test case added. One old test case result updated to have the correct value.
1 parent c7ac498 commit 9226cfe

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

mysql-test/r/plugin_auth.result

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ERROR 28000: Access denied for user 'plug'@'localhost' (using password: YES)
4444
## test correct default plugin
4545
select USER(),CURRENT_USER();
4646
USER() CURRENT_USER()
47-
plug@localhost plug@%
47+
plug@localhost plug_dest@%
4848
## test no_auto_create_user sql mode with plugin users
4949
SET @@sql_mode=no_auto_create_user;
5050
GRANT INSERT ON TEST.* TO grant_user IDENTIFIED WITH 'test_plugin_server';
@@ -462,4 +462,24 @@ CREATE USER bug12610784@localhost;
462462
SET PASSWORD FOR bug12610784@localhost = PASSWORD('secret');
463463
ERROR 28000: Access denied for user 'bug12610784'@'localhost' (using password: NO)
464464
DROP USER bug12610784@localhost;
465+
#
466+
# Bug #12818542: PAM: ADDING PASSWORD FOR AN ACCOUNT DISABLES PAM
467+
# AUTHENTICATION SETTINGS
468+
#
469+
CREATE USER bug12818542@localhost
470+
IDENTIFIED WITH 'test_plugin_server' AS 'bug12818542_dest';
471+
CREATE USER bug12818542_dest@localhost
472+
IDENTIFIED BY 'bug12818542_dest_passwd';
473+
GRANT PROXY ON bug12818542_dest@localhost TO bug12818542@localhost;
474+
SELECT USER(),CURRENT_USER();
475+
USER() CURRENT_USER()
476+
bug12818542@localhost bug12818542_dest@localhost
477+
SET PASSWORD = PASSWORD('bruhaha');
478+
Warnings:
479+
Note 1699 SET PASSWORD has no significance for users authenticating via plugins
480+
SELECT USER(),CURRENT_USER();
481+
USER() CURRENT_USER()
482+
bug12818542@localhost bug12818542_dest@localhost
483+
DROP USER bug12818542@localhost;
484+
DROP USER bug12818542_dest@localhost;
465485
End of 5.5 tests

mysql-test/t/plugin_auth.test

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,4 +540,35 @@ connection default;
540540
disconnect b12610784;
541541
DROP USER bug12610784@localhost;
542542

543+
544+
--echo #
545+
--echo # Bug #12818542: PAM: ADDING PASSWORD FOR AN ACCOUNT DISABLES PAM
546+
--echo # AUTHENTICATION SETTINGS
547+
--echo #
548+
549+
CREATE USER bug12818542@localhost
550+
IDENTIFIED WITH 'test_plugin_server' AS 'bug12818542_dest';
551+
CREATE USER bug12818542_dest@localhost
552+
IDENTIFIED BY 'bug12818542_dest_passwd';
553+
GRANT PROXY ON bug12818542_dest@localhost TO bug12818542@localhost;
554+
555+
connect(bug12818542_con,localhost,bug12818542,bug12818542_dest);
556+
connection bug12818542_con;
557+
SELECT USER(),CURRENT_USER();
558+
559+
SET PASSWORD = PASSWORD('bruhaha');
560+
561+
connection default;
562+
disconnect bug12818542_con;
563+
564+
connect(bug12818542_con2,localhost,bug12818542,bug12818542_dest);
565+
connection bug12818542_con2;
566+
SELECT USER(),CURRENT_USER();
567+
568+
connection default;
569+
disconnect bug12818542_con2;
570+
571+
DROP USER bug12818542@localhost;
572+
DROP USER bug12818542_dest@localhost;
573+
543574
--echo End of 5.5 tests

sql/sql_acl.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,17 +1881,17 @@ bool change_password(THD *thd, const char *host, const char *user,
18811881
goto end;
18821882
}
18831883

1884+
/* update loaded acl entry: */
1885+
set_user_salt(acl_user, new_password, new_password_len);
1886+
18841887
if (my_strcasecmp(system_charset_info, acl_user->plugin.str,
18851888
native_password_plugin_name.str) &&
18861889
my_strcasecmp(system_charset_info, acl_user->plugin.str,
18871890
old_password_plugin_name.str))
1888-
{
18891891
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
18901892
ER_SET_PASSWORD_AUTH_PLUGIN, ER(ER_SET_PASSWORD_AUTH_PLUGIN));
1891-
}
1892-
/* update loaded acl entry: */
1893-
set_user_salt(acl_user, new_password, new_password_len);
1894-
set_user_plugin(acl_user, new_password_len);
1893+
else
1894+
set_user_plugin(acl_user, new_password_len);
18951895

18961896
if (update_user_table(thd, table,
18971897
acl_user->host.hostname ? acl_user->host.hostname : "",

0 commit comments

Comments
 (0)