From 2e81eab29fed25655c57235c307c64383056bbe9 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 25 Jan 2022 13:59:41 +1100 Subject: MDEV-27607: mysql_install_db to install mysql_upgrade_info For compatibility this is under an extra option --upgrade-info The goal here is to install a data directory with the required info to let mysql_upgrade know that an upgrade isn't required. --- scripts/mysql_install_db.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'scripts') diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 6a415f4fa11..fdd3a42d77f 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -41,6 +41,7 @@ create database if not exists test; use mysql;" auth_root_authentication_method=normal auth_root_socket_user='root' +upgrade_info=0 dirname0=`dirname $0 2>/dev/null` dirname0=`dirname $dirname0 2>/dev/null` @@ -97,6 +98,7 @@ Usage: $0 [OPTIONS] user. You must be root to use this option. By default mysqld runs using your current login name and files and directories that it creates will be owned by you. + --upgrade-info Store mysql_upgrade_info in the installed data directory. All other options are passed to the mysqld program @@ -152,6 +154,7 @@ parse_arguments() --skip-name-resolve) ip_only=1 ;; --verbose) verbose=1 ; silent_startup="" ;; --rpm) in_rpm=1 ;; + --upgrade-info) upgrade_info=1 ;; --help) usage ;; --no-defaults|--defaults-file=*|--defaults-extra-file=*) defaults="$arg" ;; @@ -509,6 +512,10 @@ SET @auth_root_socket='$auth_root_socket_user';" ;; esac if { echo "$install_params"; cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$fill_help_tables" "$maria_add_gis_sp"; } | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null then + if test "$upgrade_info" -eq 1 + then + printf "@VERSION@-MariaDB" > "$ldata/mysql_upgrade_info" + fi s_echo "OK" else echo -- cgit v1.2.1 From 93a5fb00252c54cad2844b385808a1c6ff0037eb Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 27 Jan 2022 14:43:21 +0200 Subject: MDEV-27477 Remaining SUSE patches for 10.2+ This patch let's you specify not only user to use but also group that MariaDB should use. Original patch: https://github.com/openSUSE/mysql-packaging/blob/master/patches/mysql-patches/mariadb-10.2.3-group.patch Author: Kristyna Streitova Reviewer: monty@mariadb.org --- scripts/CMakeLists.txt | 1 + scripts/mysql_install_db.sh | 22 +++++++++++++++++++--- scripts/mysqld_safe.sh | 10 +++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 190d9f774fb..ec8a53c1b90 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -163,6 +163,7 @@ ENDIF() SET(HOSTNAME "hostname") SET(MYSQLD_USER "mysql") +SET(MYSQLD_GROUP "mysql") ENDIF(UNIX) # Really ugly, one script, "mysql_install_db", needs prefix set to ".", diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index fdd3a42d77f..2a23eb987b4 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -30,6 +30,7 @@ defaults="" defaults_group_suffix="" mysqld_opt="" user="" +group="" silent_startup="--silent-startup" force=0 @@ -98,6 +99,11 @@ Usage: $0 [OPTIONS] user. You must be root to use this option. By default mysqld runs using your current login name and files and directories that it creates will be owned by you. + --group=group_name The login group to use for running mysqld. Files and + directories created by mysqld will be owned by this + group. You must be root to use this option. By default + mysqld runs using your current group and files and + directories that it creates will be owned by you. --upgrade-info Store mysql_upgrade_info in the installed data directory. All other options are passed to the mysqld program @@ -146,11 +152,11 @@ parse_arguments() --builddir=*) builddir=`parse_arg "$arg"` ;; --srcdir=*) srcdir=`parse_arg "$arg"` ;; --ldata=*|--datadir=*|--data=*) ldata=`parse_arg "$arg"` ;; - --user=*) # Note that the user will be passed to mysqld so that it runs # as 'user' (crucial e.g. if log-bin=/some_other_path/ # where a chown of datadir won't help) - user=`parse_arg "$arg"` ;; + --user=*) user=`parse_arg "$arg"` ;; + --group=*) group=`parse_arg "$arg"` ;; --skip-name-resolve) ip_only=1 ;; --verbose) verbose=1 ; silent_startup="" ;; --rpm) in_rpm=1 ;; @@ -461,7 +467,12 @@ do fi if test -n "$user" then - chown $user "$dir" + if test -z "$group" + then + chown $user $dir + else + chown $user:$group $dir + fi if test $? -ne 0 then echo "Cannot change ownership of the database directories to the '$user'" @@ -476,6 +487,11 @@ then args="$args --user=$user" fi +if test -n "$group" +then + args="$args --group=$group" +fi + # When doing a "cross bootstrap" install, no reference to the current # host should be added to the system tables. So we filter out any # lines which contain the current host name. diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 9f539bf875d..29b6d839685 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -29,6 +29,7 @@ logging=init want_syslog=0 syslog_tag= user='@MYSQLD_USER@' +group='@MYSQLD_GROUP@' pid_file= err_log= err_log_base= @@ -318,6 +319,7 @@ parse_arguments() { --pid[-_]file=*) pid_file="$val" ;; --plugin[-_]dir=*) PLUGIN_DIR="$val" ;; --user=*) user="$val"; SET_USER=1 ;; + --group=*) group="$val"; SET_USER=1 ;; --log[-_]basename=*|--hostname=*|--loose[-_]log[-_]basename=*) pid_file="$val.pid"; err_log_base="$val"; @@ -720,6 +722,7 @@ then if test "$user" != "root" -o $SET_USER = 1 then USER_OPTION="--user=$user" + GROUP_OPTION="--group=$group" fi if test -n "$open_files" then @@ -742,7 +745,12 @@ then log_error "Fatal error Can't create database directory '$mysql_unix_port'" exit 1 fi - chown $user $mysql_unix_port_dir + if [ "$user" -a "$group" ]; then + chown $user:$group $mysql_unix_port_dir + else + [ "$user" ] && chown $user $mysql_unix_port_dir + [ "$group" ] && chgrp $group $mysql_unix_port_dir + fi chmod 755 $mysql_unix_port_dir fi -- cgit v1.2.1 From 5acc79d03099568be42ddbc2faa506d2a5b69cf2 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 27 Jan 2022 14:51:16 +0200 Subject: Remove --upgrade-info option from mysql_upgrade Removed the option as it safe to always create the file when we have created the MariaDB data directories. This fixes this issue not only for debian but for all MariaDB users. --- scripts/mysql_install_db.sh | 6 ------ 1 file changed, 6 deletions(-) (limited to 'scripts') diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 2a23eb987b4..d1c0fc67baf 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -42,7 +42,6 @@ create database if not exists test; use mysql;" auth_root_authentication_method=normal auth_root_socket_user='root' -upgrade_info=0 dirname0=`dirname $0 2>/dev/null` dirname0=`dirname $dirname0 2>/dev/null` @@ -104,7 +103,6 @@ Usage: $0 [OPTIONS] group. You must be root to use this option. By default mysqld runs using your current group and files and directories that it creates will be owned by you. - --upgrade-info Store mysql_upgrade_info in the installed data directory. All other options are passed to the mysqld program @@ -160,7 +158,6 @@ parse_arguments() --skip-name-resolve) ip_only=1 ;; --verbose) verbose=1 ; silent_startup="" ;; --rpm) in_rpm=1 ;; - --upgrade-info) upgrade_info=1 ;; --help) usage ;; --no-defaults|--defaults-file=*|--defaults-extra-file=*) defaults="$arg" ;; @@ -528,10 +525,7 @@ SET @auth_root_socket='$auth_root_socket_user';" ;; esac if { echo "$install_params"; cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$fill_help_tables" "$maria_add_gis_sp"; } | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null then - if test "$upgrade_info" -eq 1 - then printf "@VERSION@-MariaDB" > "$ldata/mysql_upgrade_info" - fi s_echo "OK" else echo -- cgit v1.2.1 From e99d3da6381023395c86f679bb76b00b4385dc2d Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 27 Jan 2022 16:04:58 +0200 Subject: Silence the file-key-management plugin during mysql_install_db This avoids printing the error "mysqld: file-key-management-filename is not set" which can happen if the file-key-management pluging is statically compiled --- scripts/mysql_install_db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index d1c0fc67baf..63c014ea098 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -505,7 +505,7 @@ mysqld_install_cmd_line() { "$mysqld_bootstrap" $defaults $defaults_group_suffix "$mysqld_opt" --bootstrap $silent_startup\ "--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 --enforce-storage-engine="" \ - "--plugin-dir=${plugindir}" \ + "--plugin-dir=${plugindir}" --loose-disable-plugin-file-key-management \ $args --max_allowed_packet=8M \ --net_buffer_length=16K } -- cgit v1.2.1