Skip to contentSkip to conversation

mariadb: make it be able to work with SELinux

PATCH In review [email protected] 2 participants 2 messages Feb 6, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mariadb: make it be able to work with SELinux

From: Roy Li <[email protected]>

1. change the datadir from /var/mysql to /var/lib/mysql
2. after creating datedir, restorecon on it, make SELinux be able to work
3. Add the PIDFile for systemd unit file, otherwise systemctl can not stop mysqld

---
 meta-oe/recipes-support/mysql/mariadb.inc            | 1 +
 meta-oe/recipes-support/mysql/mariadb/my.cnf         | 2 +-
 meta-oe/recipes-support/mysql/mariadb/mysqld.service | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)
meta-oe/recipes-support/mysql/mariadb.inc +1 -0
index 8068862..f385bfc 100644
@@ -128,6 +128,7 @@ pkg_postinst_${PN}-server () {
 
     mysql_install_db --basedir=${prefix} --user=mysql
 
+    [ -x /sbin/restorecon ] && /sbin/restorecon -RF /var/lib/mysql
 }
 
 PACKAGES = "${PN}-dbg ${PN} \
meta-oe/recipes-support/mysql/mariadb/my.cnf +1 -1
index 876ce36..28d3899 100644
@@ -13,7 +13,7 @@ socket 						= /var/lib/mysql/mysql.sock
 pid-file 					= /var/lib/mysql/mysqld.pid
 log-error 					= /var/log/mysqld.err
 basedir 					= /usr
-datadir 					= /var/mysql
+datadir 					= /var/lib/mysql
 skip-external-locking
 skip-networking
 ignore-builtin-innodb
meta-oe/recipes-support/mysql/mariadb/mysqld.service +1 -0
index 18ad8d5..757d038 100644
@@ -4,6 +4,7 @@ After=syslog.target
 After=network.target
 
 [Service]
+PIDFile=/var/lib/mysql/mysqld.pid
 Type=simple
 User=mysql
 Group=mysql
Signature · 1 line
2.1.0
#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[email protected] schreef op 06-02-15 om 06:59:

Quoted 5 lines

From: Roy Li <[email protected]>

1. change the datadir from /var/mysql to /var/lib/mysql 2. after creating datedir, restorecon on it, make SELinux be able to work 3. Add the PIDFile for systemd unit file, otherwise systemctl can not stop mysqld

Shouldn't those all use the ${localstatedir} variable instead of hardcoding?

Quoted 33 lines
meta-oe/recipes-support/mysql/mariadb.inc            | 1 + 
meta-oe/recipes-support/mysql/mariadb/my.cnf         | 2 +- 
meta-oe/recipes-support/mysql/mariadb/mysqld.service | 1 + 3 files

changed, 3 insertions(+), 1 deletion(-)

(quoted diff) +0 -0

b/meta-oe/recipes-support/mysql/mariadb.inc index 8068862..f385bfc 100644 --- a/meta-oe/recipes-support/mysql/mariadb.inc +++ b/meta-oe/recipes-support/mysql/mariadb.inc @@ -128,6 +128,7 @@ pkg_postinst_${PN}-server () {

mysql_install_db --basedir=${prefix} --user=mysql

+ [ -x /sbin/restorecon ] && /sbin/restorecon -RF /var/lib/mysql }

PACKAGES = "${PN}-dbg ${PN} \ diff --git a/meta-oe/recipes-support/mysql/mariadb/my.cnf b/meta-oe/recipes-support/mysql/mariadb/my.cnf index 876ce36..28d3899 100644 --- a/meta-oe/recipes-support/mysql/mariadb/my.cnf +++ b/meta-oe/recipes-support/mysql/mariadb/my.cnf @@ -13,7 +13,7 @@ socket
= /var/lib/mysql/mysql.sock pid-file = /var/lib/mysql/mysqld.pid
log-error = /var/log/mysqld.err basedir = /usr -datadir =
/var/mysql +datadir = /var/lib/mysql skip-external-locking
skip-networking ignore-builtin-innodb diff --git a/meta-oe/recipes-support/mysql/mariadb/mysqld.service b/meta-oe/recipes-support/mysql/mariadb/mysqld.service index 18ad8d5..757d038 100644 --- a/meta-oe/recipes-support/mysql/mariadb/mysqld.service +++ b/meta-oe/recipes-support/mysql/mariadb/mysqld.service @@ -4,6 +4,7 @@ After=syslog.target After=network.target

Quoted 3 lines

[Service] +PIDFile=/var/lib/mysql/mysqld.pid Type=simple User=mysql Group=mysql

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
Comment: GPGTools - http://gpgtools.org

iD8DBQFU1H5NMkyGM64RGpERAiEDAJ9sJEaiGqhauXo0DJD2+cgMPshg8wCgsfHO DBiU69t3NR66pAvdQyNlh/Y=
=KiCJ
-----END PGP SIGNATURE-----