Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
8fcdd6b0
Commit
8fcdd6b0
authored
Dec 20, 2016
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Numerous issues in mysqld_safe
parent
c8e49f2f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
128 additions
and
70 deletions
+128
-70
.gitignore
.gitignore
+1
-0
debian/dist/Debian/mariadb-server-5.5.files.in
debian/dist/Debian/mariadb-server-5.5.files.in
+1
-0
debian/dist/Ubuntu/mariadb-server-5.5.files.in
debian/dist/Ubuntu/mariadb-server-5.5.files.in
+1
-0
extra/CMakeLists.txt
extra/CMakeLists.txt
+3
-0
extra/mysqld_safe_helper.c
extra/mysqld_safe_helper.c
+77
-0
scripts/mysqld_safe.sh
scripts/mysqld_safe.sh
+44
-63
support-files/mysql.server.sh
support-files/mysql.server.sh
+1
-7
No files found.
.gitignore
View file @
8fcdd6b0
...
@@ -49,6 +49,7 @@ extra/jemalloc/build/
...
@@ -49,6 +49,7 @@ extra/jemalloc/build/
extra/jemalloc/tmp/
extra/jemalloc/tmp/
extra/my_print_defaults
extra/my_print_defaults
extra/mysql_waitpid
extra/mysql_waitpid
extra/mysqld_safe_helper
extra/perror
extra/perror
extra/replace
extra/replace
extra/resolve_stack_dump
extra/resolve_stack_dump
...
...
debian/dist/Debian/mariadb-server-5.5.files.in
View file @
8fcdd6b0
...
@@ -32,6 +32,7 @@ usr/bin/mysql_zap
...
@@ -32,6 +32,7 @@ usr/bin/mysql_zap
usr/bin/mysqlbinlog
usr/bin/mysqlbinlog
usr/bin/mysqld_multi
usr/bin/mysqld_multi
usr/bin/mysqld_safe
usr/bin/mysqld_safe
usr/bin/mysqld_safe_helper
usr/bin/mysqlhotcopy
usr/bin/mysqlhotcopy
usr/bin/perror
usr/bin/perror
usr/bin/replace
usr/bin/replace
...
...
debian/dist/Ubuntu/mariadb-server-5.5.files.in
View file @
8fcdd6b0
...
@@ -34,6 +34,7 @@ usr/bin/mysql_zap
...
@@ -34,6 +34,7 @@ usr/bin/mysql_zap
usr/bin/mysqlbinlog
usr/bin/mysqlbinlog
usr/bin/mysqld_multi
usr/bin/mysqld_multi
usr/bin/mysqld_safe
usr/bin/mysqld_safe
usr/bin/mysqld_safe_helper
usr/bin/mysqlhotcopy
usr/bin/mysqlhotcopy
usr/bin/perror
usr/bin/perror
usr/bin/replace
usr/bin/replace
...
...
extra/CMakeLists.txt
View file @
8fcdd6b0
...
@@ -82,4 +82,7 @@ IF(UNIX)
...
@@ -82,4 +82,7 @@ IF(UNIX)
MYSQL_ADD_EXECUTABLE
(
mysql_waitpid mysql_waitpid.c COMPONENT Client
)
MYSQL_ADD_EXECUTABLE
(
mysql_waitpid mysql_waitpid.c COMPONENT Client
)
TARGET_LINK_LIBRARIES
(
mysql_waitpid mysys
)
TARGET_LINK_LIBRARIES
(
mysql_waitpid mysys
)
MYSQL_ADD_EXECUTABLE
(
mysqld_safe_helper mysqld_safe_helper.c COMPONENT Server
)
TARGET_LINK_LIBRARIES
(
mysqld_safe_helper mysys
)
ENDIF
()
ENDIF
()
extra/mysqld_safe_helper.c
0 → 100644
View file @
8fcdd6b0
#include <my_global.h>
#include <m_string.h>
#include <my_sys.h>
#include <my_pthread.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include <stdlib.h>
#include <stdio.h>
void
my_exit
(
int
c
)
{
my_end
(
0
);
exit
(
c
);
}
void
do_usage
()
{
printf
(
"Usage:
\n
"
" %s <user> log <filename>
\n
"
" %s <user> exec <command> <args>
\n
"
,
my_progname
,
my_progname
);
my_exit
(
1
);
}
void
do_log
(
const
char
*
logfile
)
{
FILE
*
f
;
uchar
buf
[
4096
];
int
size
;
if
(
!
logfile
)
do_usage
();
f
=
my_fopen
(
logfile
,
O_WRONLY
|
O_APPEND
|
O_CREAT
,
MYF
(
MY_WME
));
if
(
!
f
)
my_exit
(
1
);
while
((
size
=
my_fread
(
stdin
,
buf
,
sizeof
(
buf
),
MYF
(
MY_WME
)))
>
0
)
if
((
int
)
my_fwrite
(
f
,
buf
,
size
,
MYF
(
MY_WME
))
!=
size
)
my_exit
(
1
);
my_fclose
(
f
,
MYF
(
0
));
my_exit
(
0
);
}
void
do_exec
(
char
*
args
[])
{
if
(
!
args
[
0
])
do_usage
();
my_end
(
0
);
execvp
(
args
[
0
],
args
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
passwd
*
user_info
;
MY_INIT
(
argv
[
0
]);
if
(
argc
<
3
)
do_usage
(
argv
[
0
]);
user_info
=
my_check_user
(
argv
[
1
],
MYF
(
0
));
if
(
user_info
?
my_set_user
(
argv
[
1
],
user_info
,
MYF
(
MY_WME
))
:
my_errno
==
EINVAL
)
my_exit
(
1
);
if
(
strcmp
(
argv
[
2
],
"log"
)
==
0
)
do_log
(
argv
[
3
]);
if
(
strcmp
(
argv
[
2
],
"exec"
)
==
0
)
do_exec
(
argv
+
3
);
my_end
(
0
);
return
1
;
}
scripts/mysqld_safe.sh
View file @
8fcdd6b0
...
@@ -20,6 +20,7 @@ mysqld_ld_preload=
...
@@ -20,6 +20,7 @@ mysqld_ld_preload=
mysqld_ld_library_path
=
mysqld_ld_library_path
=
flush_caches
=
0
flush_caches
=
0
numa_interleave
=
0
numa_interleave
=
0
unsafe_my_cnf
=
0
# Initial logging status: error log is not open, and not using syslog
# Initial logging status: error log is not open, and not using syslog
logging
=
init
logging
=
init
...
@@ -128,6 +129,18 @@ my_which ()
...
@@ -128,6 +129,18 @@ my_which ()
return
$ret
# Success
return
$ret
# Success
}
}
find_in_bin
()
{
if
test
-x
"
$MY_BASEDIR_VERSION
/bin/
$1
"
then
echo
"
$MY_BASEDIR_VERSION
/bin/
$1
"
elif
test
-x
"@bindir@/
$1
"
then
echo
"@bindir@/
$1
"
else
echo
"
$1
"
fi
}
log_generic
()
{
log_generic
()
{
priority
=
"
$1
"
priority
=
"
$1
"
shift
shift
...
@@ -136,7 +149,7 @@ log_generic () {
...
@@ -136,7 +149,7 @@ log_generic () {
echo
"
$msg
"
echo
"
$msg
"
case
$logging
in
case
$logging
in
init
)
;;
# Just echo the message, don't save it anywhere
init
)
;;
# Just echo the message, don't save it anywhere
file
)
echo
"
$msg
"
>>
"
$err_log
"
;;
file
)
echo
"
$msg
"
|
"
$helper
"
"
$user
"
log
"
$err_log
"
;;
syslog
)
logger
-t
"
$syslog_tag_mysqld_safe
"
-p
"
$priority
"
"
$*
"
;;
syslog
)
logger
-t
"
$syslog_tag_mysqld_safe
"
-p
"
$priority
"
"
$*
"
;;
*
)
*
)
echo
"Internal program error (non-fatal):"
\
echo
"Internal program error (non-fatal):"
\
...
@@ -156,7 +169,7 @@ log_notice () {
...
@@ -156,7 +169,7 @@ log_notice () {
eval_log_error
()
{
eval_log_error
()
{
cmd
=
"
$1
"
cmd
=
"
$1
"
case
$logging
in
case
$logging
in
file
)
cmd
=
"
$cmd
>> "
`
shell_quote_string
"
$err_log
"
`
" 2>&1"
;;
file
)
cmd
=
"
$cmd
2>&1 | "
`
shell_quote_string
"
$helper
"
`
"
$user
log "
`
shell_quote_string
"
$err_log
"
`
;;
syslog
)
syslog
)
# mysqld often prefixes its messages with a timestamp, which is
# mysqld often prefixes its messages with a timestamp, which is
# redundant when logging to syslog (which adds its own timestamp)
# redundant when logging to syslog (which adds its own timestamp)
...
@@ -190,6 +203,13 @@ shell_quote_string() {
...
@@ -190,6 +203,13 @@ shell_quote_string() {
echo
"
$1
"
|
sed
-e
's,\([^a-zA-Z0-9/_.=-]\),\\\1,g'
echo
"
$1
"
|
sed
-e
's,\([^a-zA-Z0-9/_.=-]\),\\\1,g'
}
}
check_executable_location
()
{
if
test
"
$unsafe_my_cnf
"
=
1
-a
"
$unrecognized_handling
"
!=
collect
;
then
log_error
"Cannot accept
$1
from a config file, when my.cnf is in the datadir"
exit
1
fi
}
parse_arguments
()
{
parse_arguments
()
{
for
arg
do
for
arg
do
# the parameter after "=", or the whole $arg if no match
# the parameter after "=", or the whole $arg if no match
...
@@ -200,7 +220,6 @@ parse_arguments() {
...
@@ -200,7 +220,6 @@ parse_arguments() {
optname_subst
=
`
echo
"
$optname
"
|
sed
's/_/-/g'
`
optname_subst
=
`
echo
"
$optname
"
|
sed
's/_/-/g'
`
arg
=
`
echo
$arg
|
sed
"s/^
$optname
/
$optname_subst
/"
`
arg
=
`
echo
$arg
|
sed
"s/^
$optname
/
$optname_subst
/"
`
case
"
$arg
"
in
case
"
$arg
"
in
--crash-script
=
*
)
CRASH_SCRIPT
=
"
$val
"
;;
# these get passed explicitly to mysqld
# these get passed explicitly to mysqld
--basedir
=
*
)
MY_BASEDIR_VERSION
=
"
$val
"
;;
--basedir
=
*
)
MY_BASEDIR_VERSION
=
"
$val
"
;;
--datadir
=
*
|
--data
=
*
)
DATADIR
=
"
$val
"
;;
--datadir
=
*
|
--data
=
*
)
DATADIR
=
"
$val
"
;;
...
@@ -220,12 +239,14 @@ parse_arguments() {
...
@@ -220,12 +239,14 @@ parse_arguments() {
# mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
# mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
--core-file-size
=
*
)
core_file_size
=
"
$val
"
;;
--core-file-size
=
*
)
core_file_size
=
"
$val
"
;;
--ledir
=
*
)
ledir
=
"
$val
"
;;
--ledir
=
*
)
check_executable_location
"
$arg
"
;
ledir
=
"
$val
"
;;
--malloc-lib
=
*
)
set_malloc_lib
"
$val
"
;;
--malloc-lib
=
*
)
check_executable_location
"
$arg
"
;
set_malloc_lib
"
$val
"
;;
--mysqld
=
*
)
MYSQLD
=
"
$val
"
;;
--crash-script
=
*
)
check_executable_location
"
$arg
"
;
crash_script
=
"
$val
"
;;
--mysqld
=
*
)
check_executable_location
"
$arg
"
;
MYSQLD
=
"
$val
"
;;
--mysqld-version
=
*
)
--mysqld-version
=
*
)
if
test
-n
"
$val
"
if
test
-n
"
$val
"
then
then
check_executable_location
"
$arg
"
MYSQLD
=
"mysqld-
$val
"
MYSQLD
=
"mysqld-
$val
"
PLUGIN_VARIANT
=
"/
$val
"
PLUGIN_VARIANT
=
"/
$val
"
else
else
...
@@ -385,15 +406,8 @@ set_malloc_lib() {
...
@@ -385,15 +406,8 @@ set_malloc_lib() {
# First, try to find BASEDIR and ledir (where mysqld is)
# First, try to find BASEDIR and ledir (where mysqld is)
#
#
if
echo
'@pkgdatadir@'
|
grep
'^@prefix@'
>
/dev/null
MY_PWD
=
`
dirname
$0
`
then
MY_PWD
=
`
cd
"
$MY_PWD
"
/..
&&
pwd
`
relpkgdata
=
`
echo
'@pkgdatadir@'
|
sed
-e
's,^@prefix@,,'
-e
's,^/,,'
-e
's,^,./,'
`
else
# pkgdatadir is not relative to prefix
relpkgdata
=
'@pkgdatadir@'
fi
MY_PWD
=
`
pwd
`
# Check for the directories we would expect from a binary release install
# Check for the directories we would expect from a binary release install
if
test
-n
"
$MY_BASEDIR_VERSION
"
-a
-d
"
$MY_BASEDIR_VERSION
"
if
test
-n
"
$MY_BASEDIR_VERSION
"
-a
-d
"
$MY_BASEDIR_VERSION
"
then
then
...
@@ -409,16 +423,16 @@ then
...
@@ -409,16 +423,16 @@ then
else
else
ledir
=
"
$MY_BASEDIR_VERSION
/bin"
ledir
=
"
$MY_BASEDIR_VERSION
/bin"
fi
fi
elif
test
-
f
"
$relpkgdata
"
/english/errmsg.sys
-a
-
x
"
$MY_PWD
/bin/mysqld"
elif
test
-x
"
$MY_PWD
/bin/mysqld"
then
then
MY_BASEDIR_VERSION
=
"
$MY_PWD
"
# Where bin, share and data are
MY_BASEDIR_VERSION
=
"
$MY_PWD
"
# Where bin, share and data are
ledir
=
"
$MY_PWD
/bin"
# Where mysqld is
ledir
=
"
$MY_PWD
/bin"
# Where mysqld is
# Check for the directories we would expect from a source install
# Check for the directories we would expect from a source install
elif
test
-
f
"
$relpkgdata
"
/english/errmsg.sys
-a
-
x
"
$MY_PWD
/libexec/mysqld"
elif
test
-x
"
$MY_PWD
/libexec/mysqld"
then
then
MY_BASEDIR_VERSION
=
"
$MY_PWD
"
# Where libexec, share and var are
MY_BASEDIR_VERSION
=
"
$MY_PWD
"
# Where libexec, share and var are
ledir
=
"
$MY_PWD
/libexec"
# Where mysqld is
ledir
=
"
$MY_PWD
/libexec"
# Where mysqld is
elif
test
-
f
"
$relpkgdata
"
/english/errmsg.sys
-a
-
x
"
$MY_PWD
/sbin/mysqld"
elif
test
-x
"
$MY_PWD
/sbin/mysqld"
then
then
MY_BASEDIR_VERSION
=
"
$MY_PWD
"
# Where sbin, share and var are
MY_BASEDIR_VERSION
=
"
$MY_PWD
"
# Where sbin, share and var are
ledir
=
"
$MY_PWD
/sbin"
# Where mysqld is
ledir
=
"
$MY_PWD
/sbin"
# Where mysqld is
...
@@ -428,6 +442,8 @@ else
...
@@ -428,6 +442,8 @@ else
ledir
=
'@libexecdir@'
ledir
=
'@libexecdir@'
fi
fi
helper
=
`
find_in_bin mysqld_safe_helper
`
print_defaults
=
`
find_in_bin my_print_defaults
`
#
#
# Second, try to find the data directory
# Second, try to find the data directory
...
@@ -465,6 +481,7 @@ IGNORING $DATADIR/my.cnf"
...
@@ -465,6 +481,7 @@ IGNORING $DATADIR/my.cnf"
log_error
"WARNING: Found
$DATADIR
/my.cnf
log_error
"WARNING: Found
$DATADIR
/my.cnf
The data directory is a deprecated location for my.cnf, please move it to
The data directory is a deprecated location for my.cnf, please move it to
$MY_BASEDIR_VERSION
/my.cnf"
$MY_BASEDIR_VERSION
/my.cnf"
unsafe_my_cnf
=
1
MYSQL_HOME
=
$DATADIR
MYSQL_HOME
=
$DATADIR
else
else
MYSQL_HOME
=
$MY_BASEDIR_VERSION
MYSQL_HOME
=
$MY_BASEDIR_VERSION
...
@@ -472,34 +489,15 @@ $MY_BASEDIR_VERSION/my.cnf"
...
@@ -472,34 +489,15 @@ $MY_BASEDIR_VERSION/my.cnf"
fi
fi
export
MYSQL_HOME
export
MYSQL_HOME
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
# and then merge with the command line arguments
if
test
-x
"
$MY_BASEDIR_VERSION
/bin/my_print_defaults"
then
print_defaults
=
"
$MY_BASEDIR_VERSION
/bin/my_print_defaults"
elif
test
-x
`
dirname
$0
`
/my_print_defaults
then
print_defaults
=
"
`
dirname
$0
`
/my_print_defaults"
elif
test
-x
./bin/my_print_defaults
then
print_defaults
=
"./bin/my_print_defaults"
elif
test
-x
@bindir@/my_print_defaults
then
print_defaults
=
"@bindir@/my_print_defaults"
elif
test
-x
@bindir@/mysql_print_defaults
then
print_defaults
=
"@bindir@/mysql_print_defaults"
else
print_defaults
=
"my_print_defaults"
fi
append_arg_to_args
()
{
append_arg_to_args
()
{
args
=
"
$args
"
`
shell_quote_string
"
$1
"
`
args
=
"
$args
"
`
shell_quote_string
"
$1
"
`
}
}
args
=
args
=
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
# and then merge with the command line arguments
SET_USER
=
2
SET_USER
=
2
parse_arguments
`
$print_defaults
$defaults
--loose-verbose
--mysqld
`
parse_arguments
`
$print_defaults
$defaults
--loose-verbose
--mysqld
`
if
test
$SET_USER
-eq
2
if
test
$SET_USER
-eq
2
...
@@ -603,11 +601,6 @@ then
...
@@ -603,11 +601,6 @@ then
log_notice
"Logging to '
$err_log
'."
log_notice
"Logging to '
$err_log
'."
logging
=
file
logging
=
file
if
[
!
-f
"
$err_log
"
]
;
then
# if error log already exists,
touch
"
$err_log
"
# we just append. otherwise,
chmod
"
$fmode
"
"
$err_log
"
# fix the permissions here!
fi
else
else
if
[
-n
"
$syslog_tag
"
]
if
[
-n
"
$syslog_tag
"
]
then
then
...
@@ -620,10 +613,6 @@ else
...
@@ -620,10 +613,6 @@ else
logging
=
syslog
logging
=
syslog
fi
fi
# close stdout and stderr, everything goes to $logging now
exec
1>&-
exec
2>&-
USER_OPTION
=
""
USER_OPTION
=
""
if
test
-w
/
-o
"
$USER
"
=
"root"
if
test
-w
/
-o
"
$USER
"
=
"root"
then
then
...
@@ -631,11 +620,6 @@ then
...
@@ -631,11 +620,6 @@ then
then
then
USER_OPTION
=
"--user=
$user
"
USER_OPTION
=
"--user=
$user
"
fi
fi
# Change the err log to the right user, if it is in use
if
[
$want_syslog
-eq
0
]
;
then
touch
"
$err_log
"
chown
$user
"
$err_log
"
fi
if
test
-n
"
$open_files
"
if
test
-n
"
$open_files
"
then
then
ulimit
-n
$open_files
ulimit
-n
$open_files
...
@@ -879,6 +863,10 @@ max_fast_restarts=5
...
@@ -879,6 +863,10 @@ max_fast_restarts=5
# flag whether a usable sleep command exists
# flag whether a usable sleep command exists
have_sleep
=
1
have_sleep
=
1
# close stdout and stderr, everything goes to $logging now
exec
1>&-
exec
2>&-
while
true
while
true
do
do
rm
-f
"
$pid_file
"
# Some extra safety
rm
-f
"
$pid_file
"
# Some extra safety
...
@@ -886,13 +874,6 @@ do
...
@@ -886,13 +874,6 @@ do
start_time
=
`
date
+%M%S
`
start_time
=
`
date
+%M%S
`
eval_log_error
"
$cmd
"
eval_log_error
"
$cmd
"
if
[
$want_syslog
-eq
0
-a
!
-f
"
$err_log
"
]
;
then
touch
"
$err_log
"
# hypothetical: log was renamed but not
chown
$user
"
$err_log
"
# flushed yet. we'd recreate it with
chmod
"
$fmode
"
"
$err_log
"
# wrong owner next time we log, so set
fi
# it up correctly while we can!
end_time
=
`
date
+%M%S
`
end_time
=
`
date
+%M%S
`
if
test
!
-f
"
$pid_file
"
# This is removed if normal shutdown
if
test
!
-f
"
$pid_file
"
# This is removed if normal shutdown
...
@@ -956,9 +937,9 @@ do
...
@@ -956,9 +937,9 @@ do
done
done
fi
fi
log_notice
"mysqld restarted"
log_notice
"mysqld restarted"
if
test
-n
"
$
CRASH_SCRIPT
"
if
test
-n
"
$
crash_script
"
then
then
crash_script_output
=
`
$
CRASH_SCRIPT
2>&1
`
crash_script_output
=
`
$
crash_script
2>&1
`
log_error
"
$crash_script_output
"
log_error
"
$crash_script_output
"
fi
fi
done
done
...
...
support-files/mysql.server.sh
View file @
8fcdd6b0
...
@@ -157,15 +157,9 @@ parse_server_arguments() {
...
@@ -157,15 +157,9 @@ parse_server_arguments() {
# Get arguments from the my.cnf file,
# Get arguments from the my.cnf file,
# the only group, which is read from now on is [mysqld]
# the only group, which is read from now on is [mysqld]
if
test
-x
./bin/my_print_defaults
if
test
-x
$bindir
/my_print_defaults
then
print_defaults
=
"./bin/my_print_defaults"
elif
test
-x
$bindir
/my_print_defaults
then
then
print_defaults
=
"
$bindir
/my_print_defaults"
print_defaults
=
"
$bindir
/my_print_defaults"
elif
test
-x
$bindir
/mysql_print_defaults
then
print_defaults
=
"
$bindir
/mysql_print_defaults"
else
else
# Try to find basedir in /etc/my.cnf
# Try to find basedir in /etc/my.cnf
conf
=
/etc/my.cnf
conf
=
/etc/my.cnf
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment