Skip to content

Commit da052cc

Browse files
author
Arun Kuruvila
committed
Bug#23291841: PASSWORD NOT EXPIRING WHEN IT SHOULD
Description:- User password is not expiring even after exceeding the "password_lifetime" limit. Analysis:- Password is not expiring because of the attribute "use_default_password_lifetime" which is set inside "acl_update_user()". This is making the user's account accessible even after the password exceeds the password lifetime. Fix:- The function, "change_password()" is modified to set "update_password_expired_fields" field to false. A check is introduced inside "acl_update_user()" before updating the password expired fields.
1 parent 52a0038 commit da052cc

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

mysql-test/r/grant_user_lock_qa.result

+2-2
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ account_locked N
430430

431431
SHOW CREATE USER u6@localhost;
432432
CREATE USER for u6@localhost
433-
CREATE USER 'u6'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '<non-deterministic-password-hash>' REQUIRE X509 PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK
433+
CREATE USER 'u6'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '<non-deterministic-password-hash>' REQUIRE X509 PASSWORD EXPIRE NEVER ACCOUNT UNLOCK
434434
SELECT USER();
435435
USER()
436436
u6@localhost
@@ -548,7 +548,7 @@ account_locked N
548548

549549
SHOW CREATE USER u9@localhost;
550550
CREATE USER for u9@localhost
551-
CREATE USER 'u9'@'localhost' IDENTIFIED WITH 'sha256_password' AS '<non-deterministic-password-hash>' REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client' PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK
551+
CREATE USER 'u9'@'localhost' IDENTIFIED WITH 'sha256_password' AS '<non-deterministic-password-hash>' REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client' PASSWORD EXPIRE NEVER ACCOUNT UNLOCK
552552
SELECT USER();
553553
USER()
554554
u9@localhost

sql/auth/sql_auth_cache.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -2702,7 +2702,8 @@ void acl_update_user(const char *user, const char *host,
27022702
if (password_life.update_password_expired_column ||
27032703
what_is_set & PLUGIN_ATTR)
27042704
acl_user->password_expired= password_life.update_password_expired_column;
2705-
if (!password_life.update_password_expired_column)
2705+
if (!password_life.update_password_expired_column &&
2706+
password_life.update_password_expired_fields)
27062707
{
27072708
if (!password_life.use_default_password_lifetime)
27082709
{

sql/auth/sql_authentication.cc

+6
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,12 @@ check_password_lifetime(THD *thd, const ACL_USER *acl_user)
20292029
}
20302030
}
20312031
}
2032+
DBUG_EXECUTE_IF("force_password_interval_expire",
2033+
{
2034+
if (!acl_user->use_default_password_lifetime &&
2035+
acl_user->password_lifetime)
2036+
password_time_expired= true;
2037+
});
20322038
return password_time_expired;
20332039
}
20342040

sql/auth/sql_user.cc

+1
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ bool change_password(THD *thd, const char *host, const char *user,
708708
thd->lex->alter_password.expire_after_days= 0;
709709
thd->lex->alter_password.update_account_locked_column= false;
710710
thd->lex->alter_password.account_locked= false;
711+
thd->lex->alter_password.update_password_expired_fields= false;
711712

712713
/*
713714
When @@log-backward-compatible-user-definitions variable is ON

0 commit comments

Comments
 (0)