|
Petr Lautrbach |
c49229 |
# Copyright (C) 2016 Petr Lautrbach
|
|
Petr Lautrbach |
c49229 |
#
|
|
Petr Lautrbach |
c49229 |
# This program is free software; you can redistribute it and/or
|
|
Petr Lautrbach |
c49229 |
# modify it under the terms of the GNU General Public License
|
|
Petr Lautrbach |
c49229 |
# as published by the Free Software Foundation; either version 2
|
|
Petr Lautrbach |
c49229 |
# of the License, or (at your option) any later version.
|
|
Petr Lautrbach |
c49229 |
#
|
|
Petr Lautrbach |
c49229 |
# This program is distributed in the hope that it will be useful,
|
|
Petr Lautrbach |
c49229 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Petr Lautrbach |
c49229 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Petr Lautrbach |
c49229 |
# GNU General Public License for more details.
|
|
Petr Lautrbach |
c49229 |
#
|
|
Petr Lautrbach |
c49229 |
# You should have received a copy of the GNU General Public License
|
|
Petr Lautrbach |
c49229 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Petr Lautrbach |
c49229 |
|
|
Petr Lautrbach |
c49229 |
# RPM macros for packages installing SELinux modules
|
|
Petr Lautrbach |
c49229 |
|
|
Petr Lautrbach |
c49229 |
%_selinux_policy_version SELINUXPOLICYVERSION
|
|
Petr Lautrbach |
c49229 |
|
|
Petr Lautrbach |
c49229 |
%_file_context_file %{_sysconfdir}/selinux/${SELINUXTYPE}/contexts/files/file_contexts
|
|
Petr Lautrbach |
c49229 |
%_file_context_file_pre %{_localstatedir}/lib/rpm-state/file_contexts.pre
|
|
Petr Lautrbach |
c49229 |
|
|
Petr Lautrbach |
c49229 |
# %selinux_modules_install [-s <policytype>] module [module]...
|
|
Petr Lautrbach |
c49229 |
%selinux_modules_install("s:") \
|
|
Petr Lautrbach |
c49229 |
. /etc/selinux/config \
|
|
Petr Lautrbach |
c49229 |
_policytype=%{-s*} \
|
|
Petr Lautrbach |
c49229 |
if [ -z "${_policytype}" ]; then \
|
|
Petr Lautrbach |
c49229 |
_policytype="targeted" \
|
|
Petr Lautrbach |
c49229 |
fi \
|
|
Petr Lautrbach |
c49229 |
%{_sbindir}/semodule -n -s ${_policytype} -X 200 -i %* \
|
|
Petr Lautrbach |
c49229 |
if %{_sbindir}/selinuxenabled && [ "${SELINUXTYPE}" = "${_policytype}" ]; then \
|
|
Petr Lautrbach |
c49229 |
%{_sbindir}/load_policy \
|
|
Petr Lautrbach |
c49229 |
fi \
|
|
Petr Lautrbach |
c49229 |
%{nil}
|
|
Petr Lautrbach |
c49229 |
|
|
Petr Lautrbach |
c49229 |
# %selinux_modules_uninstall [-s <policytype>] module [module]...
|
|
Petr Lautrbach |
c49229 |
%selinux_modules_uninstall("s:") \
|
|
Petr Lautrbach |
c49229 |
. /etc/selinux/config \
|
|
Petr Lautrbach |
c49229 |
_policytype=%{-s*} \
|
|
Petr Lautrbach |
c49229 |
if [ -z "${_policytype}" ]; then \
|
|
Petr Lautrbach |
c49229 |
_policytype="targeted" \
|
|
Petr Lautrbach |
c49229 |
fi \
|
|
Petr Lautrbach |
c49229 |
if [ $1 -eq 0 ]; then \
|
|
Petr Lautrbach |
c49229 |
%{_sbindir}/semodule -n -X 200 -r %* &> /dev/null || : \
|
|
Petr Lautrbach |
c49229 |
if %{_sbindir}/selinuxenabled && [ "${SELINUXTYPE}" = "${_policytype}" ]; then \
|
|
Petr Lautrbach |
c49229 |
%{_sbindir}/load_policy \
|
|
Petr Lautrbach |
c49229 |
fi \
|
|
Petr Lautrbach |
c49229 |
fi \
|
|
Petr Lautrbach |
c49229 |
%{nil}
|
|
Petr Lautrbach |
c49229 |
|
|
Petr Lautrbach |
c49229 |
# %selinux_relabel_pre [-s <policytype>]
|
|
Petr Lautrbach |
c49229 |
%selinux_relabel_pre("s:") \
|
|
Petr Lautrbach |
c49229 |
. /etc/selinux/config \
|
|
Petr Lautrbach |
c49229 |
_policytype=%{-s*} \
|
|
Petr Lautrbach |
c49229 |
if [ -z "${_policytype}" ]; then \
|
|
Petr Lautrbach |
c49229 |
_policytype="targeted" \
|
|
Petr Lautrbach |
c49229 |
fi \
|
|
Petr Lautrbach |
c49229 |
if %{_sbindir}/selinuxenabled && [ "${SELINUXTYPE}" = "${_policytype}" ]; then \
|
|
Petr Lautrbach |
c49229 |
[ -f %{_file_context_file_pre} ] || cp -f %{_file_context_file} %{_file_context_file_pre} \
|
|
Petr Lautrbach |
c49229 |
fi \
|
|
Petr Lautrbach |
c49229 |
%{nil}
|
|
Petr Lautrbach |
c49229 |
|
|
Petr Lautrbach |
c49229 |
|
|
Petr Lautrbach |
c49229 |
# %selinux_relabel_post [-s <policytype>]
|
|
Petr Lautrbach |
c49229 |
%selinux_relabel_post("s:") \
|
|
Petr Lautrbach |
c49229 |
. /etc/selinux/config \
|
|
Petr Lautrbach |
c49229 |
_policytype=%{-s*} \
|
|
Petr Lautrbach |
c49229 |
if [ -z "${_policytype}" ]; then \
|
|
Petr Lautrbach |
c49229 |
_policytype="targeted" \
|
|
Petr Lautrbach |
c49229 |
fi \
|
|
Petr Lautrbach |
c49229 |
if /usr/sbin/selinuxenabled && [ "${SELINUXTYPE}" = "${_policytype}" ]; then \
|
|
Petr Lautrbach |
c49229 |
if [ -f %{_file_context_file_pre} ]; then \
|
|
Petr Lautrbach |
c49229 |
%{_sbindir}/fixfiles -C %{_file_context_file_pre} restore \
|
|
Petr Lautrbach |
c49229 |
rm -f %{_file_context_file_pre} \
|
|
Petr Lautrbach |
c49229 |
fi \
|
|
Petr Lautrbach |
c49229 |
fi \
|
|
Petr Lautrbach |
c49229 |
%{nil}
|