List:Commits« Previous MessageNext Message »
From:Joerg Bruehe Date:June 20 2006 10:40pm
Subject:bk commit into 5.0 tree (joerg:1.2191) BUG#18516
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of joerg. When joerg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2191 06/06/20 22:40:46 joerg@stripped +2 -0
  Fix for bug#18516 (also #19353, reported for 5.1):
  In addition to include "mysql_upgrade" in a RPM, it should also be called
  when the RPM is upgraded.

  support-files/mysql.spec.sh
    1.140 06/06/20 22:40:40 joerg@stripped +15 -1
    Call "mysql_upgrade" during an RPM upgrade.
    
    "mysql_upgrade" needs a server to run, as it issues SQL commands.
    (This had been neglected previously.)
    It also needs to connect as "root", but in an RPM upgrade the password is unknown.
    To allow this, the server is started "--skip-grant-tables".
    Normally, this would open big security holes, so it is also started
"--skip-networking",
    and access to the socket is limited to "mysql" + "root" by temporarily setting mode
700.

  support-files/mysql.server.sh
    1.51 06/06/20 22:40:40 joerg@stripped +14 -4
    Support getting additional arguments, which need to be passed on to the server.
    This works only if the server is started through "mysqld_safe", as the IM will not
pass such arguments.
    So if the IM would be used, additional arguments cause the start to fail
(voluntarily).
    
    This feature is needed so that tools like RPM can start the server in an "isolated"
way,
    see the patch to the RPM spec file (also in this changeset) to call "mysql_upgrade".

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	joerg
# Host:	trift2.
# Root:	/M50/bug19353-5.0

--- 1.50/support-files/mysql.server.sh	2006-06-14 18:13:34 +02:00
+++ 1.51/support-files/mysql.server.sh	2006-06-20 22:40:40 +02:00
@@ -98,6 +98,11 @@
 export PATH
 
 mode=$1    # start or stop
+shift
+other_args="$*"   # uncommon, but needed when called from an RPM upgrade action
+           # Expected: "--skip-networking --skip-grant-tables"
+           # They are not checked here, intentionally, as it is the resposibility
+           # of the "spec" file author to give correct arguments only.
 
 case `echo "testing\c"`,`echo -n testing` in
     *c*,-n*) echo_n=   echo_c=     ;;
@@ -264,6 +269,11 @@
     echo $echo_n "Starting MySQL"
     if test -x $manager -a "$use_mysqld_safe" = "0"
     then
+      if test -n "$other_args"
+      then
+        log_failure_msg "MySQL manager does not support options '$other_args'"
+        exit 1
+      fi
       # Give extra arguments to mysqld with the my.cnf file. This script may
       # be overwritten at next upgrade.
       $manager --user=$user --pid-file=$pid_file >/dev/null 2>&1 &
@@ -279,7 +289,7 @@
       # Give extra arguments to mysqld with the my.cnf file. This script
       # may be overwritten at next upgrade.
       pid_file=$server_pid_file
-      $bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file >/dev/null
2>&1 &
+      $bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args
>/dev/null 2>&1 &
       wait_for_pid created
 
       # Make lock for RedHat / SuSE
@@ -327,8 +337,8 @@
   'restart')
     # Stop the service and regardless of whether it was
     # running or not, start it again.
-    $0 stop
-    $0 start
+    $0 stop  $other_args
+    $0 start $other_args
     ;;
 
   'reload')
@@ -343,7 +353,7 @@
 
   *)
     # usage
-    echo "Usage: $0 start|stop|restart|reload"
+    echo "Usage: $0  {start|stop|restart|reload}  [ MySQL server options ]"
     exit 1
     ;;
 esac

--- 1.139/support-files/mysql.spec.sh	2006-05-21 00:46:42 +02:00
+++ 1.140/support-files/mysql.spec.sh	2006-06-20 22:40:40 +02:00
@@ -485,7 +485,16 @@
 %{_bindir}/mysql_install_db --rpm --user=%{mysqld_user}
 
 # Upgrade databases if needed
-%{_bindir}/mysql_upgrade --user=%{mysqld_user}
+# This must be done as database user "root", who should be password-protected,
+# but this password is not available here.
+# So ensure the server is isolated as much as possible, and start it so that
+# passwords are not checked.
+# See the related change in the start script "/etc/init.d/mysql".
+chmod 700 $mysql_datadir
+%{_sysconfdir}/init.d/mysql start --skip-networking --skip-grant-tables
+%{_bindir}/mysql_upgrade
+%{_sysconfdir}/init.d/mysql stop  --skip-networking --skip-grant-tables
+chmod 755 $mysql_datadir
 
 # Change permissions again to fix any new files.
 chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
@@ -723,6 +732,11 @@
 # itself - note that they must be ordered by date (important when
 # merging BK trees)
 %changelog 
+* Tue Jun 20 2006 Joerg Bruehe <joerg@stripped>
+
+- To run "mysql_upgrade", we need a running server;
+  start it in isolation and skip password checks.
+
 * Sat May 20 2006 Kent Boortz <kent@stripped>
 
 - Always compile for PIC, position independent code.
Thread
bk commit into 5.0 tree (joerg:1.2191) BUG#18516Joerg Bruehe20 Jun