@@ -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.
323317set_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'; " \
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
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@}}
614619mysql_unix_port_dir=` dirname $safe_mysql_unix_port `
615620if [ ! -d $mysql_unix_port_dir ]
616621then
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
620627fi
621628
622629# If the user doesn't specify a binary, we assume name "mysqld"
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
780789while true
781790do
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
0 commit comments