Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-19316: mysql_secure_installation offers to rename root user #1288

Closed
wants to merge 4 commits into from

Conversation

ManjotS
Copy link

@ManjotS ManjotS commented Apr 26, 2019

This PR fixes MDEV-19316

mysql_secure_installation should offer to rename root to another name (default to short hostname) before prompting for root password change.

@an3l an3l added this to the 10.4 milestone Apr 28, 2019
@an3l an3l changed the title mysql_secure_installation offers to rename root user (MDEV-19316) MDEV-19316: mysql_secure_installation offers to rename root user Apr 28, 2019
return 1
fi

do_query "UPDATE mysql.global_priv SET User='$newuser' WHERE User='root';"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 311, you used $rootuser, why not here ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

311 is return, unsure what you are asking

scripts/mysql_secure_installation.sh Outdated Show resolved Hide resolved
scripts/mysql_secure_installation.sh Outdated Show resolved Hide resolved
@an3l an3l self-assigned this Apr 28, 2019
@an3l an3l requested a review from vuvova April 28, 2019 14:53
@an3l
Copy link
Collaborator

an3l commented Dec 11, 2019

Hi @ManjotS,
any update regarding the review?

fixed bad indents, while loop for set_root_user
@ManjotS ManjotS requested a review from an3l December 13, 2019 23:16
@vuvova
Copy link
Member

vuvova commented Dec 14, 2019

@ManjotS
Copy link
Author

ManjotS commented Dec 16, 2019

@vuvova I don't think that MDEV will effect this PR.. unless you think we should have secure installation redefine mysql.user view, which it could.

@vuvova
Copy link
Member

vuvova commented Dec 16, 2019

MDEV-19650 says that renaming a root user, breaks mysql.user, makes it unusable.

I think it's very relevant to a PR about renaming the root user.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ManjotS
Copy link
Author

ManjotS commented Mar 26, 2020

I am a MariaDB Corp employee and this work was done as part of my employment. Don't need CLA.

@an3l
Copy link
Collaborator

an3l commented Apr 19, 2021

@ManjotS can you try locally to run your query? I couldn't.

UPDATE mysql.global_priv SET User='foo' WHERE User='root';
SET @v1 := (SELECT CONCAT("CREATE OR REPLACE DEFINER=`'"foo"'`@`localhost` VIEW `mysql`.`user` AS ", view_definition, ";") FROM information_schema.views WHERE table_schema="mysql" and table_name="user"); EXECUTE IMMEDIATE @v1;

@an3l
Copy link
Collaborator

an3l commented Apr 26, 2021

Based on MDEV-19650, mariadb.sys@localhost is a definer for mysql.user and as such we can change the root.
Simple rename user should work.
However there is some ongoing work which will ask user which user to use and I think we can add option to rename the user too.

grooverdan added a commit that referenced this pull request Jun 3, 2021
@grooverdan
Copy link
Member

@ManjotS I took your concepts and wrote ddd6677 to keep it compatible with the goals of MDEV-10112 (Galera replication of changes - which is also getting corrected in the tree of changes). Related to MDEV-22486 its all about ensuring that non-root access can be used and overall this has simplified the implementation somewhat.

If there's unix socket authentication it won't prompt the change.

It currently will rename to $user@% if the user doesn't enter an explicit host portion like bob@localhost that I'll probably correct to preserve the host part of the original.

I know this change has been requested for a long time. Sorry for the delay. Is there any other desired and anti-desired aspects of this implementation in development to fix MDEV-19316?

@ManjotS
Copy link
Author

ManjotS commented Jun 4, 2021

That was quite a simplification, but I am happy with it!

an3l pushed a commit to an3l/server that referenced this pull request Jun 5, 2021
an3l pushed a commit that referenced this pull request Jun 23, 2021
an3l pushed a commit that referenced this pull request Jul 1, 2021
an3l pushed a commit that referenced this pull request Jul 6, 2021
an3l added a commit that referenced this pull request Jul 8, 2021
Patch includes redesign of the script and solves following MDEVs:
- MDEV-22486: mysql_secure_installation cannot work without root user in the database
- MDEV-25169 Secure installation with normal user fails to accept empty root password
- MDEV-10112: mysql_secure_installation should use GRANT, REVOKE, etc for galera support
- MDEV-19316: mysql_secure_installation should offer to rename root user
  Closes PR #1288
- Adding test case for the script evaluation

Co-author: Daniel Black <daniel@mariadb.org>
Reviewed by:
daniel@mariadb.org
serg@mariadb.com
@an3l an3l removed their assignment Mar 28, 2023
@LinuxJedi
Copy link
Contributor

Hi @ManjotS,

I'm going through older pull requests to help move them forward. I see that @an3l is continuing development of this based on your work in his branch bb-10.4-anel-mysql-secureinstall. For this reason, I will close this pull request for now. You are welcome to reopen at if you feel this is in error.

Also, feel free to comment further in MDEV-19316.

@LinuxJedi LinuxJedi closed this Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants