From b41525cef4171c7f3200afc41dca5e3837cbd2ec Mon Sep 17 00:00:00 2001 From: Michal Hrusecky Date: Thu, 13 Jan 2022 15:04:57 +0100 Subject: [PATCH 1/2] mariadb: Check and fix datadir owner issues during upgrade If you are migrating to MariaDB package, you might have old datadir stored somewhere using different setup with different users. If you trust us enough to enable autoupgrade, you probably trust us enough to chown your datadir as well. This can prevent some potential issues. Signed-off-by: Michal Hrusecky --- utils/mariadb/files/mysqld.init | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/mariadb/files/mysqld.init b/utils/mariadb/files/mysqld.init index f20697161..8fff379e1 100644 --- a/utils/mariadb/files/mysqld.init +++ b/utils/mariadb/files/mysqld.init @@ -152,6 +152,12 @@ start_service() { # Migration from old versions # shellcheck disable=SC2154 if [ "$(cat "$datadir"/.version 2> /dev/null)" \!= "$version" ] && [ "$autoupgrade" -gt 0 ]; then + # Check for correct owner + local owner="$(stat --format %U:%G "$datadir" 2> /dev/null)" + if [ -n "$owner" ] && [ "$owner" != "$my_user:$my_group" ]; then + chown -Rh "$my_user:$my_group" "$datadir" + fi + # Start upgrade instance without credentials sudo -u "$my_user" mysqld --skip-networking --skip-grant-tables --socket=/tmp/mysql_upgrade.sock & PID="$!" From 0ffec9bd4bf91118d33203d93d53b316b43115ce Mon Sep 17 00:00:00 2001 From: Michal Hrusecky Date: Thu, 13 Jan 2022 15:11:01 +0100 Subject: [PATCH 2/2] mariadb: Add sudo dependency During update we use sudo to start an instance. It probably could be workarounded, but given the MariaDB size, dependency on sudo shouldn't be an issue. Signed-off-by: Michal Hrusecky --- utils/mariadb/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/mariadb/Makefile b/utils/mariadb/Makefile index a0d1fa84b..31c61a42e 100644 --- a/utils/mariadb/Makefile +++ b/utils/mariadb/Makefile @@ -265,7 +265,8 @@ define Package/mariadb-server-base +KERNEL_IO_URING:liburing \ +liblzma \ +libpcre2 \ - +resolveip + +resolveip \ + +sudo TITLE:=MariaDB database server base USERID:=mariadb=376:mariadb=376 endef