Skip to content

Commit 304519f

Browse files
committed
Merge branch 'mysql-5.5' into mysql-5.6
2 parents 90b2f9a + 1f93f43 commit 304519f

File tree

2 files changed

+92
-27
lines changed

2 files changed

+92
-27
lines changed

scripts/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 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
@@ -125,7 +125,13 @@ STRING(REPLACE "-grecord-gcc-switches" "" CXXFLAGS "${CXXFLAGS}")
125125
STRING(REPLACE "-pipe" "" CXXFLAGS "${CXXFLAGS}")
126126

127127
IF(UNIX)
128-
# FIND_PROC and CHECK_PID are used by mysqld_safe
128+
# SHELL_PATH, FIND_PROC, CHECK_PID are used by mysqld_safe
129+
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
130+
SET (SHELL_PATH "/bin/bash")
131+
ELSE()
132+
SET (SHELL_PATH "/bin/sh")
133+
ENDIF()
134+
129135
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
130136
SET (FIND_PROC
131137
"ps wwwp $PID | grep -v mysqld_safe | grep -- $MYSQLD > /dev/null")

scripts/mysqld_safe.sh

Lines changed: 84 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!@SHELL_PATH@
22
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
33
# This file is public domain and comes with NO WARRANTY of any kind
44
#
@@ -126,7 +126,13 @@ log_generic () {
126126
echo "$msg"
127127
case $logging in
128128
init) ;; # Just echo the message, don't save it anywhere
129-
file) echo "$msg" >> "$err_log" ;;
129+
file)
130+
if [ -w / -o "$USER" = "root" ]; then
131+
true
132+
else
133+
echo "$msg" >> "$err_log"
134+
fi
135+
;;
130136
syslog) logger -t "$syslog_tag_mysqld_safe" -p "$priority" "$*" ;;
131137
*)
132138
echo "Internal program error (non-fatal):" \
@@ -146,7 +152,13 @@ log_notice () {
146152
eval_log_error () {
147153
cmd="$1"
148154
case $logging in
149-
file) cmd="$cmd >> "`shell_quote_string "$err_log"`" 2>&1" ;;
155+
file)
156+
if [ -w / -o "$USER" = "root" ]; then
157+
cmd="$cmd > /dev/null 2>&1"
158+
else
159+
cmd="$cmd >> "`shell_quote_string "$err_log"`" 2>&1"
160+
fi
161+
;;
150162
syslog)
151163
# mysqld often prefixes its messages with a timestamp, which is
152164
# redundant when logging to syslog (which adds its own timestamp)
@@ -571,14 +583,7 @@ then
571583
fi
572584

573585
# Log to err_log file
574-
log_notice "Logging to '$err_log'."
575586
logging=file
576-
577-
if [ ! -f "$err_log" -a ! -h "$err_log" ]; then # if error log already exists,
578-
touch "$err_log" # we just append. otherwise,
579-
chmod "$fmode" "$err_log" # fix the permissions here!
580-
fi
581-
582587
else
583588
if [ -n "$syslog_tag" ]
584589
then
@@ -591,18 +596,55 @@ else
591596
logging=syslog
592597
fi
593598

599+
logdir=`dirname "$err_log"`
600+
# Change the err log to the right user, if possible and it is in use
601+
if [ $logging = "file" -o $logging = "both" ]; then
602+
if [ ! -f "$err_log" -a ! -h "$err_log" ]; then
603+
if test -w / -o "$USER" = "root"; then
604+
case $logdir in
605+
/var/log)
606+
(
607+
umask 0137
608+
set -o noclobber
609+
> "$err_log" && chown $user "$err_log"
610+
) ;;
611+
*) ;;
612+
esac
613+
else
614+
(
615+
umask 0137
616+
set -o noclobber
617+
> "$err_log"
618+
)
619+
fi
620+
fi
621+
622+
if [ -f "$err_log" ]; then # Log to err_log file
623+
log_notice "Logging to '$err_log'."
624+
elif [ "x$user" = "xroot" ]; then # running as root, mysqld can create log file; continue
625+
echo "Logging to '$err_log'." >&2
626+
else
627+
case $logdir in
628+
# We can't create $err_log, however mysqld can; continue
629+
/tmp|/var/tmp|/var/log/mysql|$DATADIR)
630+
echo "Logging to '$err_log'." >&2
631+
;;
632+
# We can't create $err_log and don't know if mysqld can; error out
633+
*)
634+
log_error "error: log-error set to '$err_log', however file don't exists. Create writable for user '$user'."
635+
exit 1
636+
;;
637+
esac
638+
fi
639+
fi
640+
594641
USER_OPTION=""
595642
if test -w / -o "$USER" = "root"
596643
then
597644
if test "$user" != "root" -o $SET_USER = 1
598645
then
599646
USER_OPTION="--user=$user"
600647
fi
601-
# Change the err log to the right user, if it is in use
602-
if [ $want_syslog -eq 0 -a ! -h "$err_log" ]; then
603-
touch "$err_log"
604-
chown $user "$err_log"
605-
fi
606648
if test -n "$open_files"
607649
then
608650
ulimit -n $open_files
@@ -615,15 +657,12 @@ then
615657
fi
616658

617659
safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}}
618-
# Make sure that directory for $safe_mysql_unix_port exists
660+
# Check that directory for $safe_mysql_unix_port exists
619661
mysql_unix_port_dir=`dirname $safe_mysql_unix_port`
620662
if [ ! -d $mysql_unix_port_dir ]
621663
then
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
664+
log_error "Directory '$mysql_unix_port_dir' for UNIX socket file don't exists."
665+
exit 1
627666
fi
628667

629668
# If the user doesn't specify a binary, we assume name "mysqld"
@@ -800,11 +839,31 @@ do
800839

801840
eval_log_error "$cmd"
802841

842+
# hypothetical: log was renamed but not
843+
# flushed yet. we'd recreate it with
844+
# wrong owner next time we log, so set
845+
# it up correctly while we can!
846+
803847
if [ $want_syslog -eq 0 -a ! -f "$err_log" -a ! -h "$err_log" ]; then
804-
touch "$err_log" # hypothetical: log was renamed but not
805-
chown $user "$err_log" # flushed yet. we'd recreate it with
806-
chmod "$fmode" "$err_log" # wrong owner next time we log, so set
807-
fi # it up correctly while we can!
848+
if test -w / -o "$USER" = "root"; then
849+
logdir=`dirname "$err_log"`
850+
case $logdir in
851+
/var/log)
852+
(
853+
umask 0137
854+
set -o noclobber
855+
> "$err_log" && chown $user "$err_log"
856+
) ;;
857+
*) ;;
858+
esac
859+
else
860+
(
861+
umask 0137
862+
set -o noclobber
863+
> "$err_log"
864+
)
865+
fi
866+
fi
808867

809868
end_time=`date +%M%S`
810869

0 commit comments

Comments
 (0)