From fc2775ee2fcb7a3da832cb509b89f065ac5b5d31 Mon Sep 17 00:00:00 2001 From: Michal Hrusecky Date: Thu, 25 Jun 2015 10:38:52 +0200 Subject: [PATCH 1/5] FEATURE Adds group option This patch let's you specify not only user to use but also group that MySQL should use. --- scripts/CMakeLists.txt | 1 + scripts/mysql_install_db.sh | 22 +++++++++++++++++++--- scripts/mysqld_safe.sh | 17 +++++++++++++++-- support-files/CMakeLists.txt | 1 + 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 3bda6d9..e69f690 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -203,6 +203,7 @@ ENDIF() SET(HOSTNAME "hostname") SET(MYSQLD_USER "mysql") +SET(MYSQLD_GROUP "mysql") ENDIF(UNIX) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 8af3d95..2ab0d37 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -28,6 +28,7 @@ args="" defaults="" mysqld_opt="" user="" +group="" force=0 in_rpm=0 @@ -68,6 +69,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. All other options are passed to the mysqld program @@ -108,11 +114,11 @@ parse_arguments() --builddir=*) builddir=`parse_arg "$arg"` ;; --srcdir=*) srcdir=`parse_arg "$arg"` ;; --ldata=*|--datadir=*) 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 ;; # Obsolete --rpm) in_rpm=1 ;; @@ -365,7 +371,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'" @@ -380,6 +391,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 afea5b3..f383abe 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -23,6 +23,7 @@ logging=init want_syslog=0 syslog_tag= user='@MYSQLD_USER@' +group='@MYSQLD_GROUP@' pid_file= err_log= @@ -196,6 +197,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 ;; # these might have been set in a [mysqld_safe] section of my.cnf # they are added to mysqld command line to override settings from my.cnf @@ -619,11 +621,17 @@ then if test "$user" != "root" -o $SET_USER = 1 then USER_OPTION="--user=$user" + GROUP_OPTION="--group=$group" fi # Change the err log to the right user, if it is in use if [ $want_syslog -eq 0 ]; then touch "$err_log" - chown $user "$err_log" + if [ "$user" -a "$group" ]; then + chown $user:$group $err_log + else + [ "$user" ] && chown $user $err_log + [ "$group" ] && chgrp $group $err_log + fi fi if test -n "$open_files" then @@ -642,7 +650,12 @@ mysql_unix_port_dir=`dirname $safe_mysql_unix_port` if [ ! -d $mysql_unix_port_dir ] then mkdir $mysql_unix_port_dir - 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 diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index 229547c..010820a 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -29,6 +29,7 @@ ELSE() SET(CFLAGS ${CMAKE_C_FLAGS}) SET(CXXFLAGS ${CMAKE_CXX_FLAGS}) SET(MYSQLD_USER "mysql") + SET(MYSQLD_GROUP "mysql") SET(ini_file_extension "cnf") SET(HOSTNAME "hostname") SET(CNF_SOCKET_LINE "# socket = .....") From a977bfa68d0c2b76d6e903a521585ae00926625d Mon Sep 17 00:00:00 2001 From: Michal Hrusecky Date: Thu, 25 Jun 2015 10:36:17 +0200 Subject: [PATCH 2/5] Fix linking options BUGS: upstream#39175, bnc#420313 --- scripts/mysql_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 7a63d10..96e4421 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -101,7 +101,7 @@ fi version='@VERSION@' socket='@MYSQL_UNIX_ADDR@' -ldflags='@LDFLAGS@' +ldflags='@SAVE_LDFLAGS@' if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then port=0 From 4f5ba3aff0702ca29b93f685243f819d5a8997c6 Mon Sep 17 00:00:00 2001 From: Michal Hrusecky Date: Thu, 25 Jun 2015 10:33:07 +0200 Subject: [PATCH 3/5] Rename srv_buf_size variable bug#70047 Variable was probably renamed sometime in the past but error was not triggered because ifdef was not satisfied. --- storage/innobase/row/row0log.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index eb707b6..84d11c4 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -2684,7 +2684,7 @@ row_log_table_apply_ops( and be ignored when the operation is unsupported. */ fallocate(index->online_log->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, - ofs, srv_buf_size); + ofs, srv_sort_buf_size); #endif /* FALLOC_FL_PUNCH_HOLE */ next_mrec = index->online_log->head.block; @@ -3521,7 +3521,7 @@ row_log_apply_ops( and be ignored when the operation is unsupported. */ fallocate(index->online_log->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, - ofs, srv_buf_size); + ofs, srv_sort_buf_size); #endif /* FALLOC_FL_PUNCH_HOLE */ next_mrec = index->online_log->head.block; From faf3c235f2722d852d2d4acfb915b64e68cc0d91 Mon Sep 17 00:00:00 2001 From: Michal Hrusecky Date: Thu, 25 Jun 2015 10:46:08 +0200 Subject: [PATCH 4/5] Keep datadir across multiple calls mysql_upgrade script asks for datadir multiple times during update but at some point privileges gets updated and if --skip-grant-tables was used (like in SUSE init scripts), datadir is no longer queryable. So we cache the value. --- client/upgrade/program.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/client/upgrade/program.cc b/client/upgrade/program.cc index 3dd3c77..a1bc72c 100644 --- a/client/upgrade/program.cc +++ b/client/upgrade/program.cc @@ -595,12 +595,14 @@ class Program : public Base::Abstract_connection_program */ int get_upgrade_info_file_name(char* name) { - string datadir; - int res= Show_variable_query_extractor::get_variable_value( - this->m_query_runner, "datadir", &datadir); - if (res != 0) - { - return res; + static string datadir; + if(datadir.empty()) { + int res= Show_variable_query_extractor::get_variable_value( + this->m_query_runner, "datadir", &datadir); + if (res != 0) + { + return res; + } } fn_format(name, "mysql_upgrade_info", datadir.c_str(), "", MYF(0)); From 2e9a7f69ac3c685684696a7a2dc26b17f3e5a606 Mon Sep 17 00:00:00 2001 From: Kristyna Streitova Date: Thu, 25 Jun 2015 10:18:10 +0200 Subject: [PATCH 5/5] Use CMAKE STATIC declaration where needed This prevents broken build with -DSHARED enforced on cmake command line --- libservices/CMakeLists.txt | 2 +- sql/CMakeLists.txt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt index c0bdadb..246ae7d 100644 --- a/libservices/CMakeLists.txt +++ b/libservices/CMakeLists.txt @@ -28,5 +28,5 @@ SET(MYSQLSERVICES_SOURCES rpl_transaction_ctx_service.c rpl_transaction_write_set_service.c) -ADD_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES}) +ADD_LIBRARY(mysqlservices STATIC ${MYSQLSERVICES_SOURCES}) INSTALL(TARGETS mysqlservices DESTINATION ${INSTALL_LIBDIR} COMPONENT Development) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 58a32cc..7feb6de 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -355,15 +355,15 @@ SET (BINLOG_SOURCE rpl_gtid_misc.cc log_event.cc log_event_old.cc binlog.cc sql_binlog.cc rpl_filter.cc rpl_record.cc rpl_record_old.cc rpl_utility.cc rpl_injector.cc rpl_table_access.cc) -ADD_LIBRARY(binlog ${BINLOG_SOURCE}) +ADD_LIBRARY(binlog STATIC ${BINLOG_SOURCE}) TARGET_LINK_LIBRARIES(binlog binlogevents_static) SET (RPL_SOURCE rpl_handler.cc rpl_tblmap.cc rpl_context.cc) ADD_DEPENDENCIES(binlog GenError) -ADD_LIBRARY(rpl ${RPL_SOURCE}) +ADD_LIBRARY(rpl STATIC ${RPL_SOURCE}) SET (MASTER_SOURCE rpl_master.cc rpl_binlog_sender.cc) ADD_DEPENDENCIES(rpl GenError) -ADD_LIBRARY(master ${MASTER_SOURCE}) +ADD_LIBRARY(master STATIC ${MASTER_SOURCE}) ADD_DEPENDENCIES(master GenError) SET (SLAVE_SOURCE rpl_slave.cc rpl_reporting.cc rpl_mi.cc rpl_rli.cc rpl_info_handler.cc rpl_info_file.cc @@ -372,7 +372,7 @@ SET (SLAVE_SOURCE rpl_slave.cc rpl_reporting.cc rpl_mi.cc rpl_rli.cc rpl_rli_pdb.cc rpl_info_dummy.cc rpl_mts_submode.cc rpl_slave_commit_order_manager.cc rpl_msr.cc rpl_trx_boundary_parser.cc rpl_channel_service_interface.cc) -ADD_LIBRARY(slave ${SLAVE_SOURCE}) +ADD_LIBRARY(slave STATIC ${SLAVE_SOURCE}) ADD_DEPENDENCIES(slave GenError) ######################### GUnit Lib #################################