Skip to content

Commit 56ed3de

Browse files
Bug#21192879 : FAILED SET PASSWORD STILL HAS CONSEQUENCES
Description : In cases when SET PASSWORD fails with ER_MUST_CHANGE_PASSWORD, pasword_last_changed column is updated. Solution : Before changing any data in underlying system table, make sure that if user is trying to change someone else's password, user's own password is not expired. Reviewed-By : Bharthy Satish <bharathy.x.satish@oracle.com> Reviewed-By : Robert Golebiowski <robert.golebiowski@oracle.com>
1 parent 3e14f9f commit 56ed3de

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sql/auth/sql_user.cc

+10-2
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,24 @@ enum enum_acl_lists
197197
int check_change_password(THD *thd, const char *host, const char *user,
198198
const char *new_password, size_t new_password_len)
199199
{
200+
Security_context *sctx;
200201
if (!initialized)
201202
{
202203
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables");
203204
return(1);
204205
}
206+
207+
sctx= thd->security_context();
205208
if (!thd->slave_thread &&
206-
(strcmp(thd->security_context()->user().str, user) ||
209+
(strcmp(sctx->user().str, user) ||
207210
my_strcasecmp(system_charset_info, host,
208-
thd->security_context()->priv_host().str)))
211+
sctx->priv_host().str)))
209212
{
213+
if (sctx->password_expired())
214+
{
215+
my_error(ER_MUST_CHANGE_PASSWORD, MYF(0));
216+
return(1);
217+
}
210218
if (check_access(thd, UPDATE_ACL, "mysql", NULL, NULL, 1, 0))
211219
return(1);
212220
}

0 commit comments

Comments
 (0)