diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 929d8be678f7..66bc3e51fd41 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -583,21 +583,37 @@ static int extract_variable_from_show(DYNAMIC_STRING* ds, char* value) static int get_upgrade_info_file_name(char* name) { - DYNAMIC_STRING ds_datadir; - DBUG_ENTER("get_upgrade_info_file_name"); + static char *data_dir = NULL; + static size_t len; - if (init_dynamic_string(&ds_datadir, NULL, 32, 32)) - die("Out of memory"); + DBUG_ENTER("get_upgrade_info_file_name"); - if (run_query("show variables like 'datadir'", - &ds_datadir, FALSE) || - extract_variable_from_show(&ds_datadir, name)) + if(data_dir==NULL) { + DYNAMIC_STRING ds_datadir; + + if (init_dynamic_string(&ds_datadir, NULL, 32, 32)) + die("Out of memory"); + + if (run_query("show variables like 'datadir'", + &ds_datadir, FALSE) || + extract_variable_from_show(&ds_datadir, name) + ) + { + dynstr_free(&ds_datadir); + DBUG_RETURN(1); /* Query failed */ + } dynstr_free(&ds_datadir); - DBUG_RETURN(1); /* Query failed */ - } + len = strlen(name)+1; + if ((data_dir=(char*)malloc(sizeof(char)*len))==NULL) + { + die("Out of memory"); + } + strncpy(data_dir,name,len); - dynstr_free(&ds_datadir); + } else { + strncpy(name, data_dir, len); + } fn_format(name, "mysql_upgrade_info", name, "", MYF(0)); DBUG_PRINT("exit", ("name: %s", name)); @@ -1010,7 +1026,7 @@ int main(int argc, char **argv) Read the mysql_upgrade_info file to check if mysql_upgrade already has been run for this installation of MySQL */ - if (!opt_force && upgrade_already_done()) + if (upgrade_already_done() && !opt_force) { printf("This installation of MySQL is already upgraded to %s, " "use --force if you still need to run mysql_upgrade\n", @@ -1029,9 +1045,9 @@ int main(int argc, char **argv) */ if ((!opt_systables_only && (run_mysqlcheck_mysql_db_fixnames() || run_mysqlcheck_mysql_db_upgrade())) || - run_sql_fix_privilege_tables() || (!opt_systables_only && - (run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade()))) + (run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) + || run_sql_fix_privilege_tables()) { /* The upgrade failed to complete in some way or another, diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt index a247f2b3ce9f..82a86d004793 100644 --- a/libservices/CMakeLists.txt +++ b/libservices/CMakeLists.txt @@ -23,5 +23,5 @@ SET(MYSQLSERVICES_SOURCES my_thread_scheduler_service.c mysql_string_service.c) -ADD_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES}) +ADD_LIBRARY(mysqlservices STATIC ${MYSQLSERVICES_SOURCES}) INSTALL(TARGETS mysqlservices DESTINATION ${INSTALL_LIBDIR} COMPONENT Development) diff --git a/mysys/mf_loadpath.c b/mysys/mf_loadpath.c index 776435e0e752..c6def675c991 100644 --- a/mysys/mf_loadpath.c +++ b/mysys/mf_loadpath.c @@ -42,7 +42,7 @@ char * my_load_path(char * to, const char *path, if (is_cur) is_cur=2; /* Remove current dir */ if (! my_getwd(buff,(uint) (FN_REFLEN-strlen(path)+is_cur),MYF(0))) - (void) strncat(buff, path+is_cur, FN_REFLEN-1); + (void) strncat(buff, path+is_cur, FN_REFLEN-strlen(buff)-1); else (void) strnmov(buff, path, FN_REFLEN); /* Return org file name */ } diff --git a/regex/regcomp.c b/regex/regcomp.c index 6fdaf4507ab5..a726e022697a 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -138,7 +138,15 @@ const CHARSET_INFO *charset; (NC-1)*sizeof(cat_t)); if (g == NULL) return(MY_REG_ESPACE); - p->ssize = (long) (len/(size_t)2*(size_t)3 + (size_t)1); /* ugh */ + { + /* Patched for CERT Vulnerability Note VU#695940, Feb 2015. */ + size_t new_ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */ + if (new_ssize < len || new_ssize > LONG_MAX / sizeof(sop)) { + free((char *) g); + return MY_REG_INVARG; + } + p->ssize = (long) new_ssize; + } p->strip = (sop *)malloc(p->ssize * sizeof(sop)); p->slen = 0; if (p->strip == NULL) { diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index eebe0b3da5ef..94c0df3a073f 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -161,6 +161,7 @@ ENDIF() SET(HOSTNAME "hostname") SET(MYSQLD_USER "mysql") +SET(MYSQLD_GROUP "mysql") # Required for mysqlbug until autotools are deprecated, once done remove these # and expand default cmake variables diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 0ab07ebc7a68..9b117dd24513 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 diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index b474adf27b69..2ff27946b8d5 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 3af188580071..6255756fe2ae 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= @@ -198,6 +199,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 @@ -592,11 +594,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 @@ -615,7 +623,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/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index ffedc049e953..69ffb4615d6b 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -845,7 +845,24 @@ sub get_list_of_tables { } || []; warn "Unable to retrieve list of tables in $db: $@" if $@; - return (map { $_->[0] } @$tables); + my @ignore_tables = (); + + # Ignore tables for the mysql database + if ($db eq 'mysql') { + @ignore_tables = qw(general_log slow_log schema apply_status); + } + + my @res = (); + if ($#ignore_tables > 1) { + my @tmp = (map { $_->[0] } @$tables); + for my $t (@tmp) { + push(@res, $t) if not exists { map { $_=>1 } @ignore_tables }->{$t}; + } + } else { + @res = (map { $_->[0] } @$tables); + } + + return @res; } sub get_list_of_views { diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index e88c6c01cb23..3e0974411108 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -245,20 +245,20 @@ SET (BINLOG_SOURCE uuid.cc 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) -ADD_LIBRARY(binlog ${BINLOG_SOURCE}) +ADD_LIBRARY(binlog STATIC ${BINLOG_SOURCE}) SET (RPL_SOURCE rpl_handler.cc rpl_tblmap.cc) ADD_DEPENDENCIES(binlog GenError) -ADD_LIBRARY(rpl ${RPL_SOURCE}) +ADD_LIBRARY(rpl STATIC ${RPL_SOURCE}) SET (MASTER_SOURCE rpl_master.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 rpl_info_table.cc rpl_info_values.cc rpl_info.cc rpl_info_factory.cc rpl_info_table_access.cc dynamic_ids.cc rpl_rli_pdb.cc rpl_info_dummy.cc) -ADD_LIBRARY(slave ${SLAVE_SOURCE}) +ADD_LIBRARY(slave STATIC ${SLAVE_SOURCE}) ADD_DEPENDENCIES(slave GenError) ADD_LIBRARY(sqlgunitlib filesort_utils.cc mdl.cc sql_list.cc sql_string.cc thr_malloc.cc diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index f88baa42d587..b356b17bcf52 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -2583,7 +2583,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; @@ -3411,7 +3411,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; diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index 5afe26132957..26b52ed22ef3 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 = .....")