Skip to content

Commit 6fce90e

Browse files
committed
Bug#25287707 THE PID-FILE VALUE IS IGNORED IN THE /ETC/MY.CNF OPTION FILE
In SysV initscripts for RPMS [mysqld] section was ignored for some options.
1 parent b7f33d2 commit 6fce90e

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

packaging/rpm-oel/mysql.init

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,29 @@ MYSQLD_OPTS=
3131
lockfile=/var/lock/subsys/$prog
3232

3333

34-
# extract value of a MySQL option from config files
35-
# Usage: get_mysql_option SECTION VARNAME DEFAULT
36-
# result is returned in $result
34+
# Extract value of a MySQL option from config files
35+
# Usage: get_mysql_option OPTION DEFAULT SECTION1 SECTION2 SECTIONN
36+
# Result is returned in $result
3737
# We use my_print_defaults which prints all options from multiple files,
3838
# with the more specific ones later; hence take the last match.
39-
get_mysql_option(){
40-
result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
41-
if [ -z "$result" ]; then
42-
# not found, use default
43-
result="$3"
44-
fi
39+
get_mysql_option () {
40+
option=$1
41+
default=$2
42+
shift 2
43+
result=$(/usr/bin/my_print_defaults "$@" | sed -n "s/^--${option}=//p" | tail -n 1)
44+
if [ -z "$result" ]; then
45+
# not found, use default
46+
result="${default}"
47+
fi
4548
}
4649

47-
get_mysql_option mysqld datadir "/var/lib/mysql"
50+
get_mysql_option datadir "/var/lib/mysql" mysqld
4851
datadir="$result"
49-
get_mysql_option mysqld socket "$datadir/mysql.sock"
52+
get_mysql_option socket "$datadir/mysql.sock" mysqld
5053
socketfile="$result"
51-
get_mysql_option mysqld_safe log-error "/var/log/mysqld.log"
54+
get_mysql_option log-error "/var/log/mysqld.log" mysqld mysqld_safe
5255
errlogfile="$result"
53-
get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid"
56+
get_mysql_option pid-file "/var/run/mysqld/mysqld.pid" mysqld mysqld_safe
5457
mypidfile="$result"
5558

5659
case $socketfile in

packaging/rpm-sles/mysql.init

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ PROG=/usr/bin/mysqld_safe
3838
lockfile=/var/lock/subsys/mysql
3939

4040
get_option () {
41-
local section=$1
42-
local option=$2
43-
local default=$3
44-
ret=$(/usr/bin/my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-)
45-
[ -z $ret ] && ret=$default
41+
local option=$1
42+
local default=$2
43+
shift 2
44+
ret=$(/usr/bin/my_print_defaults "$@" | sed -n "s/^--${option}=//p" | tail -n 1)
45+
[ -z $ret ] && ret=${default}
4646
echo $ret
4747
}
4848

49-
datadir=$(get_option mysqld datadir "/var/lib/mysql")
50-
socket=$(get_option mysqld socket "$datadir/mysql.sock")
51-
pidfile=$(get_option mysqld_safe pid-file "/var/run/mysql/mysqld.pid")
49+
datadir=$(get_option datadir "/var/lib/mysql" mysqld)
50+
socket=$(get_option socket "$datadir/mysql.sock" mysqld)
51+
pidfile=$(get_option pid-file "/var/run/mysql/mysqld.pid" mysqld mysqld_safe)
5252

5353
install_db () {
5454
# Note: something different than datadir=/var/lib/mysql requires
5555
# SELinux policy changes (in enforcing mode)
56-
datadir=$(get_option mysqld datadir "/var/lib/mysql")
57-
logfile=$(get_option mysqld_safe log-error "/var/log/mysql/mysqld.log")
56+
datadir=$(get_option datadir "/var/lib/mysql" mysqld)
57+
logfile=$(get_option log-error "/var/log/mysql/mysqld.log" mysqld mysqld_safe)
5858

5959
# Restore log, dir, perms and SELinux contexts
6060
if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then

0 commit comments

Comments
 (0)