[MDEV-32166] mysql_install_db creates mysql_upgrade_info file with different owner Created: 2023-09-14  Updated: 2024-01-08  Resolved: 2024-01-08

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.4, 10.8.8, 10.7, 10.5.22, 10.6.14, 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.0.3, 11.1.2
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Hartmut Holzgraefe Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-27607 mysql_install_db to install mysql_upg... Closed
Relates
relates to MDEV-15207 mysql_upgrade cannot create file mysq... Closed
relates to MDEV-23008 store mysql_upgrade version info in s... Open

 Description   

When running mysql_install_db with --user=... option all files in the created datadir will be owned by the given user, with the exception of mysql_upgrade_info which is owned by the user that executed the script, e.g.:

# mysql_install_db --user=mysql
[...]
# ls -l /var/lib/mysql
total 111040
-rw-rw---- 1 mysql mysql    417792 Sep 14 06:56 aria_log.00000001
-rw-rw---- 1 mysql mysql        52 Sep 14 06:56 aria_log_control
-rw-rw---- 1 mysql mysql       942 Sep 14 06:56 ib_buffer_pool
-rw-rw---- 1 mysql mysql  12582912 Sep 14 06:56 ibdata1
-rw-rw---- 1 mysql mysql 100663296 Sep 14 06:56 ib_logfile0
drwx------ 2 mysql mysql      4096 Sep 14 06:56 mysql
-rw-r--r-- 1 root  root         15 Sep 14 06:56 mysql_upgrade_info
drwx------ 2 mysql mysql      4096 Sep 14 06:56 performance_schema
drwx------ 2 mysql mysql     12288 Sep 14 06:56 sys
drwx------ 2 mysql mysql      4096 Sep 14 06:56 test



 Comments   
Comment by Hartmut Holzgraefe [ 2023-09-14 ]

Only tested on latest 10.11 so far, but probably effects all versions after MDEV-27607 "fixed in"

Comment by Hartmut Holzgraefe [ 2023-09-14 ]

Another reason for not having this info in a file, but in the database itself ...

Comment by Sergei Golubchik [ 2023-09-14 ]

why is it a bug?

Comment by Hartmut Holzgraefe [ 2023-10-16 ]

From KB on the "--user" option:

"The login user name to use for running mysqld. Files and directories created by mysqld will be owned by this user."

I know that this specific file is not created by mysqld/mariadbd, but the average user wouldn't necessarily know, and may get confused by ownership of this one specific file in the datadir not being affected.

Also this breaks things if a user lager chooses to run mysql_upgrade as the regular database system user ("mysql") instead of as ("root"), even though mysql_upgrade should not require root privileges otherwise

Comment by Sergei Golubchik [ 2023-10-16 ]

mysql_upgrade_info is owned by the user that mariadb-upgrade was run under. It's not really specific to mariadb-install-db, one can run mariadb-upgrade after installation as root and then as some other user, and get exactly the same issue.

So, basically, you're saying that mariadb-upgrade should chown the file it creates in the datadir to be owned by the owner of the datadir. Is that the desirable behavior?

Comment by Daniel Black [ 2023-10-17 ]

When the file exists, mariadb-upgrade rewrites the file contents, so fixing mariadb-install-db is desirable to get the base file right. When the file doesn't exist, yes changing the ownership to the datadir owner sound like a good addition too.

Comment by Sergei Golubchik [ 2023-11-20 ]

why is it a good addition? what is the goal, to allow someone to run mariadb-upgrade alternately as root and as mysql user? Like on even weeks as root and on odd weeks as mysql? Is this what you're trying to get working?

Generated at Thu Feb 08 10:29:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.