Skip to content

Commit 7679f5f

Browse files
committed
Merge branch 'mysql-5.5.52-release' into mysql-5.5.53-release
2 parents 0c6eac6 + 754e7ef commit 7679f5f

File tree

14 files changed

+258
-78
lines changed

14 files changed

+258
-78
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
@@ -83,6 +83,7 @@ typedef struct my_aio_result {
8383
#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
8484
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
8585
#define MY_REDEL_MAKE_BACKUP 256
86+
#define MY_REDEL_NO_COPY_STAT 512 /* my_redel() doesn't call my_copystat() */
8687
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
8788
#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */
8889
#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
@@ -137,7 +137,7 @@ start () {
137137
rc_failed 6 ; rc_status -v ; rc_exit
138138
fi
139139

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

scripts/mysqld_safe.sh

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

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

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

341334
if [ -z "$malloc_lib" ]; then
342-
log_error "no shared library for --malloc-lib=tcmalloc found in /usr/lib or $pkglibdir"
335+
log_error "no shared library for --malloc-lib=tcmalloc found in $malloc_dirs"
343336
exit 1
344337
fi
345338
fi
@@ -350,9 +343,21 @@ set_malloc_lib() {
350343
case "$malloc_lib" in
351344
/*)
352345
if [ ! -r "$malloc_lib" ]; then
353-
log_error "--malloc-lib '$malloc_lib' can not be read and will not be used"
346+
log_error "--malloc-lib can not be read and will not be used"
354347
exit 1
355348
fi
349+
350+
# Restrict to a the list in $malloc_dirs above
351+
case "`dirname "$malloc_lib"`" in
352+
/usr/lib) ;;
353+
/usr/lib64) ;;
354+
/usr/lib/i386-linux-gnu) ;;
355+
/usr/lib/x86_64-linux-gnu) ;;
356+
*)
357+
log_error "--malloc-lib must be located in one of the directories: $malloc_dirs"
358+
exit 1
359+
;;
360+
esac
356361
;;
357362
*)
358363
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: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,6 +2293,77 @@ bool MYSQL_LOG::init_and_set_log_file_name(const char *log_name,
22932293
}
22942294

22952295

2296+
bool is_valid_log_name(const char *name, size_t len)
2297+
{
2298+
if (len > 3)
2299+
{
2300+
const char *tail= name + len - 4;
2301+
if (my_strcasecmp(system_charset_info, tail, ".ini") == 0 ||
2302+
my_strcasecmp(system_charset_info, tail, ".cnf") == 0)
2303+
{
2304+
return false;
2305+
}
2306+
}
2307+
return true;
2308+
}
2309+
2310+
2311+
/**
2312+
Get the real log file name, and possibly reopen file.
2313+
2314+
Use realpath() to get the path with symbolic links
2315+
expanded. Then, close the file, and reopen the real path using the
2316+
O_NOFOLLOW flag. This will reject following symbolic links.
2317+
2318+
@param file File descriptor.
2319+
@param log_file_key Key for P_S instrumentation.
2320+
@param open_flags Flags to use for opening the file.
2321+
@param opened_file_name Name of the open fd.
2322+
2323+
@retval file descriptor to open file with 'real_file_name', or '-1'
2324+
in case of errors.
2325+
*/
2326+
2327+
#ifndef _WIN32
2328+
static File mysql_file_real_name_reopen(File file,
2329+
#ifdef HAVE_PSI_INTERFACE
2330+
PSI_file_key log_file_key,
2331+
#endif
2332+
int open_flags,
2333+
const char *opened_file_name)
2334+
{
2335+
DBUG_ASSERT(file);
2336+
DBUG_ASSERT(opened_file_name);
2337+
2338+
/* Buffer for realpath must have capacity for PATH_MAX. */
2339+
char real_file_name[PATH_MAX];
2340+
2341+
/* Get realpath, validate, open realpath with O_NOFOLLOW. */
2342+
if (realpath(opened_file_name, real_file_name) == NULL)
2343+
{
2344+
(void) mysql_file_close(file, MYF(0));
2345+
return -1;
2346+
}
2347+
2348+
if (mysql_file_close(file, MYF(0)))
2349+
return -1;
2350+
2351+
if (strlen(real_file_name) > FN_REFLEN)
2352+
return -1;
2353+
2354+
if (!is_valid_log_name(real_file_name, strlen(real_file_name)))
2355+
{
2356+
sql_print_error("Invalid log file name after expanding symlinks: '%s'",
2357+
real_file_name);
2358+
return -1;
2359+
}
2360+
2361+
return mysql_file_open(log_file_key, real_file_name,
2362+
open_flags | O_NOFOLLOW,
2363+
MYF(MY_WME | ME_WAITTANG));
2364+
}
2365+
#endif // _WIN32
2366+
22962367
/*
22972368
Open a (new) log file.
22982369
@@ -2358,8 +2429,22 @@ bool MYSQL_LOG::open(
23582429

23592430
if ((file= mysql_file_open(log_file_key,
23602431
log_file_name, open_flags,
2361-
MYF(MY_WME | ME_WAITTANG))) < 0 ||
2362-
init_io_cache(&log_file, file, IO_SIZE, io_cache_type,
2432+
MYF(MY_WME | ME_WAITTANG))) < 0)
2433+
goto err;
2434+
2435+
#ifndef _WIN32
2436+
/* Reopen and validate path. */
2437+
if ((log_type_arg == LOG_UNKNOWN || log_type_arg == LOG_NORMAL) &&
2438+
(file= mysql_file_real_name_reopen(file,
2439+
#ifdef HAVE_PSI_INTERFACE
2440+
log_file_key,
2441+
#endif
2442+
open_flags,
2443+
log_file_name)) < 0)
2444+
goto err;
2445+
#endif // _WIN32
2446+
2447+
if (init_io_cache(&log_file, file, IO_SIZE, io_cache_type,
23632448
mysql_file_tell(file, MYF(MY_WME)), 0,
23642449
MYF(MY_WME | MY_NABP |
23652450
((log_type == LOG_BIN) ? MY_WAIT_IF_FULL : 0))))

sql/log.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,16 @@ File open_binlog(IO_CACHE *log, const char *log_file_name,
717717

718718
char *make_log_name(char *buff, const char *name, const char* log_ext);
719719

720+
/**
721+
Check given log name against certain blacklisted names/extensions.
722+
723+
@param name Log name to check
724+
@param len Length of log name
725+
726+
@returns true if name is valid, false otherwise.
727+
*/
728+
bool is_valid_log_name(const char *name, size_t len);
729+
720730
extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log;
721731
extern LOGGER logger;
722732

sql/mysqld.cc

Lines changed: 17 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
1+
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights
22
reserved.
33
44
This program is free software; you can redistribute it and/or modify
@@ -3512,6 +3512,22 @@ static int init_common_variables()
35123512
"--log-slow-queries option, log tables are used. "
35133513
"To enable logging to files use the --log-output=file option.");
35143514

3515+
if (opt_logname &&
3516+
!is_valid_log_name(opt_logname, strlen(opt_logname)))
3517+
{
3518+
sql_print_error("Invalid value for --general_log_file: %s",
3519+
opt_logname);
3520+
return 1;
3521+
}
3522+
3523+
if (opt_slow_logname &&
3524+
!is_valid_log_name(opt_slow_logname, strlen(opt_slow_logname)))
3525+
{
3526+
sql_print_error("Invalid value for --slow_query_log_file: %s",
3527+
opt_slow_logname);
3528+
return 1;
3529+
}
3530+
35153531
#define FIX_LOG_VAR(VAR, ALT) \
35163532
if (!VAR || !*VAR) \
35173533
{ \

0 commit comments

Comments
 (0)