summaryrefslogtreecommitdiff
path: root/scripts/mysqld_safe.sh
diff options
context:
space:
mode:
authorOtto Kekäläinen <otto@kekalainen.net>2020-04-21 21:14:54 +0300
committerJan Lindström <jan.lindstrom@mariadb.com>2020-04-22 07:54:52 +0300
commitefa3b3de35c7c57e30e45c3963d7bb1fbd57f499 (patch)
tree78a9b3a87c995ab4d5169f8a6dbe06c00e00d37f /scripts/mysqld_safe.sh
parenta6a8774d47a4598f9fcff9d96602a9a550b85feb (diff)
downloadmariadb-git-efa3b3de35c7c57e30e45c3963d7bb1fbd57f499.tar.gz
MDEV-22159: Don't redirect as root to a tmp file not owned by root
Also add a check for tmp file being empty and bail out with a clear error message in such a case, as mysqld_safe prevents normal stderr from being displayed anywhere and would fail silently on this.
Diffstat (limited to 'scripts/mysqld_safe.sh')
-rw-r--r--scripts/mysqld_safe.sh9
1 files changed, 8 insertions, 1 deletions
diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh
index 290f43e9e84..07fa304a4cf 100644
--- a/scripts/mysqld_safe.sh
+++ b/scripts/mysqld_safe.sh
@@ -263,7 +263,9 @@ wsrep_recover_position() {
fi
if [ -f $wr_logfile ]; then
- [ "$euid" = "0" ] && chown $user $wr_logfile
+ # NOTE! Do not change ownership of the temporary file, as on newer kernel
+ # versions fs.protected_regular is set to '2' and redirecting output with >
+ # as root to a file not owned by root will fail with "Permission denied"
chmod 600 $wr_logfile
else
log_error "WSREP: mktemp failed"
@@ -278,6 +280,11 @@ wsrep_recover_position() {
eval "$mysqld_cmd --wsrep_recover $wr_options 2> $wr_logfile"
+ if [ ! -s "$wr_logfile" ]; then
+ log_error "Log file $wr_logfile was empty, cannot proceed. Is system running fs.protected_regular?"
+ exit 1
+ fi
+
local rp="$(grep 'WSREP: Recovered position:' $wr_logfile)"
if [ -z "$rp" ]; then
local skipped="$(grep WSREP $wr_logfile | grep 'skipping position recovery')"