Skip to content

Commit b4dad3f

Browse files
committed
Merge branch 'mysql-5.6.33-release' into mysql-5.6.34-release
2 parents 888c383 + 1235719 commit b4dad3f

File tree

14 files changed

+253
-74
lines changed

14 files changed

+253
-74
lines changed

include/my_sys.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -84,6 +84,7 @@ typedef struct my_aio_result {
8484
#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
8585
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
8686
#define MY_REDEL_MAKE_BACKUP 256
87+
#define MY_REDEL_NO_COPY_STAT 512 /* my_redel() doesn't call my_copystat() */
8788
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
8889
#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */
8990
#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */

include/myisam.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -426,12 +426,13 @@ int chk_size(MI_CHECK *param, MI_INFO *info);
426426
int chk_key(MI_CHECK *param, MI_INFO *info);
427427
int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend);
428428
int mi_repair(MI_CHECK *param, register MI_INFO *info,
429-
char * name, int rep_quick);
430-
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name);
429+
char * name, int rep_quick, my_bool no_copy_stat);
430+
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name,
431+
my_bool no_copy_stat);
431432
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
432-
const char * name, int rep_quick);
433+
const char * name, int rep_quick, my_bool no_copy_stat);
433434
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
434-
const char * name, int rep_quick);
435+
const char * name, int rep_quick, my_bool no_copy_stat);
435436
int change_to_newfile(const char * filename, const char * old_ext,
436437
const char * new_ext, myf myflags);
437438
int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type,

mysys/my_redel.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -35,6 +35,9 @@ struct utimbuf {
3535
3636
if MY_REDEL_MAKE_COPY is given, then the orginal file
3737
is renamed to org_name-'current_time'.BAK
38+
39+
if MY_REDEL_NO_COPY_STAT is given, stats are not copied
40+
from org_name to tmp_name.
3841
*/
3942

4043
#define REDEL_EXT ".BAK"
@@ -46,8 +49,11 @@ int my_redel(const char *org_name, const char *tmp_name, myf MyFlags)
4649
DBUG_PRINT("my",("org_name: '%s' tmp_name: '%s' MyFlags: %d",
4750
org_name,tmp_name,MyFlags));
4851

49-
if (my_copystat(org_name,tmp_name,MyFlags) < 0)
50-
goto end;
52+
if (!(MyFlags & MY_REDEL_NO_COPY_STAT))
53+
{
54+
if (my_copystat(org_name,tmp_name,MyFlags) < 0)
55+
goto end;
56+
}
5157
if (MyFlags & MY_REDEL_MAKE_BACKUP)
5258
{
5359
char name_buff[FN_REFLEN+20];

packaging/rpm-oel/mysql.init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ start(){
102102
# alarms, per bug #547485
103103
$exec --datadir="$datadir" --socket="$socketfile" \
104104
--pid-file="$mypidfile" \
105-
--basedir=/usr --user=mysql >/dev/null 2>&1 &
105+
--basedir=/usr --user=mysql >/dev/null &
106106
safe_pid=$!
107107
# Spin for a maximum of N seconds waiting for the server to come up;
108108
# exit the loop immediately if mysqld_safe process disappears.

packaging/rpm-sles/mysql.init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ start () {
153153
rc_failed 6 ; rc_status -v ; rc_exit
154154
fi
155155

156-
$PROG --basedir=/usr --datadir="$datadir" --pid-file="$pidfile" >/dev/null 2>&1 &
156+
$PROG --basedir=/usr --datadir="$datadir" --pid-file="$pidfile" >/dev/null &
157157
if pinger $! ; then
158158
echo -n "Starting service MySQL:"
159159
touch $lockfile

scripts/mysqld_safe.sh

Lines changed: 47 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,17 @@ parse_arguments() {
209209
--core-file-size=*) core_file_size="$val" ;;
210210
--ledir=*) ledir="$val" ;;
211211
--malloc-lib=*) set_malloc_lib "$val" ;;
212-
--mysqld=*) MYSQLD="$val" ;;
212+
--mysqld=*)
213+
if [ -z "$pick_args" ]; then
214+
log_error "--mysqld option can only be used as command line option, found in config file"
215+
exit 1
216+
fi
217+
MYSQLD="$val" ;;
213218
--mysqld-version=*)
219+
if [ -z "$pick_args" ]; then
220+
log_error "--mysqld-version option can only be used as command line option, found in config file"
221+
exit 1
222+
fi
214223
if test -n "$val"
215224
then
216225
MYSQLD="mysqld-$val"
@@ -298,38 +307,22 @@ mysqld_ld_preload_text() {
298307
echo "$text"
299308
}
300309

