Skip to content

Commit f1aaa75

Browse files
committed
MDEV-15502 debian: systemd, with tmpfiles install not required
With PermissionsStartOnly deprecated, remove this from the systemd service file. Replace Debian's ExecStartPre "install -d" with a tmpfile configuration directive creating the directory with this. Debian's ExecStartPost of the mariadb upgrade uses the ! special executable prefix added in systemd v231 to use root privs.
1 parent 649216e commit f1aaa75

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

cmake/systemd.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ MACRO(CHECK_SYSTEMD)
5050
SET(SYSTEMD_SCRIPTS ${SYSTEMD_SCRIPTS} galera_new_cluster galera_recovery)
5151
ENDIF()
5252
IF(DEB)
53-
SET(SYSTEMD_EXECSTARTPRE "ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld")
54-
SET(SYSTEMD_EXECSTARTPOST "ExecStartPost=/etc/mysql/debian-start")
53+
SET(SYSTEMD_EXECSTARTPOST "ExecStartPost=!/etc/mysql/debian-start")
5554
ENDIF()
5655
IF(URING_FOUND)
5756
SET(SYSTEMD_LIMIT "# For liburing and io_uring_setup()

debian/mariadb-server.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ lib/systemd/system/mariadb@.socket
1616
lib/systemd/system/mysql.service
1717
lib/systemd/system/mysqld.service
1818
support-files/rpm/enable_encryption.preset etc/mysql/mariadb.conf.d/99-enable-encryption.cnf.preset
19+
usr/lib/tmpfiles.d/mariadb.conf
1920
usr/bin/aria_chk
2021
usr/bin/aria_dump_log
2122
usr/bin/aria_ftdump

debian/not-installed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ usr/bin/uca-dump
2424
usr/bin/wsrep_sst_backup
2525
usr/lib/mysql/plugin/type_test.so
2626
usr/lib/sysusers.d/mariadb.conf # Not used (yet) in Debian systemd
27-
usr/lib/tmpfiles.d/mariadb.conf # Not used (yet) in Debian systemd
2827
usr/sbin/rcmysql
2928
usr/share/doc/mariadb-server/COPYING (related file: "debian/tmp/usr/share/mysql/mroonga/COPYING")
3029
usr/share/doc/mariadb-server/CREDITS

support-files/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,15 @@ IF(UNIX AND NOT WITHOUT_SERVER)
210210
RENAME mariadb.conf COMPONENT Server)
211211
ENDIF()
212212

213-
IF((HAVE_SYSTEMD OR INSTALL_SYSTEMD_TMPUSERS) AND INSTALL_SYSTEMD_TMPFILESDIR
214-
AND INSTALL_RUNDATADIR)
213+
IF((HAVE_SYSTEMD OR INSTALL_SYSTEMD_TMPUSERS) AND INSTALL_SYSTEMD_TMPFILESDIR)
215214
IF(MYSQL_DATADIR STREQUAL INSTALL_RUNDATADIR)
216-
SET(DISABLE_TMP "#")
215+
SET(DISABLE_RUNDATADIR "#")
217216
ENDIF()
217+
get_filename_component(MYSQL_UNIX_ADDRDIR ${MYSQL_UNIX_ADDR} DIRECTORY)
218+
IF(MYSQL_UNIX_ADDRDIR STREQUAL MYSQL_DATADIR OR MYSQL_UNIX_ADDRDIR STREQUAL INSTALL_RUNDATADIR)
219+
SET(DISABLE_MYSQL_UNIX_ADDRDIR "#")
220+
ENDIF()
221+
218222
CONFIGURE_FILE(tmpfiles.conf.in
219223
${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf @ONLY)
220224
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf

support-files/mariadb.service.in

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,12 @@ ProtectSystem=full
6262
# Prevent accessing /home, /root and /run/user
6363
ProtectHome=true
6464

65-
# Execute pre and post scripts as root, otherwise it does it as User=
66-
PermissionsStartOnly=true
67-
6865
# Use an environment file to pass variable _WSREP_NEW_CLUSTER
6966
EnvironmentFile=-@INSTALL_RUNDATADIR@/wsrep-new-cluster
7067

7168
# Use an environment file to pass variable _WSREP_START_POSITION
7269
EnvironmentFile=-@INSTALL_RUNDATADIR@/wsrep-start-position
7370

74-
@SYSTEMD_EXECSTARTPRE@
75-
7671
# Perform automatic wsrep recovery. When server is started without wsrep,
7772
# galera_recovery simply returns an empty string. In any case, however,
7873
# the script is not expected to return with a non-zero status.
@@ -84,7 +79,7 @@ ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \
8479
&& echo _WSREP_START_POSITION=$VAR > @INSTALL_RUNDATADIR@/wsrep-start-position || exit 1"
8580

8681
# Needed to create system tables etc.
87-
# ExecStartPre=@scriptdir@/mariadb-install-db -u mysql
82+
# ExecStartPre=@scriptdir@/mariadb-install-db
8883

8984
# Start main service
9085
# MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf

support-files/tmpfiles.conf.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
# etc.
1313
# It shouldn't be used for datadir which is why it
1414
# may be disabled.
15-
@DISABLE_TMP@d @INSTALL_RUNDATADIR@ 0755 @MYSQLD_USER@ @MYSQLD_USER@ -
15+
@DISABLE_RUNDATADIR@d @INSTALL_RUNDATADIR@ 0755 @MYSQLD_USER@ @MYSQLD_USER@ -
16+
@DISABLE_MYSQL_UNIX_ADDRDIR@d @MYSQL_UNIX_ADDRDIR@ 0755 @MYSQLD_USER@ root -

0 commit comments

Comments
 (0)