Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-32166

mysql_install_db creates mysql_upgrade_info file with different owner

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Incomplete
    • 10.8.8, 10.6.14, 10.5.22, 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.0.3, 11.1.2, 10.4(EOL), 10.7(EOL)
    • N/A
    • None
    • None

    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
      

      Attachments

        Issue Links

          Activity

            hholzgra Hartmut Holzgraefe added a comment - - edited

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

            hholzgra Hartmut Holzgraefe added a comment - - edited Only tested on latest 10.11 so far, but probably effects all versions after MDEV-27607 "fixed in"

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

            hholzgra Hartmut Holzgraefe added a comment - Another reason for not having this info in a file, but in the database itself ...

            why is it a bug?

            serg Sergei Golubchik added a comment - why is it a bug?

            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

            hholzgra Hartmut Holzgraefe added a comment - 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

            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?

            serg Sergei Golubchik added a comment - 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?
            danblack Daniel Black added a comment -

            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.

            danblack Daniel Black added a comment - 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.

            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?

            serg Sergei Golubchik added a comment - 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?

            Well, it is not really a "good" addition as this information should not be in the file system in the first place, e.g. when restoring a mysqldump from an older version the file system version information will become outright wrong until mariadb-upgrade is being run on it again.

            But it is at least a "better" addition than what we have now.

            I'm still strongly for fixing this correctly by finally implementing https://jira.mariadb.org/browse/MDEV-23008 instead, to get rid of all related problems once and for all.

            hholzgra Hartmut Holzgraefe added a comment - Well, it is not really a "good" addition as this information should not be in the file system in the first place, e.g. when restoring a mysqldump from an older version the file system version information will become outright wrong until mariadb-upgrade is being run on it again. But it is at least a "better" addition than what we have now. I'm still strongly for fixing this correctly by finally implementing https://jira.mariadb.org/browse/MDEV-23008 instead, to get rid of all related problems once and for all.

            People

              Unassigned Unassigned
              hholzgra Hartmut Holzgraefe
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.