Skip to content

Commit 3723c70

Browse files
grooverdansvoj
authored andcommitted
MDEV-426: systemd PermissionsStartOnly=true by default
mariadb-service-convert during migration can create a file containing ExecStartPre=/usr/sbin/sysctl -q -w vm.drop_caches=3 if the users my.cnf contains [mysqld_safe] flush_caches. This sysctl entry change requires root access. No existing ExecStartPre requires execution requires execution as another user. There is a comment in the mariadb{,@}.service.in that indicates mysqld_install which would require -u mysql to explicity change user to mysql from root since PermissionsStartOnly=true. Otherwise the following error would be generated: Oct 14 07:38:38 spaceman systemd[1]: Starting MariaDB database server... -- Subject: Unit mariadb.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mariadb.service has begun starting up. Oct 14 07:38:38 spaceman sysctl[10089]: sysctl: permission denied on key 'vm.drop_caches' Oct 14 07:38:38 spaceman systemd[1]: mariadb.service: control process exited, code=exited status=255 Oct 14 07:38:38 spaceman systemd[1]: Failed to start MariaDB database server.
1 parent 079cc48 commit 3723c70

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

cmake/systemd.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ MACRO(CHECK_SYSTEMD)
6161
${INSTALL_SYSTEMD_UNITDIR}/mariadb@.service
6262
${INSTALL_SYSTEMD_UNITDIR}/mariadb@bootstrap.service.d/wsrep-new-cluster.conf")
6363
IF(DEB)
64-
SET(SYSTEMD_EXECSTARTPRE "PermissionsStartOnly=true\nExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld")
64+
SET(SYSTEMD_EXECSTARTPRE "ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld")
6565
SET(SYSTEMD_EXECSTARTPOST "ExecStartPost=/etc/mysql/debian-start")
6666
ENDIF()
6767
MESSAGE(STATUS "Systemd features enabled")

support-files/mariadb.service.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ User=mysql
4343
Group=mysql
4444

4545
# Execute pre and post scripts as root, otherwise it does it as User=
46-
# PermissionsStartOnly=true
46+
PermissionsStartOnly=true
4747

4848
# Needed to create system tables etc.
49-
# ExecStartPre=/usr/bin/mysql_install_db
49+
# ExecStartPre=/usr/bin/mysql_install_db -u mysql
5050

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

support-files/mariadb@.service.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ User=mysql
5050
Group=mysql
5151

5252
# Execute pre and post scripts as root, otherwise it does it as User=
53-
# PermissionsStartOnly=true
53+
PermissionsStartOnly=true
5454

5555
# Needed to create system tables etc.
56-
# ExecStartPre=/usr/bin/mysql_install_db
56+
# ExecStartPre=/usr/bin/mysql_install_db -u mysql
5757

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

0 commit comments

Comments
 (0)