1580c87
%define distro redhat
1580c87
%define direct_initrc y
1580c87
%define monolithic n
1580c87
%define polname1 targeted
1580c87
%define type1 targeted-mcs
1580c87
%define polname2 strict
1580c87
%define type2 strict-mcs
1580c87
%define POLICYVER 20
1580c87
%define POLICYCOREUTILSVER 1.27.26-1
1580c87
%define CHECKPOLICYVER 1.27.17-5
1580c87
Summary: SELinux policy configuration
1580c87
Name: selinux-policy
1580c87
Version: 2.0.0
1580c87
Release: 0.6
1580c87
License: GPL
1580c87
Group: System Environment/Base
1580c87
Source: serefpolicy-%{version}.tgz
1580c87
Source1: seusers
1580c87
Source2: setrans.conf
1580c87
patch: policy-20051114.patch
1580c87
Url: http://serefpolicy.sourceforge.net
1580c87
BuildRoot: %{_tmppath}/serefpolicy-buildroot
1580c87
BuildArch: noarch
1580c87
BuildRequires: checkpolicy >= %{CHECKPOLICYVER} m4 policycoreutils >= %{POLICYCOREUTILSVER}
1580c87
Requires: policycoreutils >= %{POLICYCOREUTILSVER}
1580c87
Obsoletes: policy 
1580c87
1580c87
%define installCmds() \
1580c87
make NAME=%1 TYPE=%2 DISTRO=%{distro} DIRECT_INITRC=%{direct_initrc} MONOLITHIC=%{monolithic} base.pp \
1580c87
make NAME=%1 TYPE=%2 DISTRO=%{distro} DIRECT_INITRC=%{direct_initrc} MONOLITHIC=%{monolithic} modules \
1580c87
%{__mkdir} -p $RPM_BUILD_ROOT/%{_usr}/share/selinux/%1/ \
1580c87
%{__cp} *.pp $RPM_BUILD_ROOT/%{_usr}/share/selinux/%1/ \
1580c87
%{__mkdir} -p $RPM_BUILD_ROOT/%{_sysconfdir}/selinux/%1/policy \
1580c87
%{__mkdir} -p $RPM_BUILD_ROOT/%{_sysconfdir}/selinux/%1/modules/active \
1580c87
%{__mkdir} -p $RPM_BUILD_ROOT/%{_sysconfdir}/selinux/%1/contexts/files \
1580c87
make NAME=%1 TYPE=%{type1} DISTRO=%{distro} DIRECT_INITRC=%{direct_initrc} MONOLITHIC=y DESTDIR=$RPM_BUILD_ROOT install-appconfig \
1580c87
install -m0644 %{SOURCE1} ${RPM_BUILD_ROOT}%{_sysconfdir}/selinux/%1/modules/active/seusers \
1580c87
install -m0644 %{SOURCE2} ${RPM_BUILD_ROOT}%{_sysconfdir}/selinux/%1/setrans.conf \
1580c87
rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/booleans \
1580c87
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/config \
1580c87
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/seusers \
1580c87
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/policy/policy.%{POLICYVER} \
1580c87
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/contexts/files/file_contexts \
1580c87
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/contexts/files/homedir_template \
1580c87
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/contexts/files/file_contexts.homedirs 
1580c87
1580c87
%define fileList() \
1580c87
%defattr(-,root,root) \
1580c87
%dir %{_usr}/share/selinux \
1580c87
%dir %{_usr}/share/selinux/%1 \
1580c87
%config %{_usr}/share/selinux/%1/base.pp \
1580c87
%dir %{_sysconfdir}/selinux \
1580c87
%ghost %config(noreplace) %{_sysconfdir}/selinux/config \
1580c87
%dir %{_sysconfdir}/selinux/%1 \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/setrans.conf \
1580c87
%ghost %{_sysconfdir}/selinux/%1/seusers \
1580c87
%dir %{_sysconfdir}/selinux/%1/modules \
1580c87
%dir %{_sysconfdir}/selinux/%1/modules/active \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/modules/active/seusers \
1580c87
%dir %{_sysconfdir}/selinux/%1/policy/ \
1580c87
%ghost %{_sysconfdir}/selinux/%1/policy/policy.%{POLICYVER} \
1580c87
%dir %{_sysconfdir}/selinux/%1/contexts \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/customizable_types \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/dbus_contexts \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/default_contexts \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/default_type \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/failsafe_context \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/initrc_context \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/removable_context \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/userhelper_context \
1580c87
%dir %{_sysconfdir}/selinux/%1/contexts/files \
1580c87
%ghost %config %{_sysconfdir}/selinux/%1/contexts/files/file_contexts \
1580c87
%ghost %config %{_sysconfdir}/selinux/%1/contexts/files/homedir_template \
1580c87
%ghost %config %{_sysconfdir}/selinux/%1/contexts/files/file_contexts.homedirs \
1580c87
%config %{_sysconfdir}/selinux/%1/contexts/files/media
1580c87
1580c87
%define saveFileContext() \
1580c87
. %{_sysconfdir}/selinux/config; \
1580c87
FILE_CONTEXT=%{_sysconfdir}/selinux/%1/contexts/files/file_contexts; \
1580c87
if [ "${SELINUXTYPE}" == %1 -a -f ${FILE_CONTEXT} ]; then \
1580c87
	cp -f ${FILE_CONTEXT} ${FILE_CONTEXT}.pre; \
