From 161ce045a71e306768d4609bdc35788fa5ea2a71 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Tue, 8 Aug 2023 14:01:47 +0100 Subject: [PATCH] Revert "use environment file in systemd units for _WSREP_START_POSITION" This reverts commit 6c40590405da71a592a65b68e6b41b11437fb517. --- support-files/CMakeLists.txt | 2 -- support-files/mariadb.service.in | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index 7f49fca212b..4c1db775c19 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -32,8 +32,6 @@ ELSE() SET(MYSQLD_GROUP "mysql") SET(ini_file_extension "cnf") SET(HOSTNAME "uname -n") - get_filename_component(MYSQL_UNIX_DIR ${MYSQL_UNIX_ADDR} DIRECTORY) - SET(mysqlunixdir ${MYSQL_UNIX_DIR}) ENDIF() # XXX: shouldn't we just have variables for all this stuff and centralise diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in index 2f990df4a15..b7a55596029 100644 --- a/support-files/mariadb.service.in +++ b/support-files/mariadb.service.in @@ -70,20 +70,20 @@ ProtectSystem=full # Prevent accessing /home, /root and /run/user ProtectHome=true -# Use an environment file to pass variable _WSREP_START_POSITION -EnvironmentFile=-@mysqlunixdir@/wsrep-start-position +# Execute pre and post scripts as root, otherwise it does it as User= +PermissionsStartOnly=true @SYSTEMD_EXECSTARTPRE@ # Perform automatic wsrep recovery. When server is started without wsrep, # galera_recovery simply returns an empty string. In any case, however, # the script is not expected to return with a non-zero status. -# It is always safe to remove @mysqlunixdir@/wsrep-start-position -# environment file. +# It is always safe to unset _WSREP_START_POSITION environment variable. # Do not panic if galera_recovery script is not available. (MDEV-10538) +ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION" ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \ VAR=`cd @bindir@/..; @bindir@/galera_recovery`; [ $? -eq 0 ] \ - && echo _WSREP_START_POSITION=$VAR > @mysqlunixdir@/wsrep-start-position || exit 1" + && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1" # Needed to create system tables etc. # ExecStartPre=@scriptdir@/mysql_install_db -u mysql @@ -96,7 +96,7 @@ ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \ ExecStart=@sbindir@/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION # Unset _WSREP_START_POSITION environment variable. -ExecStartPost=/bin/rm -f @mysqlunixdir@/wsrep-start-position +ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION" @SYSTEMD_EXECSTARTPOST@