Commit 4bd44185 authored by guilhem@mysql.com's avatar guilhem@mysql.com

Fix for BUG#4038 "rpm postinstall script leaves files as owned by root":

the rpm postinstall script must call mysql_install_db with --user=mysql,
and mysql_install_db must then pass this to mysqld. Otherwise, mysqld
runs as root, and if you have --log-bin=somewhere_out_of_var_lib_mysql
it creates binlog files owned by root in this dir, and this dir is not
fixed by the 'chmod mysql', so files remain owned by root, and later mysqld
(running as 'mysql') can't read them.
I'm hardcoding 'mysql' in the postinstall script, but it's already hardcoded
there in many places (see the useradd and chown) so it's ok.
parent 9799c5ba
......@@ -38,6 +38,9 @@ parse_arguments() {
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
# Note that this 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)
--skip-name-resolve) ip_only=1 ;;
--verbose) verbose=1 ;;
--rpm) in_rpm=1 ;;
......@@ -332,7 +335,8 @@ fi
echo "Installing all prepared tables"
if eval "$mysqld $defaults $mysqld_opt --bootstrap --skip-grant-tables \
--basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb $args" << END_OF_DATA
--basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb \
--user=$user $args" << END_OF_DATA
use mysql;
$c_d
$i_d
......
......@@ -395,7 +395,7 @@ useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" mysql 2> /dev/nul
chown -R mysql $mysql_datadir
# Initiate databases
mysql_install_db -IN-RPM
mysql_install_db -IN-RPM --user=mysql
# Change permissions again to fix any new files.
chown -R mysql $mysql_datadir
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment