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

mysql_install_db fails when baseurl is set

Details

    Description

      Originally reported as
      https://issues.redhat.com/browse/RHEL-25575

      Even when a user sets --baseurl=/usr which is valid prefix, the mysql_install_db script fails.

      After a bit of debugging, I found a code branch that tries to look for a plugin that might not exist in paths that do not list all possible options:

      https://github.com/MariaDB/server/blob/eeba940311ed17d160023280783fd2bbb64abef3/scripts/mysql_install_db.sh#L379

      A suggested fix:

      diff -up mariadb-10.11.6/scripts/mysql_install_db.sh.plugindir mariadb-10.11.6/scripts/mysql_install_db.sh
      --- mariadb-10.11.6/scripts/mysql_install_db.sh.plugindir       2024-02-19 17:37:53.677617656 +0100
      +++ mariadb-10.11.6/scripts/mysql_install_db.sh 2024-02-19 17:41:27.907002490 +0100
      @@ -370,7 +370,7 @@ then
           cannot_find_file fill_help_tables.sql @pkgdata_locations@
           exit 1
         fi
      -  plugindir=`find_in_dirs --dir auth_pam.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin $basedir/lib/*/mariadb19/plugin`
      +  plugindir=`find_in_dirs --dir type_mysql_json.so $basedir/lib*/plugin $basedir/lib*/mariadb/plugin $basedir/lib*/mysql/plugin $basedir/lib/*/mariadb19/plugin`
         pamtooldir=$plugindir
       # relative from where the script was run for a relocatable install
       elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mariadbd"
      

      Attachments

        Issue Links

          Activity

            danblack Daniel Black added a comment -

            Thanks hhorak.

            Contributing factors.

            pam as separate package means that the pam_so isn't there (yet?)

            [root@b54bfac133fd /]# rpm -ql mariadb-pam-10.11.6-3.fc40.x86_64.rpm 
            /etc/security/user_map.conf
            /usr/lib/.build-id
            /usr/lib/.build-id/07/bb2bad7cdbbedf0132b4073043d52a2a88c118
            /usr/lib/.build-id/29
            /usr/lib/.build-id/29/bb6d481fc74fa69416fafa2e6533836a90ad76
            /usr/lib/.build-id/7d/142ef00109c4ab000192acd4bb90124e0bd2d2
            /usr/lib/.build-id/e7/4c9731d65d2bedb52335a4f94ffa27bdb854b2
            /usr/lib64/mariadb/plugin/auth_pam.so
            /usr/lib64/mariadb/plugin/auth_pam_tool_dir
            /usr/lib64/mariadb/plugin/auth_pam_tool_dir/auth_pam_tool
            /usr/lib64/mariadb/plugin/auth_pam_v1.so
            /usr/lib64/security/pam_user_map.so
            

            INSTALL_PLUGINDIR="%{_lib}/%

            {majorname}

            /plugin"
            https://src.fedoraproject.org/rpms/mariadb10.11/blob/rawhide/f/mariadb10.11.spec#_857

            means some of the mysql_install_db is out of date.

            No idea why Otto added client plugin dirs in b9dea911bf8e.

            Leaning towards a solution that throws a bunch of heuristic junk out like:

            diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
            index 742eb1e17cf..05182e27f97 100644
            --- a/scripts/mysql_install_db.sh
            +++ b/scripts/mysql_install_db.sh
            @@ -344,33 +344,13 @@ then
               pamtooldir="$builddir/plugin/auth_pam"
             elif test -n "$basedir"
             then
            -  bindir="$basedir/bin" # only used in the help text
            -  resolveip=`find_in_dirs resolveip @resolveip_locations@`
            -  if test -z "$resolveip"
            -  then
            -    cannot_find_file resolveip @resolveip_locations@
            -    exit 1
            -  fi
            -  mysqld=`find_in_dirs mariadbd @mysqld_locations@`
            -  if test -z "$mysqld"
            -  then
            -      cannot_find_file mariadbd @mysqld_locations@
            -      exit 1
            -  fi
            -  langdir=`find_in_dirs --dir errmsg.sys @errmsg_locations@`
            -  if test -z "$langdir"
            -  then
            -    cannot_find_file errmsg.sys @errmsg_locations@
            -    exit 1
            -  fi
            -  srcpkgdatadir=`find_in_dirs --dir fill_help_tables.sql @pkgdata_locations@`
            -  buildpkgdatadir=$srcpkgdatadir
            -  if test -z "$srcpkgdatadir"
            -  then
            -    cannot_find_file fill_help_tables.sql @pkgdata_locations@
            -    exit 1
            -  fi
            -  plugindir=`find_in_dirs --dir auth_pam.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin $basedir/lib/*/mariadb19/plugin`
            +  bindir="$basedir/@INSTALL_BINDIR@"
            +  resolveip="$bindir/resolveip"
            +  mysqld="$basedir/@INSTALL_SBINDIR@/mariadbd"
            +  langdir="$basedir/sql/share/english"
            +  srcpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@"
            +  buildpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@"
            +  plugindir="$basedir/@INSTALL_PLUGINDIR@"
               pamtooldir=$plugindir
             # relative from where the script was run for a relocatable install
             elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mariadbd"
            

            (haven't tested it yet)

            danblack Daniel Black added a comment - Thanks hhorak . Contributing factors. pam as separate package means that the pam_so isn't there (yet?) [root@b54bfac133fd /]# rpm -ql mariadb-pam-10.11.6-3.fc40.x86_64.rpm /etc/security/user_map.conf /usr/lib/.build-id /usr/lib/.build-id/07/bb2bad7cdbbedf0132b4073043d52a2a88c118 /usr/lib/.build-id/29 /usr/lib/.build-id/29/bb6d481fc74fa69416fafa2e6533836a90ad76 /usr/lib/.build-id/7d/142ef00109c4ab000192acd4bb90124e0bd2d2 /usr/lib/.build-id/e7/4c9731d65d2bedb52335a4f94ffa27bdb854b2 /usr/lib64/mariadb/plugin/auth_pam.so /usr/lib64/mariadb/plugin/auth_pam_tool_dir /usr/lib64/mariadb/plugin/auth_pam_tool_dir/auth_pam_tool /usr/lib64/mariadb/plugin/auth_pam_v1.so /usr/lib64/security/pam_user_map.so INSTALL_PLUGINDIR="%{_lib}/% {majorname} /plugin" https://src.fedoraproject.org/rpms/mariadb10.11/blob/rawhide/f/mariadb10.11.spec#_857 means some of the mysql_install_db is out of date. No idea why Otto added client plugin dirs in b9dea911bf8e. Leaning towards a solution that throws a bunch of heuristic junk out like: diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 742eb1e17cf..05182e27f97 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -344,33 +344,13 @@ then pamtooldir="$builddir/plugin/auth_pam" elif test -n "$basedir" then - bindir="$basedir/bin" # only used in the help text - resolveip=`find_in_dirs resolveip @resolveip_locations@` - if test -z "$resolveip" - then - cannot_find_file resolveip @resolveip_locations@ - exit 1 - fi - mysqld=`find_in_dirs mariadbd @mysqld_locations@` - if test -z "$mysqld" - then - cannot_find_file mariadbd @mysqld_locations@ - exit 1 - fi - langdir=`find_in_dirs --dir errmsg.sys @errmsg_locations@` - if test -z "$langdir" - then - cannot_find_file errmsg.sys @errmsg_locations@ - exit 1 - fi - srcpkgdatadir=`find_in_dirs --dir fill_help_tables.sql @pkgdata_locations@` - buildpkgdatadir=$srcpkgdatadir - if test -z "$srcpkgdatadir" - then - cannot_find_file fill_help_tables.sql @pkgdata_locations@ - exit 1 - fi - plugindir=`find_in_dirs --dir auth_pam.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin $basedir/lib/*/mariadb19/plugin` + bindir="$basedir/@INSTALL_BINDIR@" + resolveip="$bindir/resolveip" + mysqld="$basedir/@INSTALL_SBINDIR@/mariadbd" + langdir="$basedir/sql/share/english" + srcpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@" + buildpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@" + plugindir="$basedir/@INSTALL_PLUGINDIR@" pamtooldir=$plugindir # relative from where the script was run for a relocatable install elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mariadbd" (haven't tested it yet)
            danblack Daniel Black added a comment -

            Test:

            $ cmake --install . --prefix /tmp/m10.11
            $ rm -rf /tmp/dd-10.11/
            $ mkdir /tmp/dd-10.11
            $ /tmp/m10.11/scripts/mariadb-install-db --no-defaults --basedir=/tmp/m10.11 --datadir=/tmp/dd-10.11 --verbose
            Installing MariaDB/MySQL system tables in '/tmp/dd-10.11' ...
            2024-02-21 17:16:54 0 [Note] Starting MariaDB 10.11.8-MariaDB source revision 32f535d45c7cf1ef5e445e7814dbedc67b23b7b7 as process 164589
            2024-02-21 17:16:54 0 [Note] InnoDB: The first data file './ibdata1' did not exist. A new tablespace will be created!
            2024-02-21 17:16:54 0 [Note] InnoDB: Compressed tables use zlib 1.2.13
            2024-02-21 17:16:54 0 [Note] InnoDB: Number of transaction pools: 1
            2024-02-21 17:16:54 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
            2024-02-21 17:16:54 0 [Note] InnoDB: Using liburing
            2024-02-21 17:16:54 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
            2024-02-21 17:16:54 0 [Note] InnoDB: Initialized memory pressure event listener
            2024-02-21 17:16:54 0 [Note] InnoDB: Completed initialization of buffer pool
            2024-02-21 17:16:54 0 [Note] InnoDB: Setting file './ibdata1' size to 12.000MiB. Physically writing the file full; Please wait ...
            2024-02-21 17:16:54 0 [Note] InnoDB: File './ibdata1' size is now 12.000MiB.
            2024-02-21 17:16:54 0 [Note] InnoDB: Buffered log writes (block size=512 bytes)
            2024-02-21 17:16:55 0 [Note] InnoDB: Doublewrite buffer not found: creating new
            2024-02-21 17:16:55 0 [Note] InnoDB: 128 rollback segments are active.
            2024-02-21 17:16:55 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
            2024-02-21 17:16:55 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
            2024-02-21 17:16:55 0 [Note] InnoDB: log sequence number 0; transaction id 3
            OK
             
            To start mariadbd at boot time you have to copy
            support-files/mariadb.service to the right place for your system
             
             
            Two all-privilege accounts were created.
            One is root@localhost, it has no password, but you need to
            be system 'root' user to connect. Use, for example, sudo mysql
            The second is dan@localhost, it has no password either, but
            you need to be the system 'dan' user to connect.
            After connecting you can set the password, if you would need to be
            able to connect as any of these users with a password and without sudo
             
            See the MariaDB Knowledgebase at https://mariadb.com/kb
             
            You can start the MariaDB daemon with:
            cd '/tmp/m10.11' ; /tmp/m10.11/bin/mariadbd-safe --datadir='/tmp/dd-10.11'
             
            You can test the MariaDB daemon with mysql-test-run.pl
            cd '/tmp/m10.11/mysql-test' ; perl mariadb-test-run.pl
             
            Please report any problems at https://mariadb.org/jira
             
            The latest information about MariaDB is available at https://mariadb.org/.
             
            Consider joining MariaDB's strong and vibrant community:
            https://mariadb.org/get-involved/
            

            danblack Daniel Black added a comment - Test: $ cmake --install . --prefix /tmp/m10.11 $ rm -rf /tmp/dd-10.11/ $ mkdir /tmp/dd-10.11 $ /tmp/m10.11/scripts/mariadb-install-db --no-defaults --basedir=/tmp/m10.11 --datadir=/tmp/dd-10.11 --verbose Installing MariaDB/MySQL system tables in '/tmp/dd-10.11' ... 2024-02-21 17:16:54 0 [Note] Starting MariaDB 10.11.8-MariaDB source revision 32f535d45c7cf1ef5e445e7814dbedc67b23b7b7 as process 164589 2024-02-21 17:16:54 0 [Note] InnoDB: The first data file './ibdata1' did not exist. A new tablespace will be created! 2024-02-21 17:16:54 0 [Note] InnoDB: Compressed tables use zlib 1.2.13 2024-02-21 17:16:54 0 [Note] InnoDB: Number of transaction pools: 1 2024-02-21 17:16:54 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions 2024-02-21 17:16:54 0 [Note] InnoDB: Using liburing 2024-02-21 17:16:54 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB 2024-02-21 17:16:54 0 [Note] InnoDB: Initialized memory pressure event listener 2024-02-21 17:16:54 0 [Note] InnoDB: Completed initialization of buffer pool 2024-02-21 17:16:54 0 [Note] InnoDB: Setting file './ibdata1' size to 12.000MiB. Physically writing the file full; Please wait ... 2024-02-21 17:16:54 0 [Note] InnoDB: File './ibdata1' size is now 12.000MiB. 2024-02-21 17:16:54 0 [Note] InnoDB: Buffered log writes (block size=512 bytes) 2024-02-21 17:16:55 0 [Note] InnoDB: Doublewrite buffer not found: creating new 2024-02-21 17:16:55 0 [Note] InnoDB: 128 rollback segments are active. 2024-02-21 17:16:55 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ... 2024-02-21 17:16:55 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB. 2024-02-21 17:16:55 0 [Note] InnoDB: log sequence number 0; transaction id 3 OK   To start mariadbd at boot time you have to copy support-files/mariadb.service to the right place for your system     Two all-privilege accounts were created. One is root@localhost, it has no password, but you need to be system 'root' user to connect. Use, for example, sudo mysql The second is dan@localhost, it has no password either, but you need to be the system 'dan' user to connect. After connecting you can set the password, if you would need to be able to connect as any of these users with a password and without sudo   See the MariaDB Knowledgebase at https://mariadb.com/kb   You can start the MariaDB daemon with: cd '/tmp/m10.11' ; /tmp/m10.11/bin/mariadbd-safe --datadir='/tmp/dd-10.11'   You can test the MariaDB daemon with mysql-test-run.pl cd '/tmp/m10.11/mysql-test' ; perl mariadb-test-run.pl   Please report any problems at https://mariadb.org/jira   The latest information about MariaDB is available at https://mariadb.org/.   Consider joining MariaDB's strong and vibrant community: https://mariadb.org/get-involved/

            People

              danblack Daniel Black
              hhorak Honza Horak
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.