Skip to content

Commit c1a23cd

Browse files
committed
MDEV-11676 Starting service with mysqld_safe_helper fails in SELINUX "enforcing" mode
compile, and install selinux policy for mysqld_safe_helper on centos6. the policy was created as described in https://mariadb.com/kb/en/mariadb/what-to-do-if-mariadb-doesnt-start/#other-selinux-changes
1 parent 6ad3dd6 commit c1a23cd

File tree

7 files changed

+52
-2
lines changed

7 files changed

+52
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ support-files/mysql.spec
221221
support-files/mysqld_multi.server
222222
support-files/wsrep.cnf
223223
support-files/wsrep_notify
224+
support-files/SELinux/centos6-mariadb.pp
224225
tags
225226
tests/async_queries
226227
tests/bug25714

support-files/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ IF(UNIX)
6767
ENDFOREACH()
6868
IF(INSTALL_SUPPORTFILESDIR)
6969
INSTALL(FILES magic DESTINATION ${inst_location} COMPONENT SupportFiles)
70-
INSTALL(DIRECTORY RHEL4-SElinux/ DESTINATION ${inst_location}/SELinux/RHEL4 COMPONENT SupportFiles)
70+
ADD_SUBDIRECTORY(SELinux)
7171
ENDIF()
7272

7373
INSTALL(FILES mysql.m4 DESTINATION ${INSTALL_SHAREDIR}/aclocal COMPONENT Development)

support-files/SELinux/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) 2017, MariaDB
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation; version 2 of the License.
6+
#
7+
# This program is distributed in the hope that it will be useful,
8+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
# GNU General Public License for more details.
11+
#
12+
# You should have received a copy of the GNU General Public License
13+
# along with this program; if not, write to the Free Software
14+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15+
16+
FIND_PROGRAM(CHECKMODULE checkmodule)
17+
FIND_PROGRAM(SEMODULE_PACKAGE semodule_package)
18+
MARK_AS_ADVANCED(CHECKMODULE SEMODULE_PACKAGE)
19+
20+
SET(params DESTINATION ${INSTALL_SUPPORTFILESDIR}/SELinux COMPONENT SupportFiles)
21+
22+
IF(CHECKMODULE AND SEMODULE_PACKAGE)
23+
FOREACH(pol centos6-mariadb)
24+
SET(src ${CMAKE_CURRENT_SOURCE_DIR}/${pol}.te)
25+
SET(mod ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${pol}-pp.dir/${pol}.mod)
26+
SET(out ${CMAKE_CURRENT_BINARY_DIR}/${pol}.pp)
27+
ADD_CUSTOM_COMMAND(OUTPUT ${out}
28+
COMMAND ${CHECKMODULE} -M -m ${src} -o ${mod}
29+
COMMAND ${SEMODULE_PACKAGE} -m ${mod} -o ${out}
30+
DEPENDS ${src})
31+
ADD_CUSTOM_TARGET(${pol}-pp ALL DEPENDS ${out})
32+
INSTALL(FILES ${out} ${params})
33+
ENDFOREACH()
34+
ENDIF()
35+
INSTALL(FILES centos6-mariadb.te rhel4-mysql.fc rhel4-mysql.te ${params})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module mariadb 1.0;
2+
3+
require {
4+
type mysqld_safe_t;
5+
class capability { setuid setgid };
6+
}
7+
8+
#============= mysqld_safe_t ==============
9+
allow mysqld_safe_t self:capability { setuid setgid };

support-files/rpm/server-postin.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ if [ -f /etc/redhat-release ] ; then
7979
echo ' make load'
8080
echo
8181
echo
82-
fi
82+
fi
83+
if grep 'CentOS release 6' /etc/redhat-release >/dev/null 2>&1; then
84+
if [ -x /usr/sbin/semodule ] ; then
85+
/usr/sbin/semodule -i /usr/share/mysql/SELinux/centos6-mariadb.pp
86+
fi
87+
fi
8388
fi
8489

8590
if [ -x sbin/restorecon ] ; then

0 commit comments

Comments
 (0)