[Pkg-mysql-commits] r927 - branches/sid-5.1/debian
Christian Hammers
ch at alioth.debian.org
Wed Aug 29 00:26:29 UTC 2007
Author: ch
Date: 2007-08-29 00:26:29 +0000 (Wed, 29 Aug 2007)
New Revision: 927
Modified:
branches/sid-5.1/debian/mysql-server-5.1.postinst
Log:
The root password setter was accidently dropped when merging with 5.0
Modified: branches/sid-5.1/debian/mysql-server-5.1.postinst
===================================================================
--- branches/sid-5.1/debian/mysql-server-5.1.postinst 2007-08-29 00:24:40 UTC (rev 926)
+++ branches/sid-5.1/debian/mysql-server-5.1.postinst 2007-08-29 00:26:29 UTC (rev 927)
@@ -18,6 +18,41 @@
fi
}
+MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables "
+
+test_mysql_access() {
+ mysql --no-defaults -u root -h localhost </dev/null >/dev/null 2>&1
+}
+
+# call with $1 = "online" to connect to the server, otherwise it bootstraps
+set_mysql_rootpw() {
+ # forget we ever saw the password. don't use reset to keep the seen status
+ db_set mysql-server/root_password ""
+
+ tfile=`mktemp`
+ if [ ! -f "$tfile" ]; then
+ return 1
+ fi
+
+ # this avoids us having to call "test" or "[" on $rootpw
+ cat << EOF > $tfile
+USE mysql;
+UPDATE user SET password=PASSWORD("$rootpw") WHERE user='root';
+FLUSH PRIVILEGES;
+EOF
+ if grep -q 'PASSWORD("")' $tfile; then
+ retval=0
+ elif [ "$1" = "online" ]; then
+ mysql --no-defaults -u root -h localhost <$tfile >/dev/null
+ retval=$?
+ else
+ $MYSQL_BOOTSTRAP <$tfile
+ retval=$?
+ fi
+ rm -f $tfile
+ return $retval
+}
+
# This is necessary because mysql_install_db removes the pid file in /var/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
@@ -96,7 +131,7 @@
# data directory and then somewhen gets purged by the admin.
db_set mysql-server/postrm_remove_database false || true
- # So that mysql-server (4.0) can check if it's safe to install.
+ # To avoid downgrades.
touch $mysql_statedir/debian-5.1.flag
# initiate databases. Output is not allowed by debconf :-(
@@ -145,13 +180,13 @@
echo "user = debian-sys-maint" >>$dc
echo "password = $pass" >>$dc
echo "socket = $mysql_rundir/mysqld.sock" >>$dc
+ echo "basedir = /usr" >>$dc
fi
# If this dir chmod go+w then the admin did it. But this file should not.
chown 0:0 $dc
chmod 0600 $dc
# update privilege tables
- MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables "
password_column_fix_query=`/bin/echo -e \
"USE mysql\n" \
"ALTER TABLE user CHANGE Password Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL"`;
@@ -200,7 +235,14 @@
"INSERT INTO plugin VALUES ('blackhole', 'ha_blackhole.so'); " \
"INSERT INTO plugin VALUES ('archive', 'ha_archive.so'); " `
+ # Upgrade password column format before the root password gets set.
echo "$password_column_fix_query" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
+
+ db_get mysql-server/root_password && rootpw="$RET"
+ if ! set_mysql_rootpw; then
+ password_error="yes"
+ fi
+
echo "$fix_privs" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
echo "$replace_query" | sed "s/__EXTRA_PRIVS__//" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
set +e
@@ -218,6 +260,28 @@
;;
esac
+# here we check to see if we can connect as root without a password
+# this should catch upgrades from previous versions where the root
+# password wasn't set. if there is a password, or if the connection
+# fails for any other reason, nothing happens.
+if [ "$1" = "configure" ]; then
+ if test_mysql_access; then
+ db_input medium mysql-server/root_password || true
+ db_go
+ db_get mysql-server/root_password && rootpw="$RET"
+
+ if ! set_mysql_rootpw "online"; then
+ password_error="yes"
+ fi
+ fi
+
+ if [ "$password_error" = "yes" ]; then
+ db_input high mysql-server/error_setting_password || true
+ db_go
+ fi
+
+fi
+
db_stop # in case invoke failes
#DEBHELPER#
More information about the Pkg-mysql-commits
mailing list