1580c87
fi 
1580c87
1580c87
%define rebuildpolicy() \
1580c87
semodule -b /usr/share/selinux/%1/base.pp -s %1 \
1580c87
for file in $(ls /usr/share/selinux/%1 | grep -v base.pp) \
1580c87
do \
1580c87
	semodule -i /usr/share/selinux/%1/$file -s %1;\
1580c87
done; 
1580c87
1580c87
%define relabel() \
1580c87
. %{_sysconfdir}/selinux/config; \
1580c87
FILE_CONTEXT=%{_sysconfdir}/selinux/%1/contexts/files/file_contexts; \
1580c87
if [ "${SELINUXTYPE}" == %1 -a -f ${FILE_CONTEXT}.pre ]; then \
1580c87
	fixfiles -C ${FILE_CONTEXT}.pre restore; \
1580c87
	rm -f ${FILE_CONTEXT}.pre; \
1580c87
fi; 
1580c87
1580c87
%description
1580c87
SELinux Reference Policy - modular.
1580c87
1580c87
%prep
1580c87
%setup -q -n serefpolicy-%{version}
1580c87
%patch -p1 
1580c87
1580c87
%build
1580c87
make conf
1580c87
1580c87
%install
1580c87
%{__rm} -fR $RPM_BUILD_ROOT
1580c87
%installCmds %{polname1} %{type1} 
1580c87
1580c87
# Commented out because only targeted ref policy currently builds
1580c87
%installCmds %{polname2} %{type2} 
1580c87
1580c87
%clean
1580c87
%{__rm} -fR $RPM_BUILD_ROOT
1580c87
1580c87
%package %{polname1}
1580c87
Summary: SELinux %{polname1} base policy
1580c87
Group: System Environment/Base
1580c87
Provides: selinux-policy-base
1580c87
Obsoletes: selinux-policy-%{polname1}-sources
1580c87
1580c87
%description %{polname1}
1580c87
SELinux Reference policy targeted base module.
1580c87
1580c87
%files %{polname1}
1580c87
%fileList %{polname1}
1580c87
1580c87
%pre %{polname1}
1580c87
%saveFileContext %{polname1}
1580c87
1580c87
%post %{polname1}
1580c87
if [ ! -s /etc/selinux/config ]; then
1580c87
	#
1580c87
	#	New install so we will default to targeted policy
1580c87
	#
1580c87
	echo "
1580c87
# This file controls the state of SELinux on the system.
1580c87
# SELINUX= can take one of these three values:
1580c87
#	enforcing - SELinux security policy is enforced.
1580c87
#	permissive - SELinux prints warnings instead of enforcing.
1580c87
#	disabled - No SELinux policy is loaded.
1580c87
SELINUX=enforcing
1580c87
# SELINUXTYPE= can take one of these two values:
1580c87
#	targeted - Only targeted network daemons are protected.
1580c87
#	strict - Full SELinux protection.
1580c87
SELINUXTYPE=targeted 
1580c87
# SETLOCALDEFS= Check local definition changes
1580c87
SETLOCALDEFS=0 
1580c87
1580c87
" > /etc/selinux/config
1580c87
1580c87
	ln -sf /etc/selinux/config /etc/sysconfig/selinux 
1580c87
	restorecon /etc/selinux/config 2> /dev/null
1580c87
else
1580c87
	# if first time update booleans.local needs to be copied to sandbox
1580c87
	[ -f /etc/selinux/%{polname1}/booleans.local ] && mv /etc/selinux/%{polname1}/booleans.local /etc/selinux/%{polname1}/modules/active/
1580c87
	[ -f /etc/selinux/%{polname1}/seusers ] && cp -f /etc/selinux/%{polname1}/seusers /etc/selinux/%{polname1}/modules/active/seusers
1580c87
	grep -q "^SETLOCALDEFS" /etc/selinux/config || echo -n "
1580c87
# SETLOCALDEFS= Check local definition changes
1580c87
SETLOCALDEFS=0 
1580c87
">> /etc/selinux/config
1580c87
fi
1580c87
%rebuildpolicy %{polname1}
1580c87
%relabel %{polname1}
1580c87
1580c87
%triggerpostun %{polname1} -- selinux-policy-%{polname1} <= 2.0.0
1580c87
%rebuildpolicy %{polname1}
1580c87
1580c87
%package %{polname2} 
1580c87
Summary: SELinux %{polname2} base policy
1580c87
Group: System Environment/Base
1580c87
Provides: selinux-policy-base
1580c87
Obsoletes: selinux-policy-%{polname1}-sources
1580c87
1580c87
%description %{polname2} 
1580c87
SELinux Reference policy %{polname2} base module.
1580c87
1580c87
%pre %{polname2} 
1580c87
%saveFileContext %{polname2}
1580c87
1580c87
%post %{polname2} 
1580c87
%rebuildpolicy %{polname2} 
1580c87
%relabel %{polname1}
1580c87
1580c87
%triggerpostun %{polname2} -- %{polname2} <= 2.0.0
1580c87
%{rebuildpolicy} %{polname2} 
1580c87
1580c87
%files %{polname2}
1580c87
#%#fileList %{polname2}
1580c87
1580c87
%changelog
1580c87
* Wed Nov 9 2003 Dan Walsh <dwalsh@redhat.com> 2.0.0-5
1580c87
- Initial version