[MDEV-21767] If default_password_lifetime > 0, then password_lifetime is not set for newly set passwords Created: 2020-02-19 Updated: 2020-02-19 Resolved: 2020-02-19 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Authentication and Privilege System |
| Affects Version/s: | 10.4.12 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
The description of the default_password_lifetime system variable says the following:
I would interpret this as meaning: if this system variable's value is non-zero, then password expiration will be enabled by default. However, as far as I can tell, password expiration is never enabled by default. The value provided by the default_password_lifetime system variable only seems to apply if the PASSWORD EXPIRE DEFAULT clause is provided to the CREATE USER or ALTER USER statements. We can test this by creating some users, and then querying mysql.global_priv, and then looking at the value of the password_lifetime attribute. For example, if the PASSWORD EXPIRE DEFAULT clause is provided to the CREATE USER or ALTER USER statement, then the password_lifetime attribute is set, so password expiration is definitely enabled for this user account:
But if no PASSWORD EXPIRE ... clause is provided to the CREATE USER or ALTER USER statement, then the password_lifetime attribute is not set, so it seems that password expiration is not enabled for this user account:
According to the source code, if the password_lifetime attribute is not set for a given user account, then password expiration is not enabled:
https://github.com/MariaDB/server/blob/mariadb-10.4.12/sql/sql_acl.cc#L13610 I would think that if the user sets default_password_lifetime to a non-zero value, then they probably want password expiration to be enabled by default. If so, then I think the password_lifetime attribute should be set to -1 if default_password_lifetime is set to a non-zero value and no PASSWORD EXPIRE ... clause is provided. Is this a bug, or is it working as intended? |
| Comments |
| Comment by Geoff Montee (Inactive) [ 2020-02-19 ] | |||||||||||||
|
It looks like this might actually be working as intended, and the server code handles the default case in the User_table_json:::get_password_lifetime() method. In that method, if the password_lifetime field isn't set, then it seems to return -1:
https://github.com/MariaDB/server/blob/mariadb-10.4.12/sql/sql_acl.cc#L1545 And -1 is the value that tells the server to use the default_password_lifetime value. | |||||||||||||
| Comment by Geoff Montee (Inactive) [ 2020-02-19 ] | |||||||||||||
|
I performed a more thorough test of this. First, I created a user account:
And then I manually altered the privilege table to make its password 10 days old, and I flushed the privileges:
And then I manually set default_password_lifetime to 5 days:
And then I tried logging in as the account:
And then I tried querying a table:
I did see the following error at this point:
So it does appear that a non-existent password_lifetime attribute is treated the same as -1, and everything seems to be working as intended. |