301-
302-
mysql_config=
303-
get_mysql_config() {
304-
if [ -z "$mysql_config" ]; then
305-
mysql_config=`echo "$0" | sed 's,/[^/][^/]*$,/mysql_config,'`
306-
if [ ! -x "$mysql_config" ]; then
307-
log_error "Can not run mysql_config $@ from '$mysql_config'"
308-
exit 1
309-
fi
310-
fi
311-
312-
"$mysql_config" "$@"
313-
}
314-
315-
316310
# set_malloc_lib LIB
317311
# - If LIB is empty, do nothing and return
318-
# - If LIB is 'tcmalloc', look for tcmalloc shared library in /usr/lib
319-
# then pkglibdir. tcmalloc is part of the Google perftools project.
312+
# - If LIB is 'tcmalloc', look for tcmalloc shared library in $malloc_dirs.
313+
# tcmalloc is part of the Google perftools project.
320314
# - If LIB is an absolute path, assume it is a malloc shared library
321315
#
322316
# Put LIB in mysqld_ld_preload, which will be added to LD_PRELOAD when
323317
# running mysqld. See ld.so for details.
324318
set_malloc_lib() {
319+
# This list is kept intentionally simple.
320+
malloc_dirs="/usr/lib /usr/lib64 /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu"
325321
malloc_lib="$1"
326322

327323
if [ "$malloc_lib" = tcmalloc ]; then
328-
pkglibdir=`get_mysql_config --variable=pkglibdir`
329324
malloc_lib=
330-
# This list is kept intentionally simple. Simply set --malloc-lib
331-
# to a full path if another location is desired.
332-
for libdir in /usr/lib "$pkglibdir" "$pkglibdir/mysql"; do
325+
for libdir in `echo $malloc_dirs`; do
333326
for flavor in _minimal '' _and_profiler _debug; do
334327
tmp="$libdir/libtcmalloc$flavor.so"
335328
#log_notice "DEBUG: Checking for malloc lib '$tmp'"
@@ -340,7 +333,7 @@ set_malloc_lib() {
340333
done
341334

342335
if [ -z "$malloc_lib" ]; then
343-
log_error "no shared library for --malloc-lib=tcmalloc found in /usr/lib or $pkglibdir"
336+
log_error "no shared library for --malloc-lib=tcmalloc found in $malloc_dirs"
344337
exit 1
345338
fi
346339
fi
@@ -351,9 +344,21 @@ set_malloc_lib() {
351344
case "$malloc_lib" in
352345
/*)
353346
if [ ! -r "$malloc_lib" ]; then
354-
log_error "--malloc-lib '$malloc_lib' can not be read and will not be used"
347+
log_error "--malloc-lib can not be read and will not be used"
355348
exit 1
356349
fi
350+
351+
# Restrict to a the list in $malloc_dirs above
352+
case "`dirname "$malloc_lib"`" in
353+
/usr/lib) ;;
354+
/usr/lib64) ;;
355+
/usr/lib/i386-linux-gnu) ;;
356+
/usr/lib/x86_64-linux-gnu) ;;
357+
*)
358+
log_error "--malloc-lib must be located in one of the directories: $malloc_dirs"
359+
exit 1
360+
;;
361+
esac
357362
;;
358363
*)
359364
log_error "--malloc-lib must be an absolute path or 'tcmalloc'; " \
@@ -569,7 +574,7 @@ then
569574
log_notice "Logging to '$err_log'."
570575
logging=file
571576

572-
if [ ! -f "$err_log" ]; then # if error log already exists,
577+
if [ ! -f "$err_log" -a ! -h "$err_log" ]; then # if error log already exists,
573578
touch "$err_log" # we just append. otherwise,
574579
chmod "$fmode" "$err_log" # fix the permissions here!
575580
fi
@@ -594,7 +599,7 @@ then
594599
USER_OPTION="--user=$user"
595600
fi
596601
# Change the err log to the right user, if it is in use
597-
if [ $want_syslog -eq 0 ]; then
602+
if [ $want_syslog -eq 0 -a ! -h "$err_log" ]; then
598603
touch "$err_log"
599604
chown $user "$err_log"
600605
fi
@@ -614,9 +619,11 @@ safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}}
614619
mysql_unix_port_dir=`dirname $safe_mysql_unix_port`
615620
if [ ! -d $mysql_unix_port_dir ]
616621
then
617-
mkdir $mysql_unix_port_dir
618-
chown $user $mysql_unix_port_dir
619-
chmod 755 $mysql_unix_port_dir
622+
if [ ! -h $mysql_unix_port_dir ]; then
623+
mkdir $mysql_unix_port_dir
624+
chown $user $mysql_unix_port_dir
625+
chmod 755 $mysql_unix_port_dir
626+
fi
620627
fi
621628

622629
# If the user doesn't specify a binary, we assume name "mysqld"
@@ -728,7 +735,9 @@ then
728735
exit 1
729736
fi
730737
fi
731-
rm -f "$pid_file"
738+
if [ ! -h "$pid_file" ]; then
739+
rm -f "$pid_file"
740+
fi
732741
if test -f "$pid_file"
733742
then
734743
log_error "Fatal error: Can't remove the pid file:
@@ -779,13 +788,19 @@ have_sleep=1
779788

780789
while true
781790
do
782-
rm -f $safe_mysql_unix_port "$pid_file" # Some extra safety
791+
# Some extra safety
792+
if [ ! -h "$safe_mysql_unix_port" ]; then
793+
rm -f "$safe_mysql_unix_port"
794+
fi
795+
if [ ! -h "$pid_file" ]; then
796+
rm -f "$pid_file"
797+
fi
783798

784799
start_time=`date +%M%S`
785800

786801
eval_log_error "$cmd"
787802

788-
if [ $want_syslog -eq 0 -a ! -f "$err_log" ]; then
803+
if [ $want_syslog -eq 0 -a ! -f "$err_log" -a ! -h "$err_log" ]; then
789804
touch "$err_log" # hypothetical: log was renamed but not
790805
chown $user "$err_log" # flushed yet. we'd recreate it with
791806
chmod "$fmode" "$err_log" # wrong owner next time we log, so set

sql/log.cc

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -1494,6 +1494,78 @@ bool MYSQL_LOG::init_and_set_log_file_name(const char *log_name,
14941494
}
14951495

14961496

1497+
bool is_valid_log_name(const char *name, size_t len)
1498+
{
1499+
if (len > 3)
1500+
{
1501+
const char *tail= name + len - 4;
1502+
if (my_strcasecmp(system_charset_info, tail, ".ini") == 0 ||
1503+
my_strcasecmp(system_charset_info, tail, ".cnf") == 0)
1504+
{
1505+
return false;
1506+
}
1507+
}
1508+
return true;
1509+
}
1510+
1511+
1512+
/**
1513+
Get the real log file name, and possibly reopen file.
1514+
1515+
Use realpath() to get the path with symbolic links
1516+
expanded. Then, close the file, and reopen the real path using the
1517+
O_NOFOLLOW flag. This will reject following symbolic links.
1518+
1519+
@param file File descriptor.
1520+
@param log_file_key Key for P_S instrumentation.
1521+
@param open_flags Flags to use for opening the file.
1522+
@param opened_file_name Name of the open fd.
1523+
1524+
@retval file descriptor to open file with 'real_file_name', or '-1'
1525+
in case of errors.
1526+
*/
1527+
1528+
#ifndef _WIN32
1529+
static File mysql_file_real_name_reopen(File file,
1530+
#ifdef HAVE_PSI_INTERFACE
1531+
PSI_file_key log_file_key,
1532+
#endif
1533+
int open_flags,
1534+
const char *opened_file_name)
1535+
{
1536+
DBUG_ASSERT(file);
1537+
DBUG_ASSERT(opened_file_name);
1538+
1539+
/* Buffer for realpath must have capacity for PATH_MAX. */
1540+
char real_file_name[PATH_MAX];
1541+
1542+
/* Get realpath, validate, open realpath with O_NOFOLLOW. */
1543+
if (realpath(opened_file_name, real_file_name) == NULL)
1544+
{
1545+
(void) mysql_file_close(file, MYF(0));
1546+
return -1;
1547+
}
1548+
1549+
if (mysql_file_close(file, MYF(0)))
1550+
return -1;
1551+
1552+
if (strlen(real_file_name) > FN_REFLEN)
1553+
return -1;
1554+
1555+
if (!is_valid_log_name(real_file_name, strlen(real_file_name)))
1556+
{
1557+
sql_print_error("Invalid log file name after expanding symlinks: '%s'",
1558+
real_file_name);
1559+
return -1;
1560+
}
1561+
1562+
return mysql_file_open(log_file_key, real_file_name,
1563+
open_flags | O_NOFOLLOW,
1564+
MYF(MY_WME | ME_WAITTANG));
1565+
}
1566+
#endif // _WIN32
1567+
1568+
14971569
/*
14981570
Open a (new) log file.
14991571
@@ -1564,6 +1636,18 @@ bool MYSQL_LOG::open(
15641636
MYF(MY_WME | ME_WAITTANG))) < 0)
15651637
goto err;
15661638

1639+
#ifndef _WIN32
1640+
/* Reopen and validate path. */
1641+
if ((log_type_arg == LOG_UNKNOWN || log_type_arg == LOG_NORMAL) &&
1642+
(file= mysql_file_real_name_reopen(file,
1643+
#ifdef HAVE_PSI_INTERFACE
1644+
log_file_key,
1645+
#endif
1646+
open_flags,
1647+
log_file_name)) < 0)
1648+
goto err;
1649+
#endif // _WIN32
1650+
15671651
if ((pos= mysql_file_tell(file, MYF(MY_WME))) == MY_FILEPOS_ERROR)
15681652
{
15691653
if (my_errno == ESPIPE)

sql/log.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -578,6 +578,16 @@ bool flush_error_log();
578578

579579
char *make_log_name(char *buff, const char *name, const char* log_ext);
580580

581+
/**
582+
Check given log name against certain blacklisted names/extensions.
583+
584+
@param name Log name to check
585+
@param len Length of log name
586+
587+
@returns true if name is valid, false otherwise.
588+
*/
589+
bool is_valid_log_name(const char *name, size_t len);
590+
581591
extern LOGGER logger;
582592

583593
#endif /* LOG_H */

sql/mysqld.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4111,6 +4111,22 @@ int init_common_variables()
41114111
if (!opt_slow_logname || !*opt_slow_logname)
41124112
opt_slow_logname= make_default_log_name(slow_logname_path, "-slow.log");
41134113

4114+
if (opt_logname &&
4115+
!is_valid_log_name(opt_logname, strlen(opt_logname)))
4116+
{
4117+
sql_print_error("Invalid value for --general_log_file: %s",
4118+
opt_logname);
4119+
return 1;
4120+
}
4121+
4122+
if (opt_slow_logname &&
4123+
!is_valid_log_name(opt_slow_logname, strlen(opt_slow_logname)))
4124+
{
4125+
sql_print_error("Invalid value for --slow_query_log_file: %s",
4126+
opt_slow_logname);
4127+
return 1;
4128+
}
4129+
41144130
#if defined(ENABLED_DEBUG_SYNC)
41154131
/* Initialize the debug sync facility. See debug_sync.cc. */
41164132
if (debug_sync_init())

0 commit comments

Comments
 (0)