[MDEV-25169] Secure installation with normal user fails to accept empty root password Created: 2021-03-16 Updated: 2021-04-13 Resolved: 2021-04-06 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Configuration, Server |
| Affects Version/s: | 10.5.9 |
| Fix Version/s: | 10.4.18 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Andrew Groot | Assignee: | Anel Husakovic |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | installation | ||
| Environment: |
macOS, Linux |
||
| Issue Links: |
|
||||||||
| Description |
|
When installing MariaDB as a normal user, mysql_secure_installation fails when attempting to authenticate the root user (with an empty password). This can be worked around by updating the make_config function to avoid writing the user and password lines if the provided root password is empty, as in the following alternate implementation (first if-statement added):
I'm not sure if this is the proper fix, but hopefully it at least highlights where the conflict is happening. |
| Comments |
| Comment by Anel Husakovic [ 2021-04-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
serg can you please review .
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-04-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Eh... The bug report was that
anel, you "fix" the issue where mysql_secure_installation fails to set an empty root password. This is a very different thing. And that behavior is quite intentional, as you could see, mysql_secure_installation indeed is supposed to reject attempts to set an empty root password, that's what "secure" in the name of the script means. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-04-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Well, I couldn't reproduce the bug.
works with empty password for root and I guess the reason is here. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Groot [ 2021-04-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I ran the following commands to install/run MariaDB into a directory (./data/) alongside the MariaDB files (./base/):
While MariaDB is running, I separately ran the following command to perform the secure installation:
I get the following:
With the code changes referenced in the issue, I get the following:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-04-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Basically the same procedure. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Groot [ 2021-04-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Here is the output I get (I substituted my personal username and computer name for <user> and <host>):
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-04-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi groot-verde, so looking from your example mysql.user table your root user doesn't have password, it is invalid.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Groot [ 2021-04-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Anel, I can appreciate that maybe what I'm trying to do isn't currently possible (or if I just described it poorly) but I'd be a bit surprised if it's considered unsupported. Immediately following installation, what is the expectation for the state of the root user's password? My impression was always that it was empty and that the password was then set with mysql_secure_installation (though I honestly prefer the idea that root's password is invalid). In the example you gave, if I understand correctly, the configuration file specifies an empty root password and that allows you to continue with mysql_secure_installation, but that scripts tells you "If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here." This is the case I have, so it seems like either this message is misleading or there's an issue with the implementation. I'm further pushed to this perspective by the fake that I'm able to continue by tweaking the make_config function to not provide the username and password. It would seem that the server is fine with proceeding in that scenario given that root has an invalid password. If that's not intended then I would imagine that is also a bug somewhere. Even if I can avoid the issue by providing a simple configuration prior to running mysql_secure_installation that makes the root password empty, that step seems unnecessary and honestly somewhat contrary to what I'm trying to do (i.e. secure the database). I would prefer to transition it directly from a freshly installed state to a secure state without having to temporarily having an empty root password. Let me know if I'm misunderstanding something, though. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-04-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Andrew,
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Groot [ 2021-04-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks this is helpful. It still leaves me with the question though of why the step of setting the root password before running mysql_secure_installation is necessary. In effect, the change to the make_config function effectively allows for the mysql_secure_installation to do this step for us. As mentioned in the blog post:
So, if mysql_secure_installation is being run by that user, why not allow the script to take advantage of their root-like access instead of forcing them to attempt to authenticate as root? Maybe an additional question or two would help make the path through mysql_secure_installation more straightforward (i.e. to differentiate between an empty password and an installation user wants to set up the database), and so maybe this is more of a feature request, but it still feels like mysql_secure_installation is, at least in part, designed to help address this kind of use-case. My impression is just that this mode of installer-authentication was added but not translated to the mysql_secure_installation script. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-04-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes, I believe your impression is exactly correct. And mysql_secure_installation could, indeed, be extended to recognize when it's run as $USER that owns all the data files and use that somehow. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Groot [ 2021-04-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
In that case, what's the appropriate course of action from here? Should this issue be re-opened? Let me know if there's anything else I can I do to help this be addressed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Groot [ 2021-04-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei/Anel, can either of you provide some guidance on what the next steps are from here? Are you willing to re-open the issue in light of Sergei's last comment? If not, let me know what other next steps are most appropriate. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-04-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi groot-verde, I'm working on the patch for MDEV-22486 which will address also your concerns. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Groot [ 2021-04-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sounds good, thank you! |