From 173314eb8ff7fa708261b40011e0ec24265fb1c9 Mon Sep 17 00:00:00 2001 From: Michal Hrusecky Date: Thu, 1 Oct 2020 16:02:42 +0200 Subject: [PATCH 1/4] mariadb: Handle non-existent logger in init Make sure init script has a fallback when logger is not available. Signed-off-by: Michal Hrusecky --- utils/mariadb/files/mysqld.init | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/mariadb/files/mysqld.init b/utils/mariadb/files/mysqld.init index a1e6a44b1..717e8d68d 100644 --- a/utils/mariadb/files/mysqld.init +++ b/utils/mariadb/files/mysqld.init @@ -7,6 +7,7 @@ STOP=10 NAME=mysqld LOGGER="/usr/bin/logger -p user.err -s -t $NAME --" +[ -x "$LOGGER" ] || LOGGER="echo" MYSQLADMIN=/usr/bin/mysqladmin MYSQLD=/usr/bin/$NAME From bb6e0d799c2ec2694037a03c0d614391339f1996 Mon Sep 17 00:00:00 2001 From: Michal Hrusecky Date: Thu, 1 Oct 2020 16:10:10 +0200 Subject: [PATCH 2/4] mariadb: Use double quotes where possible Just to make sure, add double quotes around strings and various variables. In some cases it could prevent some issues, in other cases it is just a good practice. Signed-off-by: Michal Hrusecky --- utils/mariadb/files/mysqld.init | 68 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/utils/mariadb/files/mysqld.init b/utils/mariadb/files/mysqld.init index 717e8d68d..54fe53389 100644 --- a/utils/mariadb/files/mysqld.init +++ b/utils/mariadb/files/mysqld.init @@ -9,12 +9,12 @@ NAME=mysqld LOGGER="/usr/bin/logger -p user.err -s -t $NAME --" [ -x "$LOGGER" ] || LOGGER="echo" -MYSQLADMIN=/usr/bin/mysqladmin -MYSQLD=/usr/bin/$NAME -MYSQLDSAFE=/usr/bin/mysqld_safe +MYSQLADMIN="/usr/bin/mysqladmin" +MYSQLD="/usr/bin/$NAME" +MYSQLDSAFE="/usr/bin/mysqld_safe" # mysqladmin likes to read /root/.my.cnf which could cause issues. -export HOME=/etc/mysql +export HOME="/etc/mysql" # Safeguard (relative paths, core dumps...) cd / @@ -41,8 +41,8 @@ mysqld_status() { fi ps_alive=0 - pidfile=$(mysqld_get_param pid-file) - if [ -f "$pidfile" ] && kill -0 $(cat "$pidfile") >/dev/null 2>&1; then + pidfile="$(mysqld_get_param pid-file)" + if [ -f "$pidfile" ] && kill -0 "$(cat "$pidfile")" >/dev/null 2>&1; then ps_alive=1 fi @@ -63,85 +63,85 @@ start() { hint="please fix your server configuration in /etc/mysql/" - for i in $MYSQLD $MYSQLADMIN $MYSQLDSAFE; do - if [ ! -x $i ]; then - $LOGGER $i is missing + for i in "$MYSQLD" "$MYSQLADMIN" "$MYSQLDSAFE"; do + if [ ! -x "$i" ]; then + $LOGGER "$i is missing" exit 1 fi done - if [ ! -r $conf ]; then - $LOGGER $conf cannot be read + if [ ! -r "$conf" ]; then + $LOGGER "$conf cannot be read" exit 1 fi - config_load $NAME + config_load "$NAME" config_get_bool enabled general enabled 0 - if [ $enabled -eq 0 ]; then - $LOGGER service not enabled in /etc/config/$NAME + if [ "$enabled" -eq 0 ]; then + $LOGGER "service not enabled in /etc/config/$NAME" exit 1 fi config_get options general options - datadir=$(mysqld_get_param datadir) - tmpdir=$(mysqld_get_param tmpdir) + datadir="$(mysqld_get_param datadir)" + tmpdir="$(mysqld_get_param tmpdir)" if [ -z "$datadir" ]; then - $LOGGER datadir is not set - $LOGGER $hint + $LOGGER "datadir is not set" + $LOGGER "$hint" exit 1 fi if [ -z "$tmpdir" ]; then - $LOGGER tmpdir is not set - $LOGGER $hint + $LOGGER "tmpdir is not set" + $LOGGER "$hint" exit 1 fi if [ ! -f "$datadir/mysql/tables_priv.MAD" ]; then args="--force" - basedir=$(mysqld_get_param basedir) + basedir="$(mysqld_get_param basedir)" [ -n "$basedir" ] && args="$args --basedir=$basedir" - $LOGGER Cannot detect privileges table. You might need to run - $LOGGER \'mysql_install_db "$args"\' - $LOGGER to initialize the system tables. + $LOGGER "Cannot detect privileges table. You might need to run" + $LOGGER "'mysql_install_db \"$args\"'" + $LOGGER "to initialize the system tables." exit 1 fi # Start daemon if mysqld_status check_alive; then - $LOGGER already running + $LOGGER "server is already running" else - for i in $logdir $rundir; do + for i in "$logdir" "$rundir"; do opts="-m 0750" - if ! [ -e $i ]; then + if ! [ -e "$i" ]; then # $rundir needs to be accessible for # clients - if [ $i = $rundir ]; then + if [ "$i" = "$rundir" ]; then opts= fi - mkdir -p $opts $i - [ -d $i ] && chown mariadb:mariadb $i + mkdir -p $opts "$i" + [ -d "$i" ] && chown mariadb:mariadb "$i" fi done - $MYSQLDSAFE $options >/dev/null 2>&1 & + "$MYSQLDSAFE" $options >/dev/null 2>&1 & fi } stop() { if ! mysqld_status check_dead; then - $MYSQLADMIN shutdown + "$MYSQLADMIN" shutdown fi } reload() { if mysqld_status check_alive; then - $MYSQLADMIN reload + "$MYSQLADMIN" reload else - $LOGGER not running + $LOGGER "server is not running" fi } From c35bd3aa8e73a6a666a7afda42a0a9d6a20ef1a3 Mon Sep 17 00:00:00 2001 From: Michal Hrusecky Date: Fri, 2 Oct 2020 10:34:21 +0200 Subject: [PATCH 3/4] mariadb: Add shellcheck disable into init script On few places, shellcheck gets confused by how some OpenWrt functions work - especially load ones. Also on few places there are $options variables that need not to be globbed. Could be rewritten better not to need them, but I'll do major rewrites later in separate pull request. Signed-off-by: Michal Hrusecky --- utils/mariadb/files/mysqld.init | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/mariadb/files/mysqld.init b/utils/mariadb/files/mysqld.init index 54fe53389..3e3538907 100644 --- a/utils/mariadb/files/mysqld.init +++ b/utils/mariadb/files/mysqld.init @@ -1,7 +1,9 @@ #!/bin/sh /etc/rc.common # Copyright (C) 2010-2018 OpenWrt.org +# shellcheck disable=SC2034 START=95 +# shellcheck disable=SC2034 STOP=10 NAME=mysqld @@ -78,6 +80,7 @@ start() { config_load "$NAME" config_get_bool enabled general enabled 0 + # shellcheck disable=SC2154 if [ "$enabled" -eq 0 ]; then $LOGGER "service not enabled in /etc/config/$NAME" exit 1 @@ -123,11 +126,12 @@ start() { if [ "$i" = "$rundir" ]; then opts= fi + # shellcheck disable=SC2086 mkdir -p $opts "$i" [ -d "$i" ] && chown mariadb:mariadb "$i" fi done - + # shellcheck disable=SC2154,SC2086 "$MYSQLDSAFE" $options >/dev/null 2>&1 & fi } From 59a9d8dba8f10d43991f110522171b47443bdd68 Mon Sep 17 00:00:00 2001 From: Michal Hrusecky Date: Fri, 2 Oct 2020 09:55:16 +0200 Subject: [PATCH 4/4] mariadb: Update to version 10.4.14 Signed-off-by: Michal Hrusecky --- utils/mariadb/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/mariadb/Makefile b/utils/mariadb/Makefile index 8a4c13235..96b01fe2f 100644 --- a/utils/mariadb/Makefile +++ b/utils/mariadb/Makefile @@ -8,8 +8,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mariadb -PKG_VERSION:=10.4.13 -PKG_RELEASE:=3 +PKG_VERSION:=10.4.14 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL := \ @@ -18,7 +18,7 @@ PKG_SOURCE_URL := \ https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/$(PKG_NAME)-$(PKG_VERSION)/source \ https://downloads.mariadb.org/interstitial/$(PKG_NAME)-$(PKG_VERSION)/source -PKG_HASH:=45bbbb12d1de8febd9edf630e940c23cf14efd60570c743b268069516a5d91df +PKG_HASH:=f92fcd59e0122461482f28c67c5ea01c7cf6979494a571db68074396864c86fc PKG_MAINTAINER:=Michal Hrusecky PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=COPYING THIRDPARTY