Skip to content

Commit 886a865

Browse files
committed
Bug #22551523: ALTER USER IDENTIFIED WITH AUTH_PAM DISABLES USER ACCOUNT
ALTER USER <foo> IDENTIFIED WITH <bar> was always marking the password as expired regardless of whether the underlying plugin supports password expiration or not. Fixed by adding a check if the plugin does support that and not marking the password as expired in this case. Test case added.
1 parent 39feb38 commit 886a865

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Bug #22551523: ALTER USER IDENTIFIED WITH AUTH_PAM DISABLES USER ACCOUNT
3+
#
4+
CREATE USER b22551523@localhost;
5+
# Must be N
6+
SELECT password_expired from mysql.user where user='b22551523' and host = 'localhost';
7+
password_expired
8+
N
9+
ALTER USER b22551523@localhost IDENTIFIED with 'test_plugin_server';
10+
# Must still be N
11+
SELECT password_expired from mysql.user where user='b22551523' and host = 'localhost';
12+
password_expired
13+
N
14+
ALTER USER b22551523@localhost IDENTIFIED with 'mysql_native_password';
15+
# Must be Y
16+
SELECT password_expired from mysql.user where user='b22551523' and host = 'localhost';
17+
password_expired
18+
Y
19+
DROP USER b22551523@localhost;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$PLUGIN_AUTH_OPT
2+
$PLUGIN_AUTH_LOAD
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--source include/have_plugin_auth.inc
2+
--source include/not_embedded.inc
3+
4+
--echo #
5+
--echo # Bug #22551523: ALTER USER IDENTIFIED WITH AUTH_PAM DISABLES USER ACCOUNT
6+
--echo #
7+
8+
CREATE USER b22551523@localhost;
9+
--echo # Must be N
10+
SELECT password_expired from mysql.user where user='b22551523' and host = 'localhost';
11+
12+
ALTER USER b22551523@localhost IDENTIFIED with 'test_plugin_server';
13+
--echo # Must still be N
14+
SELECT password_expired from mysql.user where user='b22551523' and host = 'localhost';
15+
16+
ALTER USER b22551523@localhost IDENTIFIED with 'mysql_native_password';
17+
--echo # Must be Y
18+
SELECT password_expired from mysql.user where user='b22551523' and host = 'localhost';
19+
20+
DROP USER b22551523@localhost;

sql/auth/sql_user.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,13 @@ bool set_and_validate_user_attributes(THD *thd,
445445
}
446446
}
447447
/*
448-
if there is a plugin specified with no auth string, then set
449-
the account as expired.
448+
if there is a plugin specified with no auth string, and that
449+
plugin supports password expiration then set the account as expired.
450450
*/
451451
if (Str->uses_identified_with_clause &&
452452
!(Str->uses_identified_by_clause ||
453-
Str->uses_authentication_string_clause))
453+
Str->uses_authentication_string_clause) &&
454+
auth_plugin_supports_expiration(Str->plugin.str))
454455
{
455456
Str->alter_status.update_password_expired_column= true;
456457
what_to_set|= PASSWORD_EXPIRE_ATTR;
@@ -1746,6 +1747,9 @@ bool mysql_alter_user(THD *thd, List <LEX_USER> &list, bool if_exists)
17461747
continue;
17471748
}
17481749

1750+
if (user_from && user_from->plugin.str)
1751+
optimize_plugin_compare_by_pointer(&user_from->plugin);
1752+
17491753
/* copy password expire attributes to individual lex user */
17501754
user_from->alter_status= thd->lex->alter_password;
17511755

0 commit comments

Comments
 (0)