export DEBIAN_SCRIPT_DEBUG=1 root@ubuntu-bionic:~# apt-get install mariadb-server mariadb-plugin-rocksdb Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libmariadb3 mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server-10.5 mariadb-server-core-10.5 Suggested packages: mailx mariadb-test tinyca The following NEW packages will be installed: libmariadb3 mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-plugin-rocksdb mariadb-server mariadb-server-10.5 mariadb-server-core-10.5 0 upgraded, 8 newly installed, 0 to remove and 1 not upgraded. Need to get 0 B/17.1 MB of archives. After this operation, 167 MB of additional disk space will be used. Do you want to continue? [Y/n] Preconfiguring packages ... + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /tmp/mariadb-server-10.5.config.xEGOxU configure ' '1>&2' #42#DEBUG# RUNNING /tmp/mariadb-server-10.5.config.xEGOxU configure 1>&2 # Beware that there are two ypwhich one of them needs the 2>/dev/null! if test -n "`which ypwhich 2>/dev/null`" && ypwhich >/dev/null 2>&1; then db_input high mariadb-server-10.0/nis_warning || true db_go fi ++ which ypwhich + test -n '' Selecting previously unselected package mariadb-common. (Reading database ... 60318 files and directories currently installed.) Preparing to unpack .../mariadb-common_1%3a10.5.4+maria~bionic_all.deb ... Unpacking mariadb-common (1:10.5.4+maria~bionic) ... Selecting previously unselected package libmariadb3:amd64. Preparing to unpack .../libmariadb3_1%3a10.5.4+maria~bionic_amd64.deb ... Unpacking libmariadb3:amd64 (1:10.5.4+maria~bionic) ... Selecting previously unselected package mariadb-client-core-10.5. Preparing to unpack .../mariadb-client-core-10.5_1%3a10.5.4+maria~bionic_amd64.deb ... Unpacking mariadb-client-core-10.5 (1:10.5.4+maria~bionic) ... Selecting previously unselected package mariadb-client-10.5. Preparing to unpack .../mariadb-client-10.5_1%3a10.5.4+maria~bionic_amd64.deb ... Unpacking mariadb-client-10.5 (1:10.5.4+maria~bionic) ... Selecting previously unselected package mariadb-server-core-10.5. Preparing to unpack .../mariadb-server-core-10.5_1%3a10.5.4+maria~bionic_amd64.deb ... Unpacking mariadb-server-core-10.5 (1:10.5.4+maria~bionic) ... Setting up mariadb-common (1:10.5.4+maria~bionic) ... Selecting previously unselected package mariadb-server-10.5. (Reading database ... 60523 files and directories currently installed.) Preparing to unpack .../mariadb-server-10.5_1%3a10.5.4+maria~bionic_amd64.deb ... + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/config configure ' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/config configure 1>&2 # Beware that there are two ypwhich one of them needs the 2>/dev/null! if test -n "`which ypwhich 2>/dev/null`" && ypwhich >/dev/null 2>&1; then db_input high mariadb-server-10.0/nis_warning || true db_go fi ++ which ypwhich + test -n '' + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/preinst install' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/preinst install 1>&2 export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin + export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin:/usr/sbin:/bin:/usr/bin + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin:/usr/sbin:/bin:/usr/bin mysql_datadir=/var/lib/mysql + mysql_datadir=/var/lib/mysql mysql_upgradedir=/var/lib/mysql-upgrade + mysql_upgradedir=/var/lib/mysql-upgrade # Try to stop the server in a sane way. If it does not success let the admin # do it himself. No database directories should be removed while the server # is running! Another mariadbd in e.g. a different chroot is fine for us. stop_server() { # Return immediately if there are no mysql processes running # as there is no point in trying to shutdown in that case. if ! pgrep -x --ns $$ mariadbd > /dev/null; then return; fi set +e invoke-rc.d mariadb stop errno=$? set -e # systemctl could emit exit code 100=no init script (fresh install) if [ "$errno" != 0 -a "$errno" != 100 ]; then echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2 echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2 echo "Stop it yourself and try again!" 1>&2 db_stop exit 1 fi } ################################ main() ########################## this_version=$MAJOR_VER + this_version=10.5 max_upgradeable_version=5.7 + max_upgradeable_version=5.7 # Check if a flag file is found that indicates a previous MariaDB or MySQL # version was installed. If multiple flags are found, check which one was # the biggest version number. for flag in $mysql_datadir/debian-*.flag do # The for loop leaves $flag as the query string if there are no results, # so the check below is needed to stop further processing when there are # no real results. if [ "$flag" = "$mysql_datadir/debian-*.flag" ] then break fi flag_version=$(echo "$flag" | sed 's/.*debian-\([0-9\.]\+\).flag/\1/') # Initialize value if empty if [ -z "$found_version" ] then found_version=$flag_version fi # Update value if now bigger then before if dpkg --compare-versions "$flag_version" '>>' "$found_version" then found_version=$flag_version fi done + for flag in $mysql_datadir/debian-*.flag + '[' '/var/lib/mysql/debian-*.flag' = '/var/lib/mysql/debian-*.flag' ']' + break # If an upgrade is detected, proceed with it automatically without # requiring any user interaction. # # However, if the user attempts to downgrade, warn about the incompatibility. # Downgrade is detected if the flag version is bigger than $this_version # (e.g. 10.1 > 10.0) or the flag version is smaller than 10.0 but bigger # than $max_upgradeable_version. if [ ! -z "$found_version" ] then # MySQL 8.0 in Ubuntu has a bug in packaging and the file is name wrongly # 'debian-5.7.flag', so in case '5.7' was encountered an extra check needs to # be done to see is there is a file called undo_001, which is a sign of 8.0. if [ "$found_version" == "5.7" ] && [ -f "$mysql_datadir/undo_001" ] then # Seems to be a 8.0, flag has wrongly 5.7 (know bug) found_version=8.0 fi echo "$mysql_datadir: found previous version $found_version" if dpkg --compare-versions "$found_version" '>>' "$this_version" then downgrade_detected=true fi if dpkg --compare-versions "$found_version" '>>' "$max_upgradeable_version" \ && dpkg --compare-versions "$found_version" '<<' "10.0" then downgrade_detected=true fi fi + '[' '!' -z '' ']' # Don't abort dpkg if downgrade is detected (as was done previously). # Instead simply move the old datadir and create a new for this_version. if [ ! -z "$downgrade_detected" ] then db_input critical "mariadb-server-$MAJOR_VER/old_data_directory_saved" || true db_go echo "The file $mysql_datadir/debian-$found_version.flag indicates a" 1>&2 echo "version that cannot automatically be upgraded. Therefore the" 1>&2 echo "previous data directory will be renamed to $mysql_datadir-$found_version and" 1>&2 echo "a new data directory will be initialized at $mysql_datadir." 1>&2 echo "Please manually export/import your data (e.g. with mysqldump) if needed." 1>&2 mv -f "$mysql_datadir" "$mysql_datadir-$found_version" # Also move away the old debian.cnf file that included credentials that are # no longer valid mv -f /etc/mysql/debian.cnf "/etc/mysql/debian.cnf-$found_version" fi + '[' '!' -z '' ']' # to be sure stop_server + stop_server + pgrep -x --ns 5399 mariadbd + return # If we use NIS then errors should be tolerated. It's up to the # user to ensure that the mysql user is correctly setup. # Beware that there are two ypwhich one of them needs the 2>/dev/null! if test -n "$(which ypwhich 2>/dev/null)" && ypwhich >/dev/null 2>&1; then set +e fi ++ which ypwhich + test -n '' # # Now we have to ensure the following state: # /etc/passwd: mysql:x:100:101:MySQL Server:/nonexistent:/bin/false # /etc/group: mysql:x:101: # # Sadly there could any state be present on the system so we have to # modify everything carefully i.e. not doing a chown before creating # the user etc... # # creating mysql group if he isn't already there if ! getent group mysql >/dev/null; then # Adding system group: mysql. addgroup --system mysql >/dev/null fi + getent group mysql + addgroup --system mysql # creating mysql user if he isn't already there if ! getent passwd mysql >/dev/null; then # Adding system user: mysql. adduser \ --system \ --disabled-login \ --ingroup mysql \ --no-create-home \ --home /nonexistent \ --gecos "MySQL Server" \ --shell /bin/false \ mysql >/dev/null fi + getent passwd mysql + adduser --system --disabled-login --ingroup mysql --no-create-home --home /nonexistent --gecos 'MySQL Server' --shell /bin/false mysql # end of NIS tolerance zone set -e + set -e # if there's a symlink, let's store where it's pointing, because otherwise # it's going to be lost in some situations for dir in DATADIR LOGDIR; do checkdir=$(eval echo "$"$dir) if [ -L "$checkdir" ]; then # Use mkdir option 'Z' to create with correct SELinux context. mkdir -pZ "$mysql_upgradedir" cp -dT "$checkdir" "$mysql_upgradedir/$dir.link" fi done + for dir in DATADIR LOGDIR ++ eval echo '$DATADIR' +++ echo + checkdir= + '[' -L '' ']' + for dir in DATADIR LOGDIR ++ eval echo '$LOGDIR' +++ echo + checkdir= + '[' -L '' ']' # creating mysql home directory if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ]; then # Use mkdir option 'Z' to create with correct SELinux context. mkdir -Z $mysql_datadir fi + '[' '!' -d /var/lib/mysql ']' + '[' '!' -L /var/lib/mysql ']' + mkdir -Z /var/lib/mysql # checking disc space if LC_ALL=C BLOCKSIZE= df --portability $mysql_datadir/. | tail -n 1 | awk '{ exit ($4>1000) }'; then echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2 db_stop exit 1 fi + tail -n 1 + awk '{ exit ($4>1000) }' + LC_ALL=C + BLOCKSIZE= + df --portability /var/lib/mysql/. # Since the home directory was created before putting the user into # the mysql group and moreover we cannot guarantee that the # permissions were correctly *before* calling this script, we fix them now. # In case we use NIS and no mysql user is present then this script should # better fail now than later.. # The "set +e" is necessary as e.g. a ".journal" of a ext3 partition is # not chgrp'able (#318435). set +e + set +e find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql + xargs -0 -r chown mysql ++ id -u mysql + find /var/lib/mysql '!' -uid 111 -print0 find $mysql_datadir -follow -not -group mysql -print0 2>/dev/null \ | xargs -0 --no-run-if-empty chgrp mysql + xargs -0 --no-run-if-empty chgrp mysql + find /var/lib/mysql -follow -not -group mysql -print0 set -e + set -e db_stop + db_stop + echo STOP Unpacking mariadb-server-10.5 (1:10.5.4+maria~bionic) ... Selecting previously unselected package mariadb-plugin-rocksdb. Preparing to unpack .../mariadb-plugin-rocksdb_1%3a10.5.4+maria~bionic_amd64.deb ... Unpacking mariadb-plugin-rocksdb (1:10.5.4+maria~bionic) ... Selecting previously unselected package mariadb-server. Preparing to unpack .../mariadb-server_1%3a10.5.4+maria~bionic_all.deb ... Unpacking mariadb-server (1:10.5.4+maria~bionic) ... Setting up libmariadb3:amd64 (1:10.5.4+maria~bionic) ... Setting up mariadb-client-core-10.5 (1:10.5.4+maria~bionic) ... Setting up mariadb-client-10.5 (1:10.5.4+maria~bionic) ... Setting up mariadb-server-core-10.5 (1:10.5.4+maria~bionic) ... Setting up mariadb-server-10.5 (1:10.5.4+maria~bionic) ... + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.config configure ' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.config configure 1>&2 # Beware that there are two ypwhich one of them needs the 2>/dev/null! if test -n "`which ypwhich 2>/dev/null`" && ypwhich >/dev/null 2>&1; then db_input high mariadb-server-10.0/nis_warning || true db_go fi ++ which ypwhich + test -n '' + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.postinst configure ' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.postinst configure 1>&2 export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin + export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin:/usr/sbin:/bin:/usr/bin + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin:/usr/sbin:/bin:/usr/bin # This command can be used as pipe to syslog. With "-s" it also logs to stderr. ERR_LOGGER="logger -p daemon.err -t mariadb-server-$MAJOR_VER.postinst -i" + ERR_LOGGER='logger -p daemon.err -t mariadb-server-10.5.postinst -i' # Specify syslog tag name so it is clear the entry came from this postinst script. # This will make an error in a logged command immediately apparent by aborting # the install, rather than failing silently and leaving a broken install. set -o pipefail + set -o pipefail case "$1" in configure) # This is needed because mysql_install_db removes the pid file in /run # and because changed configuration options should take effect immediately. # In case the server wasn't running at all it should be ok if the stop # script fails. I can't tell at this point because of the cleaned /run. set +e; invoke-rc.d mariadb stop; set -e # An existing /etc/init.d/mysql might be on the system if there was a # previous MySQL or MariaDB installation, since /etc/init.d files are # considered config files and stay around even after the package is removed. # # The install step of this package adds a new /etc/init.d/mariadb file. As # we also want to ensure that there are no old (and potentially outdated) # versions of /etc/init.d/mysql we simply replace it using a copy of the # latest 'mariadb' file. This has also the added benefit that anything that # invokes traditional sysv init with either 'mysql' or 'mariadb' will end up # controlling this newly installed MariaDB, and thus we maintain better # backwards compatiblity. # # Note that the 'Provides' line is also updated to avoid 'insserv' exiting # on failure (when it is run by update-rc.d) because of duplicate service # names. if [ -f "/etc/init.d/mysql" ] && [ -f "/etc/init.d/mariadb" ] then # Copy init file and rename the service name and filename on the fly sed 's/Provides: mariadb/Provides: mysql/g' /etc/init.d/mariadb > /etc/init.d/mysql # NOTE: Number of spaces/tabs is important here! # Confirm if the sed worked if ! grep --quiet "Provides: mysql" /etc/init.d/mysql then # If not, then delete the file to avoid failures later on rm -f /etc/init.d/mysql echo "Warning! Failed creating a mysql named copy of mariadb init.d file" fi fi mysql_statedir=/usr/share/mysql mysql_datadir=/var/lib/mysql mysql_logdir=/var/log/mysql mysql_cfgdir=/etc/mysql mysql_upgradedir=/var/lib/mysql-upgrade # If the following symlink exists, it is a preserved copy the old data dir # created by the preinst script during a upgrade that would have otherwise # been replaced by an empty mysql dir. This should restore it. for dir in DATADIR LOGDIR; do if [ "$dir" = "DATADIR" ]; then targetdir=$mysql_datadir else targetdir=$mysql_logdir fi savelink="$mysql_upgradedir/$dir.link" if [ -L "$savelink" ]; then # If the targetdir was a symlink before we upgraded it is supposed # to be either still be present or not existing anymore now. if [ -L "$targetdir" ]; then rm "$savelink" elif [ ! -d "$targetdir" ]; then mv "$savelink" "$targetdir" else # this should never even happen, but just in case... mysql_tmp=$(mktemp -d -t mysql-symlink-restore-XXXXXX) echo "this is very strange! see $mysql_tmp/README..." >&2 mv "$targetdir" "$mysql_tmp" cat << EOF > "$mysql_tmp/README" If you're reading this, it's most likely because you had replaced /var/lib/mysql with a symlink, then upgraded to a new version of mysql, and then dpkg removed your symlink (see #182747 and others). The mysql packages noticed that this happened, and as a workaround have restored it. However, because /var/lib/mysql seems to have been re-created in the meantime, and because we don't want to rm -rf something we don't know as much about, we are going to leave this unexpected directory here. If your database looks normal, and this is not a symlink to your database, you should be able to blow this all away. EOF fi fi rmdir $mysql_upgradedir 2>/dev/null || true done # Ensure the existence and right permissions for the database and # log files. Use mkdir option 'Z' to create with correct SELinux context. if [ ! -d "$mysql_statedir" ] && [ ! -L "$mysql_statedir" ]; then mkdir -Z "$mysql_statedir"; fi if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ]; then mkdir -Z "$mysql_datadir" ; fi if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ]; then mkdir -Z "$mysql_logdir" ; fi # When creating an ext3 jounal on an already mounted filesystem like e.g. # /var/lib/mysql, you get a .journal file that is not modifyable by chown. # The mysql_statedir must not be writable by the mysql user under any # circumstances as it contains scripts that are executed by root. set +e chown -R 0:0 $mysql_statedir find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql chown -R mysql:adm $mysql_logdir chmod 2750 $mysql_logdir set -e ## Set the correct filesystem ownership for the PAM v2 plugin # eg. /usr/lib/x86_64-linux-gnu/mysql/plugin/auth_pam_tool_dir/ # NOTE! This is security sensitive, don't allow for a race condition. # # 1. Drop privileges of directory # -> At this point only root can see and execute auth_pam_tool chmod 0700 /usr/lib/mysql/plugin/auth_pam_tool_dir # # 2. Make binary setuid # -> At this point only root can run the setuid binary so no escalation here yet chmod 04755 /usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool # # 3. Allow user 'mysql' to see and execute auth_pam_tool # -> Now user mysql owns the directory and can see and execute the binary inside # -> Since the binary is setuid, user mysql gets limited root powers here to # run the PAM authetications, which need root (e.g. to validate passwords # against /etc/shadow) chown mysql /usr/lib/mysql/plugin/auth_pam_tool_dir # This is important to avoid dataloss when there is a removed # mysql-server version from Woody lying around which used the same # data directory and then somewhen gets purged by the admin. db_set mariadb-server/postrm_remove_database false || true # Clean up old flags before setting new one rm -f $mysql_datadir/debian-*.flag # Flag data dir to avoid downgrades touch "$mysql_datadir/debian-$MAJOR_VER.flag" # initiate databases. Output is not allowed by debconf :-( # This will fail if we are upgrading an existing database; in this case # mysql_upgrade, called from the /etc/init.d/mariadb start script, will # handle things. # Debian: beware of the bashisms... # Debian: can safely run on upgrades with existing databases set +e bash /usr/bin/mysql_install_db --rpm --cross-bootstrap --user=mysql \ --disable-log-bin --skip-test-db 2>&1 | \ $ERR_LOGGER set -e # To avoid downgrades. touch "$mysql_statedir/debian-$MAJOR_VER.flag" # On new installations root user can connect via unix_socket. # But on upgrades, scripts rely on debian-sys-maint user and # credentials in /etc/mysql/debian.cnf # All tools use --defaults-file=/etc/mysql/debian.cnf # And while it's not needed for new installations, we keep using # --defaults-file option for tools (for the sake of upgrades) # and thus need /etc/mysql/debian.cnf to exist, even if it's empty. dc=$mysql_cfgdir/debian.cnf; if [ ! -d "$mysql_cfgdir" ]; then install -o 0 -g 0 -m 0755 -d $mysql_cfgdir fi if [ ! -e "$dc" ]; then cat /dev/null > $dc echo "# Automatically generated for Debian scripts. DO NOT TOUCH!" >>$dc fi # Keep it only root-readable, as it always was chown 0:0 $dc chmod 0600 $dc # If there is a real AppArmor profile, we reload it. # If the default empty profile is installed, then we remove any old # profile that may be loaded. # This allows upgrade from old versions (that have an apparmor profile # on by default) to work both to disable a default profile, and to keep # any profile installed and maintained by users themselves. profile="/etc/apparmor.d/usr.sbin.mariadbd" if [ -f "$profile" ] && aa-status --enabled 2>/dev/null; then if grep -q /usr/sbin/mariadbd "$profile" 2>/dev/null ; then apparmor_parser -r "$profile" || true else echo "/usr/sbin/mariadbd { }" | apparmor_parser --remove 2>/dev/null || true fi fi # @TODO: Remove once buildbot.askmonty.org has been updated not to expect this file mkdir -p /etc/systemd/system/mariadb.service.d/ # Note that file cannot be empty, otherwise systemd version in Ubuntu Bionic # will think the service is masked echo "# empty placeholder" > /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf ;; abort-upgrade|abort-remove|abort-configure) ;; triggered) if [ -x "$(command -v systemctl)" ]; then systemctl daemon-reload else invoke-rc.d mariadb restart fi ;; *) echo "postinst called with unknown argument '$1'" 1>&2 exit 1 ;; esac + case "$1" in + set +e + invoke-rc.d mariadb stop + set -e + '[' -f /etc/init.d/mysql ']' + mysql_statedir=/usr/share/mysql + mysql_datadir=/var/lib/mysql + mysql_logdir=/var/log/mysql + mysql_cfgdir=/etc/mysql + mysql_upgradedir=/var/lib/mysql-upgrade + for dir in DATADIR LOGDIR + '[' DATADIR = DATADIR ']' + targetdir=/var/lib/mysql + savelink=/var/lib/mysql-upgrade/DATADIR.link + '[' -L /var/lib/mysql-upgrade/DATADIR.link ']' + rmdir /var/lib/mysql-upgrade + for dir in DATADIR LOGDIR + '[' LOGDIR = DATADIR ']' + targetdir=/var/log/mysql + savelink=/var/lib/mysql-upgrade/LOGDIR.link + '[' -L /var/lib/mysql-upgrade/LOGDIR.link ']' + rmdir /var/lib/mysql-upgrade + true + '[' '!' -d /usr/share/mysql ']' + '[' '!' -d /var/lib/mysql ']' + '[' '!' -d /var/log/mysql ']' + '[' '!' -L /var/log/mysql ']' + mkdir -Z /var/log/mysql + set +e + chown -R 0:0 /usr/share/mysql + xargs -0 -r chown mysql ++ id -u mysql + find /var/lib/mysql '!' -uid 111 -print0 + chown -R mysql:adm /var/log/mysql + chmod 2750 /var/log/mysql + set -e + chmod 0700 /usr/lib/mysql/plugin/auth_pam_tool_dir + chmod 04755 /usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool + chown mysql /usr/lib/mysql/plugin/auth_pam_tool_dir + db_set mariadb-server/postrm_remove_database false + _db_cmd 'SET mariadb-server/postrm_remove_database' false + _db_internal_IFS=' ' + IFS=' ' + printf '%s\n' 'SET mariadb-server/postrm_remove_database false' + IFS=' ' + IFS=' ' + read -r _db_internal_line + RET='10 mariadb-server/postrm_remove_database doesn'\''t exist' + case ${_db_internal_line%%[ ]*} in + return 10 + true + rm -f '/var/lib/mysql/debian-*.flag' + touch /var/lib/mysql/debian-10.5.flag + set +e + bash /usr/bin/mysql_install_db --rpm --cross-bootstrap --user=mysql --disable-log-bin --skip-test-db + logger -p daemon.err -t mariadb-server-10.5.postinst -i + set -e + touch /usr/share/mysql/debian-10.5.flag + dc=/etc/mysql/debian.cnf + '[' '!' -d /etc/mysql ']' + '[' '!' -e /etc/mysql/debian.cnf ']' + cat /dev/null + echo '# Automatically generated for Debian scripts. DO NOT TOUCH!' + chown 0:0 /etc/mysql/debian.cnf + chmod 0600 /etc/mysql/debian.cnf + profile=/etc/apparmor.d/usr.sbin.mariadbd + '[' -f /etc/apparmor.d/usr.sbin.mariadbd ']' + aa-status --enabled + grep -q /usr/sbin/mariadbd /etc/apparmor.d/usr.sbin.mariadbd + echo '/usr/sbin/mariadbd { }' + apparmor_parser --remove + true + mkdir -p /etc/systemd/system/mariadb.service.d/ + echo '# empty placeholder' db_stop # in case invoke failes + db_stop + echo STOP # dh_systemd_start doesn't emit anything since we still ship /etc/init.d/mariadb. # Thus MariaDB server is started via init.d script, which in turn redirects to # systemctl. If we upgrade from MySQL mysql.service may be masked, which also # means init.d script is disabled. Unmask mysql service explicitly. # Check first that the command exists, to avoid emitting any warning messages. if [ -x "$(command -v deb-systemd-helper)" ]; then deb-systemd-helper unmask mysql.service > /dev/null fi ++ command -v deb-systemd-helper + '[' -x /usr/bin/deb-systemd-helper ']' + deb-systemd-helper unmask mysql.service # Automatically added by dh_systemd_enable/11.1.6ubuntu1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'mariadb.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'mariadb.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'mariadb.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'mariadb.service' >/dev/null || true fi fi + '[' configure = configure ']' + deb-systemd-helper unmask mariadb.service + deb-systemd-helper --quiet was-enabled mariadb.service + deb-systemd-helper enable mariadb.service Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service. # End automatically added section # Automatically added by dh_systemd_enable/11.1.6ubuntu1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if deb-systemd-helper debian-installed 'mariadb.service'; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'mariadb.service' >/dev/null || true if deb-systemd-helper --quiet was-enabled 'mariadb.service'; then # Create new symlinks, if any. deb-systemd-helper enable 'mariadb.service' >/dev/null || true fi fi # Update the statefile to add new symlinks (if any), which need to be cleaned # up on purge. Also remove old symlinks. deb-systemd-helper update-state 'mariadb.service' >/dev/null || true fi + '[' configure = configure ']' + deb-systemd-helper debian-installed mariadb.service + deb-systemd-helper unmask mariadb.service + deb-systemd-helper --quiet was-enabled mariadb.service + deb-systemd-helper enable mariadb.service + deb-systemd-helper update-state mariadb.service # End automatically added section # Automatically added by dh_installinit/11.1.6ubuntu1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -x "/etc/init.d/mariadb" ]; then update-rc.d mariadb defaults 19 21 >/dev/null || exit 1 fi fi + '[' configure = configure ']' + '[' -x /etc/init.d/mariadb ']' + update-rc.d mariadb defaults 19 21 # End automatically added section # Modified dh_systemd_start snippet that's not added automatically if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true deb-systemd-invoke start mariadb.service >/dev/null || true # Modified dh_installinit snippet to only run with sysvinit elif [ -x "/etc/init.d/mariadb" ]; then if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then invoke-rc.d mariadb start || exit $? fi fi + '[' -d /run/systemd/system ']' + systemctl --system daemon-reload + deb-systemd-invoke start mariadb.service Setting up mariadb-server (1:10.5.4+maria~bionic) ... Setting up mariadb-plugin-rocksdb (1:10.5.4+maria~bionic) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... Processing triggers for ureadahead (0.100.0-21) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for systemd (237-3ubuntu10.41) ... Processing triggers for mariadb-server-10.5 (1:10.5.4+maria~bionic) ... + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.config configure /etc/mysql' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.config configure /etc/mysql 1>&2 # Beware that there are two ypwhich one of them needs the 2>/dev/null! if test -n "`which ypwhich 2>/dev/null`" && ypwhich >/dev/null 2>&1; then db_input high mariadb-server-10.0/nis_warning || true db_go fi ++ which ypwhich + test -n '' + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.postinst triggered /etc/mysql' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.postinst triggered /etc/mysql 1>&2 export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin + export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin:/usr/sbin:/bin:/usr/bin + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin:/usr/sbin:/bin:/usr/bin # This command can be used as pipe to syslog. With "-s" it also logs to stderr. ERR_LOGGER="logger -p daemon.err -t mariadb-server-$MAJOR_VER.postinst -i" + ERR_LOGGER='logger -p daemon.err -t mariadb-server-10.5.postinst -i' # Specify syslog tag name so it is clear the entry came from this postinst script. # This will make an error in a logged command immediately apparent by aborting # the install, rather than failing silently and leaving a broken install. set -o pipefail + set -o pipefail case "$1" in configure) # This is needed because mysql_install_db removes the pid file in /run # and because changed configuration options should take effect immediately. # In case the server wasn't running at all it should be ok if the stop # script fails. I can't tell at this point because of the cleaned /run. set +e; invoke-rc.d mariadb stop; set -e # An existing /etc/init.d/mysql might be on the system if there was a # previous MySQL or MariaDB installation, since /etc/init.d files are # considered config files and stay around even after the package is removed. # # The install step of this package adds a new /etc/init.d/mariadb file. As # we also want to ensure that there are no old (and potentially outdated) # versions of /etc/init.d/mysql we simply replace it using a copy of the # latest 'mariadb' file. This has also the added benefit that anything that # invokes traditional sysv init with either 'mysql' or 'mariadb' will end up # controlling this newly installed MariaDB, and thus we maintain better # backwards compatiblity. # # Note that the 'Provides' line is also updated to avoid 'insserv' exiting # on failure (when it is run by update-rc.d) because of duplicate service # names. if [ -f "/etc/init.d/mysql" ] && [ -f "/etc/init.d/mariadb" ] then # Copy init file and rename the service name and filename on the fly sed 's/Provides: mariadb/Provides: mysql/g' /etc/init.d/mariadb > /etc/init.d/mysql # NOTE: Number of spaces/tabs is important here! # Confirm if the sed worked if ! grep --quiet "Provides: mysql" /etc/init.d/mysql then # If not, then delete the file to avoid failures later on rm -f /etc/init.d/mysql echo "Warning! Failed creating a mysql named copy of mariadb init.d file" fi fi mysql_statedir=/usr/share/mysql mysql_datadir=/var/lib/mysql mysql_logdir=/var/log/mysql mysql_cfgdir=/etc/mysql mysql_upgradedir=/var/lib/mysql-upgrade # If the following symlink exists, it is a preserved copy the old data dir # created by the preinst script during a upgrade that would have otherwise # been replaced by an empty mysql dir. This should restore it. for dir in DATADIR LOGDIR; do if [ "$dir" = "DATADIR" ]; then targetdir=$mysql_datadir else targetdir=$mysql_logdir fi savelink="$mysql_upgradedir/$dir.link" if [ -L "$savelink" ]; then # If the targetdir was a symlink before we upgraded it is supposed # to be either still be present or not existing anymore now. if [ -L "$targetdir" ]; then rm "$savelink" elif [ ! -d "$targetdir" ]; then mv "$savelink" "$targetdir" else # this should never even happen, but just in case... mysql_tmp=$(mktemp -d -t mysql-symlink-restore-XXXXXX) echo "this is very strange! see $mysql_tmp/README..." >&2 mv "$targetdir" "$mysql_tmp" cat << EOF > "$mysql_tmp/README" If you're reading this, it's most likely because you had replaced /var/lib/mysql with a symlink, then upgraded to a new version of mysql, and then dpkg removed your symlink (see #182747 and others). The mysql packages noticed that this happened, and as a workaround have restored it. However, because /var/lib/mysql seems to have been re-created in the meantime, and because we don't want to rm -rf something we don't know as much about, we are going to leave this unexpected directory here. If your database looks normal, and this is not a symlink to your database, you should be able to blow this all away. EOF fi fi rmdir $mysql_upgradedir 2>/dev/null || true done # Ensure the existence and right permissions for the database and # log files. Use mkdir option 'Z' to create with correct SELinux context. if [ ! -d "$mysql_statedir" ] && [ ! -L "$mysql_statedir" ]; then mkdir -Z "$mysql_statedir"; fi if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ]; then mkdir -Z "$mysql_datadir" ; fi if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ]; then mkdir -Z "$mysql_logdir" ; fi # When creating an ext3 jounal on an already mounted filesystem like e.g. # /var/lib/mysql, you get a .journal file that is not modifyable by chown. # The mysql_statedir must not be writable by the mysql user under any # circumstances as it contains scripts that are executed by root. set +e chown -R 0:0 $mysql_statedir find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql chown -R mysql:adm $mysql_logdir chmod 2750 $mysql_logdir set -e ## Set the correct filesystem ownership for the PAM v2 plugin # eg. /usr/lib/x86_64-linux-gnu/mysql/plugin/auth_pam_tool_dir/ # NOTE! This is security sensitive, don't allow for a race condition. # # 1. Drop privileges of directory # -> At this point only root can see and execute auth_pam_tool chmod 0700 /usr/lib/mysql/plugin/auth_pam_tool_dir # # 2. Make binary setuid # -> At this point only root can run the setuid binary so no escalation here yet chmod 04755 /usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool # # 3. Allow user 'mysql' to see and execute auth_pam_tool # -> Now user mysql owns the directory and can see and execute the binary inside # -> Since the binary is setuid, user mysql gets limited root powers here to # run the PAM authetications, which need root (e.g. to validate passwords # against /etc/shadow) chown mysql /usr/lib/mysql/plugin/auth_pam_tool_dir # This is important to avoid dataloss when there is a removed # mysql-server version from Woody lying around which used the same # data directory and then somewhen gets purged by the admin. db_set mariadb-server/postrm_remove_database false || true # Clean up old flags before setting new one rm -f $mysql_datadir/debian-*.flag # Flag data dir to avoid downgrades touch "$mysql_datadir/debian-$MAJOR_VER.flag" # initiate databases. Output is not allowed by debconf :-( # This will fail if we are upgrading an existing database; in this case # mysql_upgrade, called from the /etc/init.d/mariadb start script, will # handle things. # Debian: beware of the bashisms... # Debian: can safely run on upgrades with existing databases set +e bash /usr/bin/mysql_install_db --rpm --cross-bootstrap --user=mysql \ --disable-log-bin --skip-test-db 2>&1 | \ $ERR_LOGGER set -e # To avoid downgrades. touch "$mysql_statedir/debian-$MAJOR_VER.flag" # On new installations root user can connect via unix_socket. # But on upgrades, scripts rely on debian-sys-maint user and # credentials in /etc/mysql/debian.cnf # All tools use --defaults-file=/etc/mysql/debian.cnf # And while it's not needed for new installations, we keep using # --defaults-file option for tools (for the sake of upgrades) # and thus need /etc/mysql/debian.cnf to exist, even if it's empty. dc=$mysql_cfgdir/debian.cnf; if [ ! -d "$mysql_cfgdir" ]; then install -o 0 -g 0 -m 0755 -d $mysql_cfgdir fi if [ ! -e "$dc" ]; then cat /dev/null > $dc echo "# Automatically generated for Debian scripts. DO NOT TOUCH!" >>$dc fi # Keep it only root-readable, as it always was chown 0:0 $dc chmod 0600 $dc # If there is a real AppArmor profile, we reload it. # If the default empty profile is installed, then we remove any old # profile that may be loaded. # This allows upgrade from old versions (that have an apparmor profile # on by default) to work both to disable a default profile, and to keep # any profile installed and maintained by users themselves. profile="/etc/apparmor.d/usr.sbin.mariadbd" if [ -f "$profile" ] && aa-status --enabled 2>/dev/null; then if grep -q /usr/sbin/mariadbd "$profile" 2>/dev/null ; then apparmor_parser -r "$profile" || true else echo "/usr/sbin/mariadbd { }" | apparmor_parser --remove 2>/dev/null || true fi fi # @TODO: Remove once buildbot.askmonty.org has been updated not to expect this file mkdir -p /etc/systemd/system/mariadb.service.d/ # Note that file cannot be empty, otherwise systemd version in Ubuntu Bionic # will think the service is masked echo "# empty placeholder" > /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf ;; abort-upgrade|abort-remove|abort-configure) ;; triggered) if [ -x "$(command -v systemctl)" ]; then systemctl daemon-reload else invoke-rc.d mariadb restart fi ;; *) echo "postinst called with unknown argument '$1'" 1>&2 exit 1 ;; esac + case "$1" in ++ command -v systemctl + '[' -x /bin/systemctl ']' + systemctl daemon-reload db_stop # in case invoke failes + db_stop + echo STOP # dh_systemd_start doesn't emit anything since we still ship /etc/init.d/mariadb. # Thus MariaDB server is started via init.d script, which in turn redirects to # systemctl. If we upgrade from MySQL mysql.service may be masked, which also # means init.d script is disabled. Unmask mysql service explicitly. # Check first that the command exists, to avoid emitting any warning messages. if [ -x "$(command -v deb-systemd-helper)" ]; then deb-systemd-helper unmask mysql.service > /dev/null fi ++ command -v deb-systemd-helper + '[' -x /usr/bin/deb-systemd-helper ']' + deb-systemd-helper unmask mysql.service # Automatically added by dh_systemd_enable/11.1.6ubuntu1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'mariadb.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'mariadb.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'mariadb.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'mariadb.service' >/dev/null || true fi fi + '[' triggered = configure ']' + '[' triggered = abort-upgrade ']' + '[' triggered = abort-deconfigure ']' + '[' triggered = abort-remove ']' # End automatically added section # Automatically added by dh_systemd_enable/11.1.6ubuntu1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if deb-systemd-helper debian-installed 'mariadb.service'; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'mariadb.service' >/dev/null || true if deb-systemd-helper --quiet was-enabled 'mariadb.service'; then # Create new symlinks, if any. deb-systemd-helper enable 'mariadb.service' >/dev/null || true fi fi # Update the statefile to add new symlinks (if any), which need to be cleaned # up on purge. Also remove old symlinks. deb-systemd-helper update-state 'mariadb.service' >/dev/null || true fi + '[' triggered = configure ']' + '[' triggered = abort-upgrade ']' + '[' triggered = abort-deconfigure ']' + '[' triggered = abort-remove ']' # End automatically added section # Automatically added by dh_installinit/11.1.6ubuntu1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -x "/etc/init.d/mariadb" ]; then update-rc.d mariadb defaults 19 21 >/dev/null || exit 1 fi fi + '[' triggered = configure ']' + '[' triggered = abort-upgrade ']' + '[' triggered = abort-deconfigure ']' + '[' triggered = abort-remove ']' # End automatically added section # Modified dh_systemd_start snippet that's not added automatically if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true deb-systemd-invoke start mariadb.service >/dev/null || true # Modified dh_installinit snippet to only run with sysvinit elif [ -x "/etc/init.d/mariadb" ]; then if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then invoke-rc.d mariadb start || exit $? fi fi + '[' -d /run/systemd/system ']' + systemctl --system daemon-reload + deb-systemd-invoke start mariadb.service